Php FAQs about obtaining sybase database content

Source: Internet
Author: User
Tags sybase sybase database
The problem of php obtaining sybase database content the database connection has been tested. No problem, and no problem with SQL statements. The problem is that the data in the database cannot be obtained. the code is as follows: public & nbsp; static & nbsp; function & nbsp; Connect () & nbsp ;{& nbsp; $ obj & nbsp; = new & nbsp; php: problem about obtaining sybase database content
The database connection has been tested. No problem, and no problem with SQL statements. The problem is that the data in the database cannot be obtained. the code is as follows:
Public static function Connect ()
{
$ Obj = new DB ();
$ Conn = $ obj-> Connection = sybase_connect (SERVER_NAME, USER, PASSWORD); // connect to the database
If (! $ Conn ){
Echo 'database connection error ...';
Exit (0 );
}
Sybase_select_db (DATABASE_NAME );
Return $ obj;
}
// Query the sales records of the last month when initializing the page
Public function QueryLastMonth (){
$ Start_date = str_replace ('-', '', date ('Y-m-D', strtotime ('-1 month ')));
$ End_date = str_replace ('-', '', date ('Y-m-D', time ()));
$ SQL _str = "select cusno as shopcode, u2.nos as salesid, u2.colthno as goodsid, u2.endprice as price, u2.nb as goodscount from u2sale u1, u2saleb u2 where u1.outdate> = ";
$ SQL = $ SQL _str. "'". $ start_date. "'and u1.outdate <= '". $ end_date. "'and u1.nos = u2.nos and u1.nb> 0 and u2.endprice> 0 ;";

// Echo $ SQL;
// Sybase_query ("set rowcount". 20); // run the SQL command to set the number of returned Records
$ Result = sybase_query ($ SQL); // execute the SQL command to retrieve the database
Echo "---". $ result;
While ($ row = sybase_fetch_assoc ($ result ))
{
// Echo 'XXX ';
Echo $ row ["shopcode"]. "---". $ row ["salesid"]. "---". $ row ["goodscount"]. "\ n ";
}

Sybase_close ($ conn );
}

Please share with us the following: More

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.