如何在cakephp中的一个页面中显示来自不同数据库表实体的数据?

Suppose I have a mysql database and I have 3 entities,

  1. TV
  2. Laptop
  3. Accessories

Each entities contains specific information.
I want to print those data into a single ctp page. How can I do it?
I do not want to use foreign_key.

if you display data in table the code might be similler like this:

<table>
    <th>Title</th>
    <th>Title</th>        

        <?php foreach ($array as $temp_variable):?>
    <tr>
        <td><?php  echo $temp_variable['ModelName']['ColumnName']; ?></td>
        <td><?php  echo $temp_variable['ModelName']['ColumnName']; ?></td>
        <?php endforeach;?>
    </tr>
</table>

for one array..similar thing do for rest of the arrays... i hope you understand.

You can use Cake's loadModel function to call in data from any table into your current controller. More info towards the bottom of this page.

$this->loadModel('YourModel');

Then set the variable to make it available in your view:

$this->set('yourModel', $this->YourModel->find('all', $settings);
$this->loadModel('YourOtherModel');
$this->set('yourOtherModel', $this->YourOtherModel->findI('all', $settings);

Having now set two variables from your Model they are available to you in your view.

(Use debug to see all the data which is available i.e. debug($yourModel); You can put this in your controller action and it will output at the top of the page, or anywhere in your view file)