Best way to prepare SQL statements? |
[eluser]europe72[/eluser]
Is there a preferred CI method? $query = $this->db->query('SELECT name, title, email FROM my_table WHERE id = ?');
[eluser]Michael Wales[/eluser]
Using Active Record: Code: $this->db->select('name, title, email'); If on PHP5 you can use method chaining.
[eluser]ELRafael[/eluser]
ooor Code: $this->db->select('*');
[eluser]Sumon[/eluser]
Or this one Code: $this->db->from('member_info'); Code: if(count($Recordsets->result())==0) echo "Sorry no member exists.";
[eluser]Bramme[/eluser]
You really should put your foreach in the else part of your if... What's point of trying to loop when there's nothing to loop? Btw, chances are hot it'll throw an error then.
[eluser]Sumon[/eluser]
This reduce only else(if...else) block. i.e parenthesis. However, it doesn't display error for empty recordset. Anyway, thanks. Finally one more way of view: Code: if(count($Recordsets->result())==0) echo "Sorry no member exists."; |
Welcome Guest, Not a member yet? Register Sign In |