public
function
get_what(
$table
='',
$where
=
array
(),
$fields
= ' * '){
if
( '' ==
$table
){
return
false;
}
$query
=
$this
->db->select(
$fields
)->where(
$where
)->get(
$table
);
$res
=
$query
->result_array();
return
$res
;
}
public
function
get_row(
$table
='',
$where
=
array
(),
$fields
= ' * '){
if
( '' ==
$table
){
return
false;
}
$query
=
$this
->db->select(
$fields
)->where(
$where
)->get(
$table
);
$res
=
$query
->row_array();
return
$res
;
}
public
function
update_what(
$table
='',
$where
=
array
(),
$data
=
array
()){
if
('' ==
$table
|| true ===
empty
(
$where
) || true ===
empty
(
$data
)){
return
false;
}
$query
=
$this
->db->update(
$table
,
$data
,
$where
);
return
$query
;
}
public
function
update_count(
$table
= '',
$where
=
array
(),
$data
=
array
()){
if
('' ==
$table
||
empty
(
$data
)){
return
false;
}
foreach
(
$data
as
$key
=>
$val
){
if
(false !==
stripos
(
$val
,'+') || false !==
stripos
(
$val
,'-')){
$this
->db->set(
$key
,
$val
, FALSE);
}
else
{
$this
->db->set(
$key
,
$val
);
}
}
$res
=
$this
->db->where(
$where
)->update(
$table
);
return
$res
;
}
public
function
insert_what(
$table
= '',
$data
=
array
()){
if
('' ==
$table
|| true ===
empty
(
$data
)){
return
false;
}
$query
=
$this
->db->insert(
$table
,
$data
);
return
$query
;
}
public
function
delete_what(
$table
= '',
$where
=
array
()){
if
(true ===
empty
(
$where
) || '' ==
$table
){
return
false;
}
$query
=
$this
->db->
delete
(
$table
,
$where
);
return
$query
;
}
public
function
debug_what(
$org_error
= ''){
$con
=
$this
->router->fetch_class();
$func
=
$this
->router->fetch_method();
if
(
$org_error
){
$error
.=
date
(
"Y-m-d H:i:s"
,time()).
"\r\n"
;
$error
.=
__FILE__
.
"\r\n"
;
$error
.=
$con
.
" 控制器下的:\r\n"
;
$error
.=
$func
.
" 方法调试信息如下:\r\n"
;
$error
.=
$org_error
;
file_put_contents
(
"./error_log.txt"
,
$error
.
"\r\n"
,FILE_APPEND);
}
}