Welcome Guest, Not a member yet? Register   Sign In
or_Where() Question
#1

[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
#2

[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);
#3

[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) : ?>
#4

[eluser]Unknown[/eluser]
Thanks.

I saw the error after

Thank you very much




Theme © iAndrew 2016 - Forum software by © MyBB