我使用此代码来验证用户。
public function verify_user($username, $password)
{
$q = $this->db->where('username', $username)
->where('password', md5($password))
->limit(1)
->get('users');
if ($q->num_rows() === 1) {
echo '<pre>';
print_r($q->row());
echo '</pre>';
} else {
echo 'EMPTY';
}
}
但是,当它等于 1 时,它什么也不显示。
Array
(
)
当我使用此代码修复 odbc num_rows = -1 问题时出现:CODEIGNITER Issue on line 40 until 67
编辑==============================
我想要达到的是这个
stdClass Object
(
[id_user] => 2
[username] => 114080077
[password] => 0d5ccab9e7f4ae3fe040f143046e386c
)
我修改的代码是: 之前(STABLE VERSION):
/**
* Number of rows in the result set
*
* @access public
* @return integer
*/
function num_rows()
{
return @odbc_num_rows($this->result_id);
}
之后(问题修复):
/**
* Number of rows in the result set
*
* @return int
*/
public function num_rows()
{
if (is_int($this->num_rows))
{
return $this->num_rows;
}
elseif (($this->num_rows = @odbc_num_rows($this->result_id)) !== -1)
{
return $this->num_rows;
}
// Work-around for ODBC subdrivers that don't support num_rows()
if (count($this->result_array) > 0)
{
return $this->num_rows = count($this->result_array);
}
elseif (count($this->result_object) > 0)
{
return $this->num_rows = count($this->result_object);
}
return $this->num_rows = count($this->result_array());
}