我使用此代码来验证用户。
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问题时,它会出现:第40行的CODEIGNITER问题,直到67
编辑=========================
我想要的是这个
stdClass Object
(
[id_user] => 2
[username] => 114080077
[password] => 0d5ccab9e7f4ae3fe040f143046e386c
)
我修改的代码是:之前(稳定版本):
/**
* 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());
}
您不能只使用CI_DB_odbc_result
的开发版本,而保留2.1版本树中的其余内容。如果你不想全部替换它们,你需要从存储库中获得以下文件:
system/database/DB_driver.php
system/database/DB_result.php
system/database/drivers/odbc/odbc_driver.php
system/database/drivers/odbc/odbc_result.php
(假设您只使用ODBC)
ODBC结果类仍然存在问题,我将对此进行研究,但考虑到您的问题涉及尚未发布的CodeIgniter版本,最好将任何问题报告发布到CodeIgnitor论坛或GitHub存储库。
if条件中存在错误,请使用:
$q->num_rows()
并尝试使用
$q->result()
而不是->row()
通过将system/database/drivers/odbc/odbc_result.php替换为以下文件修复:修复问题