views:

104

answers:

1

Hi all,

I am using cakephp 1.26 to create a simple message board in my localhost.

When I tried to link two tables together, I got this error:

Error:  Database table posts for model post was not found.

Here are the table structures of the two tables:

Table 'post' has these fields { PostID, Topic, Content}

and table 'reply' has these fields {ReplyID, PostID, CreationDate}

Here is the code of Model site1.php:

<?php
class Site1 extends AppModel {   
    var $name = 'Site1';
    var $useTable = 'post';
    var $primaryKey = 'PostID';
    var $hasMany =  'Reply';
}
?>

and here is the code of Model reply.php:

<?php
class Reply extends AppModel {       
    var $name = 'Reply';
    var $useTable = 'reply';
    var $primaryKey = 'ReplyID';
    var $belongsTo ='post';    
}
?>

Could you help me solve the problem please?

+2  A: 

I think your $belongsTo statement should point to your Site1 model (at least you don't mention anything about a Post model).

Btw: if you have control over the database schema I strongly recommend to follow the naming conventions of CakePHP.

dhofstet