Re: Cake 2 - Model name
Thanks for the help =) El martes, 10 de julio de 2012 15:25:02 UTC-5, cricket escribió: No underscore in model names. class SiegjalFuentes extends AppModel Also, you no longer need the $name var (was for PHP 4.x). On Tue, Jul 10, 2012 at 2:58 PM, MrMariscal benjamin.maris...@gmail.com wrote: I have a problem with naming a model my database table is named: siegjal_fuentes so when I use in my controller the: $this-loadModel('SiegjalFuente'); it works perfectly normal, I can even insert new records, I'm trying to define a model so I can give specif rules for database insertions, but I cannot get the right name of the file so cake recognizes it, I defined the model: ?php class Siegjal_Fuentes extends AppModel { public $name = 'Siegjal_Fuentes'; public $primaryKey = 'idejemplo'; } ? Here it should chamge the primary key field and must give me an error as long as there is not idejemplo field in the table, but it works so I guess it is inferring the model and it's not taking mine. Any suggetions? -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Cake 2 - Model name
I have a problem with naming a model my database table is named: siegjal_fuenteshttp://192.168.251.6/phpmyadmin/sql.php?db=sieggob_siegjaltable=siegjal_fuentestoken=a8f1dcbd7decf8348a4389455f5cb006 so when I use in my controller the: $this-loadModel('SiegjalFuente'); it works perfectly normal, I can even insert new records, I'm trying to define a model so I can give specif rules for database insertions, but I cannot get the right name of the file so cake recognizes it, I defined the model: ?php class Siegjal_Fuentes extends AppModel { public $name = 'Siegjal_Fuentes'; public $primaryKey = 'idejemplo'; } ? Here it should chamge the primary key field and must give me an error as long as there is not idejemplo field in the table, but it works so I guess it is inferring the model and it's not taking mine. Any suggetions? -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Override primarikey Undefined index: id Error
I have a model definition where I override the primaryKey as follows: ?php class Amg_Predios extends AppModel { var $name = 'Amg_Predios'; var $primaryKey = 'gid'; } ? but when in my controller I use the: $this-AmgPredio-save( $this-data ); I get this error: Notice (8): Undefined index: id [CORE/cake/libs/model/model.php, line 1329] And after it, a message who says I'm trying to insert a duplicate record, because the primarykey already exists. I have flushed the cache and it is still not working. Any clues about what I'm doing wrong? Thanks in advance. -- View this message in context: http://cakephp.1045679.n5.nabble.com/Override-primarikey-Undefined-index-id-Error-tp4472931p4472931.html Sent from the CakePHP mailing list archive at Nabble.com. -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Override primarikey Undefined index: id Error
I have a model definition where I override the primaryKey as follows: ?php class Amg_Predios extends AppModel { var $name = 'Amg_Predios'; var $primaryKey = 'gid'; } ? but when in my controller I use the: $this-AmgPredio-save( $this-data ); I get this error: Notice (8): Undefined index: id [CORE/cake/libs/model/ model.php, line 1329] And after it, a message who says I'm trying to insert a duplicate record, because the primarykey already exists. I have flushed the cache and it is still not working. Any clues about what I'm doing wrong? Thanks in advance. -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Changing Primary Key in Model is not being recognized
This is not an elegant solution, but after debuging some cakes code, before saving or doing somenthing I use code like this: $this-Model-primaryKey = 'myIdField'; Then magically it worked out fine. Hope it helps. On 15 abr, 09:39, Deftly-D deftl...@gmail.com wrote: I am trying tooverridethePrimaryKeyused to join tables, but the query that CakePHP is generating keeps using 'id' as the primary key. This is in CakePHP version 1.3.7 Please suggest any changes that don't involve changing the database structure. The models that I am trying to join are as follows: ?php class VUser extends AppModel { var $name = 'VUser'; var $useTable = 'v_users'; var $primaryKey= 'userid'; var $hasMany = array( 'InterviewerID' = array( 'className' = 'Sitelog', 'foreignKey' = 'interviewerid' ), 'ObserverID' = array( 'className' = 'Sitelog', 'foreignKey' = 'observerid' ), 'CounterID' = array( 'className' = 'Sitelog', 'foreignKey' = 'counterid' ) ); var $validate = array( 'orgid' = array('rule' = 'notEmpty'), 'username' = array('rule' = 'notEmpty'), 'phonenumber' = array('rule' = 'notEmpty'), 'mailaddress' = array('rule' = 'notEmpty'), 'loginid' = array('rule' = 'notEmpty'), 'roleid' = array('rule' = 'notEmpty'), 'terminatedate' = array('rule' = 'notEmpty'), 'sid' = array('rule' = 'notEmpty'), );} ? ?php class Sitelog extends AppModel { var $name = 'Sitelog'; var $useTable = 'site_log'; var $primaryKey= 'sitelogid'; var $belongsTo = array( 'interviewer' = array( 'className' = 'VUser', 'foreignKey' = 'interviewerid' ), 'observer' = array( 'className' = 'VUser', 'foreignKey' = 'observerid' ), 'counter' = array( 'className' = 'VUser', 'foreignKey' = 'counterid' ) ); var $validate = array( 'sitelogid' = array('rule' = 'notEmpty'), 'psuid' = array('rule' = 'notEmpty'), 'siteid' = array('rule' = 'notEmpty'), 'statusid' = array('rule' = 'notEmpty'), 'sitelogtype' = array('rule' = 'notEmpty'), 'interviewerid' = array('rule' = 'notEmpty'), 'observerid' = array('rule' = 'notEmpty'), 'observerdate' = array('rule' = 'notEmpty'), 'spanishavail' = array('rule' = 'notEmpty'), 'counterid' = array('rule' = 'notEmpty') );} ? -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php