Dear Michael Rocker,
Please see my answer for your questions1. A model cannot have multiple table, but the functionality is satisfied using puseudo-relationship of tables & associations
"A model is generally an access point to the database, and more specifically, to a certain table in the database.
By default, each model uses the table who's name is plural of its own, i.e. a 'User' model uses the 'users' table."
But some tweaks like :
class DummyModel extends Model
{
var $useTable = false;
public function ReadData()
{
// select table
if($a == 1)
$this->setSource('tableName1');
else if($a == 2)
$this->setSource('tableName2');
// ...
else if($a == N)
$this->setSource('tableNameN');
// now perform operations with selected table
return $this->find('all');
}
}
may work .
2 . A controller may have multiple models like
// add this in your controller
var $uses = array('Model2','Model3');
3 . Do you guys have any resources on designing databases so I can then reflect that onto CakePHP?
please check this URLs : http://stackoverflow.com/questions/1530350/database-tools-for-cakephp
http://bakery.cakephp.org/articles/Frank/2008/07/29/database_design_and_cakephp
4 . are there any resources or more information on the model associations?
Please Refer Manual of CakePHP ...
On Tue, Aug 27, 2013 at 10:58 PM, Michael Roker <mroker@gmail.com> wrote:
Hi folks, this is my new post. I am new to CakePHP, and to be honest I love it. However, I am definitely confused when it comes to the models/tables and associations. I am now working on a small project which is an online exam application. I've read the models section , in particular the models assocation but still very confused. I have some questions.--For my 'objects' I have Users,Questions,Tests,TestScores. I am confused firstly that I have a UsersController, and a QuestionsController and not sure if I can have multiple models per controller. If this is true, then I can only have one table per Model? Do you guys have any resources on designing databases so I can then reflect that onto CakePHP? Lastly, are there any resources or more information on the model associations?I hope I didn't violate any policies being a new user and all.Thanks!
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment