Sunday, July 24, 2011

legacy database, not able to set my own primary key for a view

First day checking out cake, but can't get what seems like the
simplest of things to work.

My old database table named 'sites' has a primary key of 'SiteID'. I
read that in order to tell cake to use that instead of 'id', I should
use this in the model file.

var $primaryKey = 'SiteID';

In my controller i have:

function view($id)
{
$this->set('data', $this->Site->read());
}

I get error: SQL Error: 1054: Unknown column 'Site.id' in 'where
clause'

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: