日期:2014-05-16 浏览次数:20522 次
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);
}