How do i convert this line of code into a query which will be accepted by MSSQL Server 2012?
Im getting this error That happens when im trying to convert it into a query for mssql 时,我试图将其转换为mssql查询时会发生这种情况
function login($username, $password) {
$this -> db -> select();
$this -> db -> from('tbl_user');
$this -> db -> JOIN('tbl_assign_role', 'tbl_user.u_id = tbl_assign_role.tar_owner_id');
$this -> db -> where('tbl_user.u_uname = ' . "'" . htmlspecialchars($username) . "'");
$this -> db -> where('tbl_user.u_pword = ' . "'" . MD5($password) . "'");
$this -> db -> where('tbl_user.is_active = 1');
$this -> db -> limit(1);
$query = $this -> db -> get();
if($query -> num_rows() == 1)
{
return $query->result();
}
else
{
return false;
}
}
I change it into this
$query = "SELECT * FROM tbl_user
LEFT JOIN tbl_assign_role ON tbl_user.u_id = tbl_assign_role.tar_owner_id
WHERE tbl_user.u_name = '".$username."'
AND tbl_user.u_pword = '".MD5($password)."'
AND tbl_user.is_active = 1
FETCH NEXT 1 ROWS ONLY
";
After i changed, that became the error.
It's working now. What I've done is
$query = "SELECT TOP 1 * FROM tbl_user
JOIN tbl_assign_role ON tbl_user.u_id = tbl_assign_role.tar_owner_id
WHERE tbl_user.u_uname = '".htmlspecialchars($username)."'
AND tbl_user.u_pword = '".MD5($password)."'
AND tbl_user.is_active = 1";
$query = $this->db->query($query);
您好希望这对您有帮助...
"SELECT tbl_user.*,tbl_assign_role.* FROM tbl_user left join tbl_assign_role on tbl_assign_role.tar_owner_id = tbl_user.u_id where tbl_user.u_uname = '".htmlspecialchars($username)."' and tbl_user.u_pword ='".MD5($password)."' and tbl_user.is_active='1' limit 1";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.