Jump to content

Archived

This topic is now archived and is closed to further replies.

neginf

database table for model was not found

Recommended Posts

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

< ?php
class try2 extends AppModel
{
}
?>

This is c:\inetpub\wwwroot\cakephp\app\controllers\try2s_controller.php

< ?php
class 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>

 

Share this post


Link to post
Share on other sites

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".

Share this post


Link to post
Share on other sites

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 ?

Share this post


Link to post
Share on other sites

Try to change:

class try2 extends AppModel {

 } 

// to

class Try2 extends AppModel { 

} 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.