* 'and type = 1 and username like "%os%"'
* 数组模式:
* array('type = 1', 'username like "%os%"')
* string $orderby 排序,默认为 id 倒序
*/
public
function
select(
$debug
,
$mode
,
$table
,
$fields
="*",
$sqlwhere
="",
$orderby
="tbid desc"){
//参数处理
if
(
is_array
(
$table
)){
$table
= implode(', ',
$table
);
}
if
(
is_array
(
$fields
)){
$fields
= implode(', ',
$fields
);
}
if
(
is_array
(
$sqlwhere
)){
$sqlwhere
= ' and '.implode(' and ',
$sqlwhere
);
}
//数据库操作
if
(
$debug
=== 0){
if
(
$mode
=== 2){
$this
->query("select count(tbid) from $table where 1=1 $sqlwhere");
$return
=
$this
->fetchColumn();
}
else
if
(
$mode
=== 1){
$this
->query("select $fields from $table where 1=1 $sqlwhere order by $orderby");
$return
=
$this
->fetch();
}
else
{
$this
->query("select $fields from $table where 1=1 $sqlwhere order by $orderby");
$return
=
$this
->fetchAll();
}
return
$return
;
}
else
{
if
(
$mode
=== 2){
echo
"select count(tbid) from $table where 1=1 $sqlwhere";
}
else
if
(
$mode
=== 1){
echo
"select $fields from $table where 1=1 $sqlwhere order by $orderby";
}
else
{
echo
"select $fields from $table where 1=1 $sqlwhere order by $orderby";
}
if
(
$debug
=== 2){
exit
;
}
}
}