CodeIgniter Forums
Question about models - 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: Question about models (/showthread.php?tid=18994)



Question about models - El Forum - 05-24-2009

[eluser]darren884[/eluser]
Whats the table format? I could not find it in the user guide... say for instance if I had a table named online_games what would the model name be? Thanks...


Question about models - El Forum - 05-24-2009

[eluser]Thorpe Obazee[/eluser]
The model names aren't associated with the table's names. You can name it anything as long as it follows the guidelines.

http://ellislab.com/codeigniter/user-guide/general/models.html


Question about models - El Forum - 05-24-2009

[eluser]darren884[/eluser]
So how does it know the table name?


Question about models - El Forum - 05-24-2009

[eluser]Thorpe Obazee[/eluser]
They don't.
Code:
$query = $this->db->get($table_name);
return ($query->num_rows() > 0) ? $query->result() : FALSE;

although there are options like storing the table name in a property.


Question about models - El Forum - 05-25-2009

[eluser]Dam1an[/eluser]
Although you can call your models anything you want, I call mine the singular of the table (in most cases)
So if I have a users table, the primary model for that table would be user (well, user_model.php, I add the suffix to avoid collisions)