时间:2021-07-01 10:21:17 帮助过:36人阅读
- public static function Connect()<br>
- {<br>
- $obj =new DB();<br>
- $conn=$obj->Connection=sybase_connect(SERVER_NAME, USER, PASSWORD) ; // 连接数据库<br>
- if(!$conn){<br>
- echo '数据库连接错误...';<br>
- exit(0);<br>
- }<br>
- sybase_select_db(DATABASE_NAME);<br>
- return $obj; <br>
- }<br>
- //初始化页面时查询最近一个月的销售记录<br>
- public function QueryLastMonth(){<br>
- $start_date=str_replace('-','',date('Y-m-d',strtotime('-1 month')));<br>
- $end_date=str_replace('-','',date('Y-m-d',time()));<br>
- $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>=";<br>
- $sql=$sql_str ."'".$start_date."' and u1.outdate<='".$end_date."' and u1.nos=u2.nos and u1.nb>0 and u2.endprice>0;";<br>
- <br>
- //echo $sql;<br>
- // sybase_query("set rowcount " . 20) ; // 执行SQL命令,设置返回记录行数<br>
- $result = sybase_query($sql) ; // 执行SQL命令,检索数据库<br>
- echo "---".$result;<br>
- while($row = sybase_fetch_assoc($result)) <br>
- { <br>
- // echo 'xxx';<br>
- echo $row["shopcode"] . "---" . $row["salesid"] . "---" . $row["goodscount"] . "\n" ;<br>
- }<br>
- <br>
- sybase_close($conn);<br>
- }