Jump to content

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>

 

Link to comment
https://forums.phpfreaks.com/topic/277583-database-table-for-model-was-not-found/
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".

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.