{IT} - 3.7.8.4 $primaryKey

Se il modello è associato ad una tabella, questo attributo contiene il nome della colonna della chiave primaria della tabella. Il valore di default è 'id'.

{EN} - 3.7.8.4 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 {
    var $primaryKey = 'example_id'; // example_id is the field name in the database
}
  1. class Example extends AppModel {
  2. var $primaryKey = 'example_id'; // example_id is the field name in the database
  3. }

Differences

Lines: 1-7Lines: 1-3
-<title>primaryKey</title>
<p>Each table normally has a primary key, &lt;code&gt;id&lt;/code>. 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.</p>
+<title>$primaryKey</title>
<p>Se il modello è associato ad una tabella, questo attributo contiene il nome della colonna della chiave primaria della tabella. Il valore di default è 'id'.</p>
-<p>Example usage:</p> 
-<pre>class Example extends AppModel { 
- var $primaryKey = 'example_id'; // example_id is the field name in the database 
-}</pre>