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