Cakephp Classroom image

deepa
 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81|Last
Lessons:-Models

primaryKey
Each table normally has a primary key, id. You may change which field name the model uses as its primary
key. This is common when setting CakePHP to use an existing database table.
Example usage:
class Example extends AppModel {
public $primaryKey = ’example_id’; // example_id is the field name in the database
}
displayField
The displayField attribute specifies which database field should be used as a label for the record. The
label is used in scaffolding and in find(’list’) calls. The model will use name or title, by default.
For example, to use the username field:
class User extends AppModel {
public $displayField = ’username’;
}
Multiple field names cannot be combined into a single display field. For example, you cannot specify,
array(’first_name’, ’last_name’) as the display field. Instead create a virtual field with the
Model attribute virtualFields
recursive
The recursive property defines how deep CakePHP should go to fetch associated model data via find(),
findAll() and read() methods.
Imagine your application features Groups which belong to a domain and have many Users which in turn
have many Articles. You can set $recursive to different values based on the amount of data you want back
from a $this->Group->find() call:
• -1 Cake fetches Group data only, no joins.
• 0 Cake fetches Group data and its domain
• 1 Cake fetches a Group, its domain and its associated Users
• 2 Cake fetches a Group, its domain, its associated Users, and the Users’ associated Articles
Set it no higher than you need. Having CakePHP fetch data you aren’t going to use slows your app unnecessarily.
Also note that the default recursive level is 1.
Note: If you want to combine $recursive with the fields functionality, you will have to add the columns
containing the required foreign keys to the fields array manually. In the example above, this could mean
adding domain_id.

 
 
 

deepa

Skills    Cakephp

Qualifications :-
Location :-,,,
Description:-
Explore
 

  Students (0)