Re: newb database settings save

2012-08-22 Thread DiabloGeto
If u wan to save the configure settings, simply added it as a array with 
proper index for eg. $data['Settings']['val']  and pass that $data var to 
the save function. no need to save the field seperately.


On Wednesday, August 22, 2012 1:16:28 AM UTC+5:30, cyboman wrote:

 I'm trying to add a settings panel in the admin section of a cakephp 
 build. I've been following this:  
 http://bakery.cakephp.org/articles/iamcam/2008/10/26/simply-storing-config-values-in-the-db
 .

  


-- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




newb database settings save

2012-08-21 Thread cyboman
I'm trying to add a settings panel in the admin section of a cakephp build. 
I've been following this:  
http://bakery.cakephp.org/articles/iamcam/2008/10/26/simply-storing-config-values-in-the-db
.

 I have everything working except it seems it will only read data from the 
model but won't save it to the DB. I'll warn I'm a bit new to cakephp so be 
prepared:

Here is the controller action which is on my main_controller:
 function admin_set_val($val = null) {

//Configure::write('MyApp.val',$val); 
$this-Setting-id = 1;
$this-Setting-saveField('val', $val);
 //$this-Setting-writecfg();
//*$this-Setting-read(null, 1);
$this-Setting-set('val', 'newvalue');
$this-Setting-save();*/
 //$this-Setting-saveField('val', 'asdfsdfsd');
 //$data = array('id' = 1, 'val' = 'winter');
// This will update Recipe with id 10
//$this-Setting-save($data);
//$myVar = Configure::read('MyApp.val');
 $this-Session-setFlash('val updated to '.$myVar);

}


I've limited posting everything so as not to span. Again, it will read no 
problem with this myVar = Configure::read('MyApp.val');  and the myVar 
passes successively to the flash message, but the DB is not catching any 
error. I find there is no way (you can see all the commenting I have) to 
commit a change to the val field in the settings table/model.  Sigh.

-- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.