php獲得sybase資料庫內容的問題
資料庫連接已經測試過了沒問題,sql語句也沒問題。現在問題是擷取不到資料庫裡的資料,代碼如下:
public static function Connect()
{
$obj =new DB();
$conn=$obj->Connection=sybase_connect(SERVER_NAME, USER, PASSWORD) ; // 串連資料庫
if(!$conn){
echo '資料庫連接錯誤...';
exit(0);
}
sybase_select_db(DATABASE_NAME);
return $obj;
}
//初始化頁面時查詢最近一個月的銷售記錄
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) ; // 執行SQL命令,設定返回記錄行數
$result = sybase_query($sql) ; // 執行SQL命令,檢索資料庫
echo "---".$result;
while($row = sybase_fetch_assoc($result))
{
// echo 'xxx';
echo $row["shopcode"] . "---" . $row["salesid"] . "---" . $row["goodscount"] . "\n" ;
}
sybase_close($conn);
}
請指教
分享到: 更多
------解決方案--------------------
直接拿列印的sql,放到編輯器執行啊。
------解決方案--------------------
那麼 echo $result; 得到的是什嗎?
echo sybase_get_last_message(); 又看到了什嗎?