문제

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

도움이 되었습니까?

해결책

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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top