CodeIgniter Forums
or_Where() Question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: or_Where() Question (/showthread.php?tid=13999)



or_Where() Question - El Forum - 12-15-2008

[eluser]Unknown[/eluser]
I need make a or_Where() query, but make a error!

Code:
controller

$this->db->get->('number');
$this->db->where('name',$_POST['search']);
$information['people'] = $this->db->or_where('nick',$_POST['search']);
$this->load->view('lista_view',$information);

I think is correct, but in the view is the problem with the:

Code:
view
<?php if ($people->num_rows() > 0): ?>

Appears:

Fatal error: Call to undefined method CI_DB_mysql_driver::num_rows()


And if i remove the test with num_rows() apears another error, but this time with result()


Sorry for my poor English Smile


or_Where() Question - El Forum - 12-15-2008

[eluser]gstjohn[/eluser]
I don't believe you are querying correctly. I think you want the following:

Code:
$this->db->where('name',$_POST['search']);
$this->db->or_where('nick',$_POST['search']);
$query = $this->db->get->('number');

foreach ($query->result() as $row) {
   $information['people'][] = $row;
}

$this->load->view('lista_view',$information);



or_Where() Question - El Forum - 12-15-2008

[eluser]gstjohn[/eluser]
Sorry for the double post.

If your view, you can then just check the length of your $people array with count().

Code:
<?php if (count($people) > 0) : ?>



or_Where() Question - El Forum - 12-16-2008

[eluser]Unknown[/eluser]
Thanks.

I saw the error after

Thank you very much