I am getting an error in my view:
Warning (512): SQL Error: 1054: Unknown column 'Model.id' in 'where clause' [CORE\cake\libs\model\datasources\dbo_source.php, line 525] $sql = "SELECT
Model
.model_id
,Model
.pic_location
,Model
.model_name
FROMmodels
ASModel
WHEREModel
.id
= '20' LIMIT 1" $error = "1054: Unknown column 'Model.id' in 'where clause'" $out = null
My model is unfortunately named "Model", due to the legacy database I am working with. I have used debug and determined that it is using primaryKey of 'id' (as also displayed in the SQL above), despite my model code (see below) explicitly setting the primaryKey to 'model_id'.
The database table is models with a primary key of model_id, so I can only assume the system is using an autoModel.
My model code is 'model.php':
<?php class Model extends AppModel {
var $name = 'Model';
var $primaryKey = 'model_id';
//The Associations below have been created with all possible keys, those that are not needed can be removed
var $hasMany = array(
'Pic' => array(
'className' => 'Pic',
'foreignKey' => 'model_name',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);}?>
I originally created the by hand, and when I hit this error, I baked it... with identical results (except I didn't include the empty fields in the hasMany relationship).
I have turned application level caching off temporarily, and cleared the cache, but nothing helps. How can I make it use my model code?