Pregunta

I have to modify an existing project, coded in cakephp. I am not much aware of cakephp. I need to access tables in database, without using model. The existing code is as below:

There are two tables 'users' and 'videos'. In one of the controller following code is used to access table.

public $uses = array('User','Video');

$data = $this->User->findByPhone($phone);

My doubt is how does the control identify 'User' as an object pointed to 'users' table ? Please help..

¿Fue útil?

Solución

Allowing a controller to access additional models through the $uses variable.

Model classes represent data and are used in CakePHP applications for data access. They generally represent a database table.

If model class is not defined then it uses AppModel and AppModel extend libray model class that describes :-

model classes represent data and are used in CakePHP applications for data access. They generally represent a database table but can be used to access anything that manipulates data such as files, external web services, or iCal events.

Otros consejos

Cake is all about conventions. You can change models table using useTable

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top