Re: $primaryKey not working

2010-12-13 Thread Rishi
Hi All, Thanks. It worked. Even though I have overriden $primaryKey with "CAT_CODE_ID". Still have to use "findByCatCodeid" for querying the database. As explained by Tilen, it the behavior of the cake. On Dec 12, 8:28 am, vinit sahasrabudhe wrote: > Hi, > >       As you have given the name of

Re: $primaryKey not working

2010-12-12 Thread vinit sahasrabudhe
Hi, As you have given the name of primary key in DB as 'CODE_CAT_ID' , the find function you have written is wrong. Correct it and write it as findByCODECATID($id); On Sun, Dec 12, 2010 at 2:19 AM, Rishi wrote: > hi group, > > I have the following model > > //file model name: code_cat

Re: $primaryKey not working

2010-12-11 Thread Tilen Majerle
yes, it does, but magic methods findByFieldName is that the method search exacly for 'Fieldname' so in this case 'Id' is not recognized, that this is not primary key, it will work (it should) is u do this is in model $this->Model->id = 'valuefromyourprimarykey'; //even if ur primary_key is not id

Re: $primaryKey not working

2010-12-11 Thread Rishi
Thanks. I am new, so I have look what exactly "conditions" do. But, according to documentation, declaring $primaryKey must override the 'id' field. Please correct me if I am wrong. On Dec 11, 4:26 pm, Jeremy Burns | Class Outfit wrote: > Rather than do findById try find (...'conditions' => > ar

Re: $primaryKey not working

2010-12-11 Thread Jeremy Burns | Class Outfit
Rather than do findById try find (...'conditions' => array('CodeCategory.CodeCatId' => $id)... You might need t experiment with different iterations of the field name but I think that's what you need to do. findById will look for a field called id, just as findByTractor will search for a field

Re: $primaryKey not working

2010-12-11 Thread Rishi
No I dont have a ''ID ' in the database. This is the strcture of my table CREATE TABLE `cvmdl`.`code_categories` ( `CODE_CAT_ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `CODE_CAT` varchar(45) NOT NULL, `CODE_DESC` varchar(225) DEFAULT NULL, PRIMARY KEY (`CODE_CAT_ID`) USING BTREE ) ENGI

Re: $primaryKey not working

2010-12-11 Thread Tilen Majerle
ofc...have u 'id' field in table in database?...if no, this is problem :D -- Tilen Majerle http://majerle.eu 2010/12/11 Rishi > hi group, > > I have the following model > > //file model name: code_category.php > > class CodeCategory extends AppModel { > >var $name = 'CodeCategory'; >

$primaryKey not working

2010-12-11 Thread Rishi
hi group, I have the following model //file model name: code_category.php when I try to find a row using $this->CodeCategory->findById($id); I have the following error . SQL Error: 1054: Unknown column 'CodeCategory.id' in 'where clause' Can someone please help me. Check out the new CakePH