我装了这个函数,它的工作原理几乎总是无处不在,开始产生这个错误,有人可以帮助我吗?
function busca_um($id = NULL, $usuario = NULL, $email = null)
{
if (isset($id)) {
$this->db->where('usuario_id', $id);
}
if (isset($usuario)) {
$this->db->where('usuario', $usuario);
}
if (isset($email)) {
$this->db->where('email', $email);
}
$query = $this->db->get('tb_usuario');
if (sizeof($query) > 0) {
$result = $query->result();
return $result[0];
} else {
return null;
}
}
从我的sql生成这个错误
SELECT *,* FROM
tb_usuario
WHEREusuario
='xxxx'
这个错误我不能查找选择*,*
有人知道吗?
发布于 2018-05-31 11:20:52
你的模型的方法busca_um
应该是这样的:
function busca_um($id = NULL, $usuario = NULL, $email = null)
{
if (! empty($id))
{
$this->db->where('usuario_id', $id);
}
if (! empty($usuario))
{
$this->db->where('usuario', $usuario);
}
if (! empty($email))
{
$this->db->where('email', $email);
}
$query = $this->db->get('tb_usuario');
if ($query->num_rows() > 0)
{
return $query->row();
/* you can also use the same as above
$result = $query->result();
return $result[0];
*/
}
else
{
return null;
}
}
https://stackoverflow.com/questions/-100004639
复制相似问题