Note that there are some explanatory texts on larger screens.

plurals
  1. POCodeIgniter MySQL query where not working after a label
    text
    copied!<p>i am trying to get result from database conditionally. like where a = 1 and b != 2 and so much conditions...</p> <p>here is my code sample</p> <pre><code>$u = $this-&gt;ion_auth-&gt;user()-&gt;row()-&gt;id; $hide=$this-&gt;find_hide_post(); $friend=$this-&gt;get_all_contacts(); </code></pre> <p>after this i start my main query</p> <pre><code>$this-&gt;db-&gt;where('user_id',$u); foreach($friend as $fr) { foreach($fr as $f) { if($f-&gt;sub_id !=$u) { $this-&gt;db-&gt;or_where('user_id', $f-&gt;sub_id); } elseif($f-&gt;obj_id !=$u) { $this-&gt;db-&gt;or_where('user_id', $f-&gt;obj_id); } $this-&gt;db-&gt;where('time &gt;', $f-&gt;time); } } </code></pre> <p>i get good correct result, but whenever i add these lines i didnt get correct result. but i need to remove those posts from result.</p> <pre><code>foreach($hide as $h) { $this-&gt;db-&gt;where('id !=', $h-&gt;post_id); } </code></pre> <p>lastly i get through this way</p> <pre><code>$result=$this-&gt;db-&gt;get('my_wall'); $row=$result-&gt;result(); print_r($row); </code></pre> <p>the result is:</p> <p>Array ( [0] => stdClass Object ( [id] => 18 [user_id] => 19 [post] => [img] => public/users/wall/pic/Messenger14.png [doc] => [video] => [link] => [link_name] => [access_id] => [like] => 0 [time] => 1340792296 )</p> <pre><code>[1] =&gt; stdClass Object ( [id] =&gt; 19 [user_id] =&gt; 19 [post] =&gt; This is my test Documents [img] =&gt; [doc] =&gt; public/users/wall/doc/19/20745322_temp.pdf [video] =&gt; [link] =&gt; [link_name] =&gt; [access_id] =&gt; [like] =&gt; 0 [time] =&gt; 1340792743 ) </code></pre> <p>and i want to avoid those post where id is not 19 or like something. but my last query is not working :(, result is same.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload