neginf Posted May 3, 2013 Share Posted May 3, 2013 Trying to make a hello world program in the MVC way. The code for what I'm trying is below. There is no data yet, trying to get this to work. I get warnings related to mysql and an error saying "Database table trys2 for model Try2 was not found." 1. Does a model have to have a table associated with it ? 2. How can I make this program work ? This is c:\inetpub\wwwroot\cakephp\app\models\try2.php< ?phpclass try2 extends AppModel{}?>This is c:\inetpub\wwwroot\cakephp\app\controllers\try2s_controller.php< ?phpclass Try2sController extends AppController{ function try2s() { $test='hello world'; $this->set('test',$test); }}?>This is c:\inetpub\wwwroot\cakephp\app\views\try2s\try2s.ctp< pre> <?php print_r($test)?>< /pre> Quote Link to comment https://forums.phpfreaks.com/topic/277583-database-table-for-model-was-not-found/ Share on other sites More sharing options...
neginf Posted May 3, 2013 Author Share Posted May 3, 2013 Never mind. Quote Link to comment https://forums.phpfreaks.com/topic/277583-database-table-for-model-was-not-found/#findComment-1427955 Share on other sites More sharing options...
jazzman1 Posted May 3, 2013 Share Posted May 3, 2013 Don't double post, please! The name of the model class has to have the same name as database table. The database table name needs to be in a plural form. The plural form of try that I know is a "tries" not a "trys". Quote Link to comment https://forums.phpfreaks.com/topic/277583-database-table-for-model-was-not-found/#findComment-1427973 Share on other sites More sharing options...
neginf Posted May 3, 2013 Author Share Posted May 3, 2013 There is no data yet. Try3 works with no model-just a controller and view. Still not able to get it to work without changing router.php. Is it ok to put a url question on another post here ? Quote Link to comment https://forums.phpfreaks.com/topic/277583-database-table-for-model-was-not-found/#findComment-1427990 Share on other sites More sharing options...
jazzman1 Posted May 3, 2013 Share Posted May 3, 2013 Try to change: class try2 extends AppModel { } // to class Try2 extends AppModel { } Quote Link to comment https://forums.phpfreaks.com/topic/277583-database-table-for-model-was-not-found/#findComment-1428023 Share on other sites More sharing options...
neginf Posted May 3, 2013 Author Share Posted May 3, 2013 After try3 worked, tried try2 with $uses=null; before the function in the controller. That made it work. Made the change to the capitalization in the model you suggested. Saw article saying file and directory naming is different in 1.3.2 and 2.0 and on. Thank you for helping. Quote Link to comment https://forums.phpfreaks.com/topic/277583-database-table-for-model-was-not-found/#findComment-1428034 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.