Welcome Guest, Not a member yet? Register   Sign In
$this->db->limit Problem
#1

[eluser]LDMajor[/eluser]
Code:
$this->db->where('to',$this->uri->segment(3));
                $this->db->where('picname',0);
                $qcm=$this->db->get('comments');            
                if ($qcm->num_rows() == 0) {
                    $data['yescomm']=0;
                } else {
                    $data['yescomm']=1;
                    $perpage=10;
                    if ($this->uri->segment(4)) {
                        $page=$this->uri->segment(4);
                    } else {
                        $page=1;
                    }
                    $nump=$qcm->num_rows();
                    $nump = $nump / $perpage;
                    if(intval($nump) != $nump)
                        $data['nump'] = intval($nump) + 1;
                    $lim1 = ($page - 1) * $perpage;
                    $this->db->where('to',$this->uri->segment(3));
                    $this->db->where('picname',0);
                    $this->db->limit($lim1, $perpage);
                    $data['comments']=$this->db->get('comments');
                }
I tested the code and without the LIMIT the code works fine
and with it is doesn't select anything!

please help
Dan.
#2

[eluser]Crimp[/eluser]
I would look at the SQL and see if it makes sense. If it does, I would try running the SQL in a db app or phpMyAdmin against the record set to see if it returns what I expect. If not, I would tweak the actual query to select the records I expect. Then I would go back to the AR code to produce the correct SQL.
#3

[eluser]Thorpe Obazee[/eluser]
run <?php echo $this->db->last_query();?>

this would output the SQL statement. Check the SQL on phpmyadmin or something like it.




Theme © iAndrew 2016 - Forum software by © MyBB