Re: Model methods in AppControlles
FYI, if you wanted to do it the Cake way, you could rewrite that query in one line, as: $data = $this->Config->find(array("name" => $name), "value"); return $data["value"]; --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Model methods in AppControlles
Hi! Yeah...Mike Freedom was right, this work. Thank you Mikee very much. Bye --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Model methods in AppControlles
query() is a method of your Model, and not your Controller. So, you've successfully set up that method and it seems to be working. Just an incorrect call to query. Try something like: function getConfig($name) { $ret = $this->{$this->modelClass}->query("SELECT value FROM config WHERE name='".$name."'"); $wynik = $ret[0]['value']; return $wynik; } It is a little bit dodgy though. What I do for my config values is whenever I need a config value in a particular controller i set the $uses variable to include my ConfigOption model. Then I access the value directly via the correct model using find or read. Does this help? cheers, freedom On 25/08/06, kacperix <[EMAIL PROTECTED]> wrote: > > Hello. > > I have in my app_controller.php file that function: > > function getConfig($name) { > $ret = $this->query("SELECT value FROM config WHERE > name='".$name."'"); > $wynik = $ret[0]['value']; > return $wynik; > } > > > And when I want to access to this function I' got on screen: > > Fatal error: Call to undefined method UsersController::query() in > /home/lovers/ftp/app/app_controller.php on line 53 > > How i do to make this? Please help. > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---