In my sample database table, I have a record with post id 999.
I got a few lines of code to retrieve the record of post id 999:
function viewing($sid){
$this->Testing->post_id=$sid;
$this->set('posts', $this->Testing->read());
}
But no record can be record retrieved from the post with id 999 when I altered the code:
function viewing($sid){
$sid=999;
$this->Testing->post_id=$sid;
$this->set('posts', $this->Testing->read());
}
Could you tell help me please?
I think you messing the terms and functions. First you set id of the Site1 model. Then you trying to read record from the Testing model and setting post_id in the record. The proper code should look like:
Alternatively and more short it will be:
But assuming that you want to get posts probably the actual code should look like:
Or something similar. I think first you should take a look on the CakePHP Cookbook and on the CakePHP API