Welcome Guest, Not a member yet? Register   Sign In
Pagination using $this->db->query
#1

[eluser]christiaan001[/eluser]
Hi there,

Please forgive me but I am having trouble passing $offset when using pagination within $this->db->query. I can pass $num,$offset using $this->db->get with no problems.

Please see code:

Code:
function getAllUser($num, $offset)
    {
     $query = $this->db->get('tbluser', $num,$offset);    
     return $query->result();
    }

The above function works fine:

The function below produces a database error.

Code:
function getAllUser($num, $offset)
        {
          $query = $this->db->query("SELECT intUserID, strFirstName, strSurname,  strEmail,datRegistration, AES_DECRYPT(strEncrypt,'key :) ')
          AS strEncrypt, strUserType      
          FROM tbluser  
          ORDER BY intUserID
          Limit '$num','$offset'");    
          return $query->result();
        }

Database error:

A Database Error Occurred
Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' '5',''' at line 1

select * from tblimage Limit, '5',''

If anyone can point out where I am going wrong muchly appreciated
#2

[eluser]deepydee[/eluser]
'.$num.', '.$page.'




Theme © iAndrew 2016 - Forum software by © MyBB