title: Ignore a condition if value is null MYSQL/Codeigniter
body: <p>I'm Using MYSQL/ Codeigniter. How can  MySQL query ignore a condition if the passed value is empty , like this example : </p>
  
  <pre><code>function get_category($category_id = 0){
  
   return $this-&gt;db-&gt;query("SELECT * FROM {$this-&gt;table} c
                      INNER JOIN db_category_event ce 
                      ON ce.category_id = c.category_id
                      INNER JOIN db_event_type e
                      ON e.event_id = ce.event_id
                       WHERE c.category_id = {$category_id}
                      WHERE c.visible = 1 AND e.visible = 1")
              -&gt;result();
    }
  </code></pre>