Re: ORM, fetching related rows of corresponding model: undefined index..
Post your model code so we can see if you are doing your associations correctly, or if they are spelled correctly. On Dec 6, 9:50 pm, Tanay <[EMAIL PROTECTED]> wrote: > it seems no relationships are working with my cakephp. > has it got anything to do with my version of php5? > > i have got struck at this for a long time. > help will be very greatly appreciated. > > here is the var_dump of $questions as seen in home.ctp > array(2) { [0]=> array(1) { ["Question"]=> array(5) { ["id"]=> string > (1) "1" ["question"]=> string(22) "Why do you use > CakePHP" ["questioner"]=> string(5) "Ahsan" ["created"]=> string(19) > "2008-02-11 22:19:04" ["modified"]=> string(19) "2008-02-11 > 22:19:04" } } [1]=> array(1) { ["Question"]=> array(5) { ["id"]=> > string(1) "2" ["question"]=> string(25) "Why won't you use > CakePHP" ["questioner"]=> string(5) "Ahsan" ["created"]=> string(19) > "2008-02-11 22:22:06" ["modified"]=> string(19) "2008-02-11 > 22:22:06" } } } > > coresponding queries sql dump is > DESCRIBE `questions` > SELECT `Question`.`id`, `Question`.`question`, > `Question`.`questioner`, `Question`.`created`, `Question`.`modified` > FROM `questions` AS `Question` WHERE 1 = 1 > > On Dec 7, 1:47 am, thatsgreat2345 <[EMAIL PROTECTED]> wrote: > > > I see you are using the Packt Publishing book, ensure that your model > > relations aren't misspelled or anything else it won't load the answers > > and thus won't exist, in the controller do a debug on the find, that > > or in the view do a pr($questions) before the foreach this will > > display the array and see what exactly what is in the array. > > > On Dec 6, 9:40 am, Tanay <[EMAIL PROTECTED]> wrote: > > > > Tanay wrote: > > > > i have two dbs questions , and answers.. > > > > > corresponding models > > > > > questions has many answers > > > > answers belogns to questions > > > > > in questions_controller, i have this home function > > > > function home() { > > > > $this->Question->recursive = 1; > > > > $this->set('questions', $this->Question->find('all')); > > > > } > > > > > in my home.ctp, i tried to show the corresponding answers using the > > > > code below > > > > i took a question from an array of questions using foreach > > > > foreach question, $question['Answer'] is expected to give array of > > > > answers, but it says Undefined index: Answer > > > > THAT LIne is marked in code below > > > > > home.ctp: > > > > > > > > > No Questions yet. Be the first one to > > > > post a Question! > > > > > > > > > > > > > > > > > > > ?> > > > > > > > > link($question['Question']['question'] > > > > .'?', array('action' => 'show', $question['Question']['id']))); ?> > > > > > > > $answer_count = count($question > > > > ['Answer']); // <<-ERROR HERE > > > > if(!$answer_count) > > > > e("(no answers yet)"); > > > > else if($answer_count == 1) > > > > e("(1 answer)"); > > > > else > > > > e("(".$answer_count." answers)"); > > > > ?> > > > > > > > > > > > > > > > > > > > > > the above code is a part of project in book CakePHP application > > > > Development, > > > > the code is same as in book > > > > is it due to some different version of cakephp that author used? > > > > i use latest 1.2 version > > > > . . . . . . > > > Still the same. But now it says > > > The new variable name $question['question']['answer'] is undefined > > > index. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: ORM, fetching related rows of corresponding model: undefined index..
it seems no relationships are working with my cakephp. has it got anything to do with my version of php5? i have got struck at this for a long time. help will be very greatly appreciated. here is the var_dump of $questions as seen in home.ctp array(2) { [0]=> array(1) { ["Question"]=> array(5) { ["id"]=> string (1) "1" ["question"]=> string(22) "Why do you use CakePHP" ["questioner"]=> string(5) "Ahsan" ["created"]=> string(19) "2008-02-11 22:19:04" ["modified"]=> string(19) "2008-02-11 22:19:04" } } [1]=> array(1) { ["Question"]=> array(5) { ["id"]=> string(1) "2" ["question"]=> string(25) "Why won't you use CakePHP" ["questioner"]=> string(5) "Ahsan" ["created"]=> string(19) "2008-02-11 22:22:06" ["modified"]=> string(19) "2008-02-11 22:22:06" } } } coresponding queries sql dump is DESCRIBE `questions` SELECT `Question`.`id`, `Question`.`question`, `Question`.`questioner`, `Question`.`created`, `Question`.`modified` FROM `questions` AS `Question` WHERE 1 = 1 On Dec 7, 1:47 am, thatsgreat2345 <[EMAIL PROTECTED]> wrote: > I see you are using the Packt Publishing book, ensure that your model > relations aren't misspelled or anything else it won't load the answers > and thus won't exist, in the controller do a debug on the find, that > or in the view do a pr($questions) before the foreach this will > display the array and see what exactly what is in the array. > > On Dec 6, 9:40 am, Tanay <[EMAIL PROTECTED]> wrote: > > > Tanay wrote: > > > i have two dbs questions , and answers.. > > > > corresponding models > > > > questions has many answers > > > answers belogns to questions > > > > in questions_controller, i have this home function > > > function home() { > > > $this->Question->recursive = 1; > > > $this->set('questions', $this->Question->find('all')); > > > } > > > > in my home.ctp, i tried to show the corresponding answers using the > > > code below > > > i took a question from an array of questions using foreach > > > foreach question, $question['Answer'] is expected to give array of > > > answers, but it says Undefined index: Answer > > > THAT LIne is marked in code below > > > > home.ctp: > > > > > > > No Questions yet. Be the first one to > > > post a Question! > > > > > > > > > > > > > > ?> > > > > > > link($question['Question']['question'] > > > .'?', array('action' => 'show', $question['Question']['id']))); ?> > > > > > $answer_count = count($question > > > ['Answer']); // <<-ERROR HERE > > > if(!$answer_count) > > > e("(no answers yet)"); > > > else if($answer_count == 1) > > > e("(1 answer)"); > > > else > > > e("(".$answer_count." answers)"); > > > ?> > > > > > > > > > > > > > > > > the above code is a part of project in book CakePHP application > > > Development, > > > the code is same as in book > > > is it due to some different version of cakephp that author used? > > > i use latest 1.2 version > > > . . . . . . > > Still the same. But now it says > > The new variable name $question['question']['answer'] is undefined > > index. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Problem with foreignKey in cake PHP
It's common with a lot of databases. Again, the workaround is to add an ID column. On Sat, Dec 6, 2008 at 12:33 PM, <[EMAIL PROTECTED]> wrote: > But this case is common in MSSQL, and I need use it. -.-! > > 2008/12/5 teknoid <[EMAIL PROTECTED]> >> >> There is no support for composite keys in CakePHP. >> Add an 'id' column to your table. >> >> On Dec 5, 3:34 pm, Sabinas <[EMAIL PROTECTED]> wrote: >> > Hi, I dont speak englis very well but I will try. Mi problem is: >> > >> > I have a table but this table have a primary key with two columns, an >> > example: >> > >> > sucursal folio >> > 1 1 >> > 2 1 >> > 1 2 >> > 2 2 >> > >> > joining two columns we obtain the primary key i don know how to >> > make the relation in the model... somebody help me please. >> > > > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: bug in Containable?
I forgot to mention that this problem exists with the latest nightly (1.2.x.x_06.12.2008) as well. On Sat, Dec 6, 2008 at 11:24 PM, brian <[EMAIL PROTECTED]> wrote: > cake_1.2.0.7692_RC3 > > I think I've found a bug where 2 different elements are called on a > page, each for different controllers, and each method uses a contain > block in find conditions. I've just spent several hours trying to > figure out why Containable was refusing to fetch data from a > particular model, only to realise that it does work once I remove a > previous element() call from the page. > > I have gone through Trac to see if this is already been reported. > Please excuse me if I missed it, as my head is pretty well spinning > from trying to figure this out (and going through Containable line by > line tonight). My guess is this is an unbinding issue, and there are > some reports of that, but I'm really not sure if what I'm looking at > on Trac is the same thing. > > Here's the lowdown: > > class AppModel extends Model { >var $actsAs = array('Containable'); > ... > > class User extends AppModel > { >var $name = 'User'; >var $hasOne = array( >'Admin', >'Professional', >'Organisation' >); >var $hasMany = array( >'Publication', >'Post' >); > ... > > class Post extends AppModel > { >var $name = 'Post'; >var $belongsTo = array('User', 'PostCategory'); > ... > > class PostsController extends AppController { > >/* this method is called from an element > */ >function front_page() >{ >$criteria = array( >'conditions' => array( >'OR' => array( >'Post.embargo IS NULL', >'Post.embargo < NOW()' >) >), >'limit' => 5, >'fields' => array( >'Post.id', >'Post.created', >'Post.user_id', >'Post.comments_enabled', >'Post.title', >'Post.intro', >'Post.body' >), >'contain' => array( >'PostCategory' => array( >'fields' => array('name') >), >'User' => array( >'Admin' => array( // <-- this is the > model that doesn't get > included in the query >'fields' => array( >'first_name', > 'last_name' >) >) >) >) >); >return $this->Post->find('all', $criteria); >} > > > Now, in home.ctp, I have 2 element() calls. One is for the method > above, and the other is to PublicationsController. In that method, the > $criteria is almost the same, except I'm getting > Professional.first_name, etc. instead of Admin (well, and it's > selecting publications, obviously). > > Whichever one comes first on the page works fine. The other one will > get all the data for User, but not for Admin or Professional. If I > switch the second one to come first, it works and the other one fails. > So, I know my associations are all good. > > As I said, I tried to figure out if this was already on Trac but > nothing jumped out at me. I'm just bloody thankful I removed thefirst > element temporarily of I'd never have figured out what's been driving > me freaking crazy for ... crap! 4 hours now. > > > For anyone who understands Containable better than me, does this seem > like something new? > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Well formed XML for RESTful web services ...
No, I don't expect Cake to format the output at all since we are doing MVC. I want to use the debug output without it affecting my HTTP stream. The bug/problem is that if debug > 1, the content type gets flipped to text/html, and the SQL debug gets appended to the XML (after the end of the HTML because it's being output directly from the dbo_source.php If we're truly doing MVC, there should never be debug information going directly to the view, and the debug information should be accessible in the model to the controller so we can decide how to deal with it. Say for instance I have debug set to 1 to catch errors. Now in my controller code, I have to turn off debug for XML, so I don't get any chance to catch those errors, which may or may not need to be dealt with. I know the workaround is to detect that I'm doing XML and set debug to 0, but that doesn't help in development in any way. Formatting the debug data and spitting it into the view like it does is violating the MVC design (while it is nice when you're debugging HTML). On Dec 6, 6:31 pm, James K <[EMAIL PROTECTED]> wrote: > Not sure I understand the problem. Do you expect Cake to format it's > debug information based on the content type? It's debug information - > it's meant for debugging. > > You can type Configure::write('debug', 0) at the top of any action in > order to lower the debug level selectively per action without having > to shut if off for the entire app. > > I have lots of views in a particular application that return XML or > JSON, and of course having debug info at the bottom of that response > will break those requests. Once I confirm the response is returning > correctly formatted XML or JSON, I turn the debugging off for that > action and only turn it back on in that action in the event I need > to debug :P > > Good luck, > James > > On Dec 6, 6:24 pm, Rob <[EMAIL PROTECTED]> wrote: > > > I'll probably get no response or flames telling me to "just set debug > > to 1", but > > > I've set up my VolunteerCake code to be a RESTful web service by using > > the Router::parseExtensions() and Router::mapResources() magic. This > > works fine as long as debug is not greater than 1. > > > When debug is greater than 1 however, the XML that gets returned is > > broken due to problems with the way the SQL debug is spit out. > > > I traced this down to a call In the close() function of > > dbo_source.php, to showLog() which spits out the SQL in an HTML table > > > I call the web service and get the XML as expected. The closing XML is > > followed by the dump of the SQL like: > > > > id="cakeSqlLog_1228604311493b0397a19568_61229664" summary="Cake SQL > > Log" cellspacing="0" border = "0"> > > (default) 36 queries took 127 ms > > > Other web service tools I've worked with operate by giving you access > > to the debug data so you can spit it out as part of the XML if you > > want to, so you end up with something like: > > > non-debug datadebug data > > (usually wrapped in a CDATA) > > > Ideally Cake shouldn't be changing the content-type and spitting out > > HTML after the well-formed document has been created anyway. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
bug in Containable?
cake_1.2.0.7692_RC3 I think I've found a bug where 2 different elements are called on a page, each for different controllers, and each method uses a contain block in find conditions. I've just spent several hours trying to figure out why Containable was refusing to fetch data from a particular model, only to realise that it does work once I remove a previous element() call from the page. I have gone through Trac to see if this is already been reported. Please excuse me if I missed it, as my head is pretty well spinning from trying to figure this out (and going through Containable line by line tonight). My guess is this is an unbinding issue, and there are some reports of that, but I'm really not sure if what I'm looking at on Trac is the same thing. Here's the lowdown: class AppModel extends Model { var $actsAs = array('Containable'); ... class User extends AppModel { var $name = 'User'; var $hasOne = array( 'Admin', 'Professional', 'Organisation' ); var $hasMany = array( 'Publication', 'Post' ); ... class Post extends AppModel { var $name = 'Post'; var $belongsTo = array('User', 'PostCategory'); ... class PostsController extends AppController { /* this method is called from an element */ function front_page() { $criteria = array( 'conditions' => array( 'OR' => array( 'Post.embargo IS NULL', 'Post.embargo < NOW()' ) ), 'limit' => 5, 'fields' => array( 'Post.id', 'Post.created', 'Post.user_id', 'Post.comments_enabled', 'Post.title', 'Post.intro', 'Post.body' ), 'contain' => array( 'PostCategory' => array( 'fields' => array('name') ), 'User' => array( 'Admin' => array( // <-- this is the model that doesn't get included in the query 'fields' => array( 'first_name', 'last_name' ) ) ) ) ); return $this->Post->find('all', $criteria); } Now, in home.ctp, I have 2 element() calls. One is for the method above, and the other is to PublicationsController. In that method, the $criteria is almost the same, except I'm getting Professional.first_name, etc. instead of Admin (well, and it's selecting publications, obviously). Whichever one comes first on the page works fine. The other one will get all the data for User, but not for Admin or Professional. If I switch the second one to come first, it works and the other one fails. So, I know my associations are all good. As I said, I tried to figure out if this was already on Trac but nothing jumped out at me. I'm just bloody thankful I removed thefirst element temporarily of I'd never have figured out what's been driving me freaking crazy for ... crap! 4 hours now. For anyone who understands Containable better than me, does this seem like something new? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: SQL error with Auth Component?
Checkout at the bottom of this http://www.studiocanaria.com/articles/cakephp_auth_component_users_groups_permissions_revisited It seems to work, basically allows everything in the beforeFilter in the app, then in the users_controller you recall parent::beforeFilter () , then set the allow. I'm unsure why you have to use allowedActions only works and after reading the book it seems as if they only use allowedActions when dealing with Auth and ACL. On Dec 6, 6:43 pm, gearvOsh <[EMAIL PROTECTED]> wrote: > It seems this works below, but my previous code does not. > > $this->Auth->allowedActions = array('signup', 'reset', 'verify', > 'forgot'); > > Perhaps something wrong with the > docs?http://book.cakephp.org/view/247/AuthComponent-Methods#allow-382 --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: SQL error with Auth Component?
It seems this works below, but my previous code does not. $this->Auth->allowedActions = array('signup', 'reset', 'verify', 'forgot'); Perhaps something wrong with the docs? http://book.cakephp.org/view/247/AuthComponent-Methods#allow-382 --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Well formed XML for RESTful web services ...
Not sure I understand the problem. Do you expect Cake to format it's debug information based on the content type? It's debug information - it's meant for debugging. You can type Configure::write('debug', 0) at the top of any action in order to lower the debug level selectively per action without having to shut if off for the entire app. I have lots of views in a particular application that return XML or JSON, and of course having debug info at the bottom of that response will break those requests. Once I confirm the response is returning correctly formatted XML or JSON, I turn the debugging off for that action and only turn it back on in that action in the event I need to debug :P Good luck, James On Dec 6, 6:24 pm, Rob <[EMAIL PROTECTED]> wrote: > I'll probably get no response or flames telling me to "just set debug > to 1", but > > I've set up my VolunteerCake code to be a RESTful web service by using > the Router::parseExtensions() and Router::mapResources() magic. This > works fine as long as debug is not greater than 1. > > When debug is greater than 1 however, the XML that gets returned is > broken due to problems with the way the SQL debug is spit out. > > I traced this down to a call In the close() function of > dbo_source.php, to showLog() which spits out the SQL in an HTML table > > I call the web service and get the XML as expected. The closing XML is > followed by the dump of the SQL like: > > id="cakeSqlLog_1228604311493b0397a19568_61229664" summary="Cake SQL > Log" cellspacing="0" border = "0"> > (default) 36 queries took 127 ms > > Other web service tools I've worked with operate by giving you access > to the debug data so you can spit it out as part of the XML if you > want to, so you end up with something like: > > non-debug datadebug data > (usually wrapped in a CDATA) > > Ideally Cake shouldn't be changing the content-type and spitting out > HTML after the well-formed document has been created anyway. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Custom Helper not Working
Missing php open/close tags? On Dec 6, 1:00 pm, Sapslabs <[EMAIL PROTECTED]> wrote: > I am creating a custom helper like this > > class ElapsedHelper extends AppHelper { > function test(){ > return $this->output('test'); > } > > } > > Which is save under views/helpers/elapsed.php > > I am including this on my controller using > > var $helpers = array('Elapsed'); > > but when I try it I get this error: > > class ElapsedHelper extends AppHelper { function test(){ return > $this->output('test');} } > > Missing Helper Class > > Error: The helper class ElapsedHelper can not be found or does not > exist. > > Error: Create the class below in file: www/views/helpers/elapsed.php > > class ElapsedHelper extends AppHelper { > > } > > ?> > > Any idea on what I am doing wrong? > > Thanks --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Data Validation error message fails on $this->redirect
I've certainly considered the option of submitting to the same action and on success redirecting. My problem is that the page the user modifies data on also serves as an "index page" for certain functions: Skipping the post, activating the post and deleting the post. As I want to build out entirely different actions in the controller to handle each of those functions, when the user submits the data in the form, I need to process the data through an external action. That being said, does that mean that what I'm trying to accomplish cannot work? I would think that it should be possible, and in certain circumstances necessary to people outside of just me. All help is appreciated. Thanks! On Dec 6, 10:26 am, Smelly_Eddie <[EMAIL PROTECTED]> wrote: > Why are you using two actions to begin with? > > It seems like your inviting issues using such a manner. > > Have you considered sending all the data to the same action, and on > successful validation redirect to the next action? Seems like a > cleaner way to go about things. > > On Dec 6, 1:20 am, Renesistemic <[EMAIL PROTECTED]> wrote: > > > I've had no luck locating any resource online for resolving my issue > > (which I feel is fairly easy), and thought I'd post it on here to see > > if anyone has input. > > > I'm trying to use the built-in data validation for submitting a form. > > The originating action, say, "manage_posts", displays the form to the > > user and lets them modify data for that post. When they submit, it > > sends the data to "activate_post". > > > In the "activate_post" action, I call the if($this->Datavalue->set > > ($this->data) && $this->Datavalue->validates) function to test the > > data, and if that test fails I redirect back to "manage_posts"... > > > The actual validation process seems to be functioning. It accepts > > valid data and redirects on invalid data. However, when it redirects > > to the previous action, it doesn't actually display the error message > > for that HTML element > > > In the original form, I am in fact calling $this->Form->error > > ($datavalue, $error_msg) after generating the HTML element with $this- > > > >Form->input(). > > > Likewise, I have other actions throughout my application that use data > > validation and work correctly. However, they don't redirect to another > > action on failing validation. An example would be an action to > > "add_posts"... When the user submits data, it submits to itself, > > tests, and upon validation renders the same action/view. > > > It seems that I'm only experiencing these problems when I redirect on > > the failure of a data validation. Any thoughts? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Ordering search results by best match
My app has the following: Genus hasMany Species Species hasMany CommonName and the corresponding belongsTo relationships as well. Each of these models has a name field, and Genus and Species have several other fields. Say for example I have a Species Acer rubrum. This Species belongsTo Genus Acer and has a CommonName Red Maple. I want my users to be able to search the database for "Red Maple" and get as a result Species Acer rubrum (with the CommonName Red Maple highlighted to show that's what it matched. I can do this already. Yay. However if I have another Species with CommonName Bored Maple, I want to display this result too, but lower in the list than Red Maple. Since Bored comes before Red alphabetically I can't just order by CommonName.name to get the result I want. So what I know I could do is a series of finds: 1) Find exact match: CommonName.name => $searchStr 2) Find starting match: CommonName.name LIKE => $searchStr . '%' 3) Find internal match: CommonName.name LIKE => '%' . $searchStr . '%' And then merge them into my results array. However, this seems very inefficient. Is there a way I can use cake's find() function to do this all in one go while ordering them in order of best match? I have thought about this for quite some time and done some research but I can't seem to find any clever solution. I might be able to do a custom query with a bunch of SELECTs as above combined with UNION or something, but this would be a pretty complex query and not really much more efficient than what I already know how to do. Thanks in advance any genius here who has a solution! -Clay --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Problem with foreignKey in cake PHP
But this case is common in MSSQL, and I need use it. -.-! 2008/12/5 teknoid <[EMAIL PROTECTED]> > > There is no support for composite keys in CakePHP. > Add an 'id' column to your table. > > On Dec 5, 3:34 pm, Sabinas <[EMAIL PROTECTED]> wrote: > > Hi, I dont speak englis very well but I will try. Mi problem is: > > > > I have a table but this table have a primary key with two columns, an > > example: > > > > sucursal folio > > 1 1 > > 2 1 > > 1 2 > > 2 2 > > > > joining two columns we obtain the primary key i don know how to > > make the relation in the model... somebody help me please. > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
simple write to database
I have a simple example below. I just want a form that saves stuff to the database. Its never getting to log "test2" I guess the data is not in the right format but how am I supposed to do it? I've already spent a considerable amount of time debugging this and other problems, please help! thanks. CREATE TABLE users ( id int NOT NULL AUTO_INCREMENT, lastName varchar(255), firstName varchar(255), picture_id int, about_me varchar(255), PRIMARY KEY (id) ); here's the model: class User extends AppModel { // Its always good practice to include this variable. var $name = 'User'; // This is used for validation, see Chapter "Data Validation". var $validate = array(); } controller: class NewuserController extends AppController { var $name = 'Newuser'; var $uses = Array('User'); function index() { } function add() { $this->log('in newuser_controller add()'); if(!empty($this->data)) { $this->log('test1'); //If the form data can be validated and saved... if($this->User->save($this->data['User']['about_me'])) { $this->log('test2'); //Set a session flash message and redirect. $this->Session->setFlash("User Saved!"); $this->redirect('add'); } } } } View: ... create('User'); ?> Describe yourself textarea('User/about_me')?> submit('Add'); ?> end('Add User'); ?> --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Custom Helper not Working
I am creating a custom helper like this class ElapsedHelper extends AppHelper { function test(){ return $this->output('test'); } } Which is save under views/helpers/elapsed.php I am including this on my controller using var $helpers = array('Elapsed'); but when I try it I get this error: class ElapsedHelper extends AppHelper { function test(){ return $this->output('test');} } Missing Helper Class Error: The helper class ElapsedHelper can not be found or does not exist. Error: Create the class below in file: www/views/helpers/elapsed.php Any idea on what I am doing wrong? Thanks --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Custom Helper not Working
I am trying to add a helper to my app like this: class ElapsedHelper extends AppHelper { function test() return $this->output('test'); } } this helper is saved as views/helpers/elapsed.php and included on my controller with var $helpers = array('Elapsed'); The problem is that my page is displaying the code for the helper and saying that it can't find the file and the helper and that I should create it and save it. Any ideas? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
SQL error with Auth Component?
So Im working with the auth component, heres my AppController. class AppController extends Controller { var $components = array('Auth'); function beforeFilter() { // Authenticate if (isset($this->Auth)) { Security::setHash('md5'); $this->Auth->userScope = array('User.status' => 'active'); $this->Auth->loginAction = '/auth/login/'; $this->Auth->loginRedirect = '/dashboard/'; $this->Auth->logoutRedirect = '/'; } } } And my beforeFilter in my controller: function beforeFilter() { // No authorize $this->Auth->allow('signup', 'reset', 'verify', 'forgot'); } That should all work and the signup... etc pages should not require authorization... but I keep getting these SQL errors. It looks like it thinks auth is a model. Warning (512): SQL Error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'allow' at line 1 [CORE\cake\libs\model \datasources\dbo_source.php, line 521] Query: allow --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
admin routes prefix routing paginator problems..
Hello, Im trying to do an app with 3 areas admin routes which requires login /admin/ /nurse/ /practice/ routes.php: Router::connect("/admin/:controller/:action/*", array ("prefix"=>"admin", "admin"=>true)); Router::connect("/nurse/:controller/:action/*", array ("prefix"=>"nurse", "nurse"=>true)); Router::connect("/practice/:controller/:action/*", array ("prefix"=>"practice", "practice"=>true)); all seems working, except pagination, paginator links look like: http://www.domain.com/calls/nurse_index/page:2 should be : http://www.domain.com/nurse/calls/index/page:2 tried to add more more routes like Router::connect("/admin/:controller/:action/*", array ("prefix"=>"admin")); Router::connect("/nurse/:controller/:action/*", array ("prefix"=>"nurse")); Router::connect("/practice/:controller/:action/*", array ("prefix"=>"practice")); but then it nurse index shows url as http://www.domain.com/admin/calls/index/page:2 , so somehow are overlapping.. Is there a way to construct the url correctly ? maybe from a controller ? Thank you, Andras --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Creating and Using True Self-referential Joins
I'm working on an application where people can sign up to use a service and can refer others into the network. I'm wanting to use a self-referential join table where I have one table with of course an ID and an associate id where that will join to a parent record within that table. So if Jane referred in Tom then then Tom's associate id field would have Jane's id # in it. The I have several questions: 1) How do you set up a table that uses self-referential joins within CakePHP and using cake migrations. 2) How would you reference those associations within the model? 3) How would you save to the database using a self-referential join. Most of the posts on the user group have people using two different tables and to me that's not a self-referential join. I'll do some more searching. If CakePHP is a close port from Ruby on Rails then I guess I could look at some Rails examples to see how they are doing. I think they have acts_as_tree. Thanks, Tony --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Well formed XML for RESTful web services ...
I'll probably get no response or flames telling me to "just set debug to 1", but I've set up my VolunteerCake code to be a RESTful web service by using the Router::parseExtensions() and Router::mapResources() magic. This works fine as long as debug is not greater than 1. When debug is greater than 1 however, the XML that gets returned is broken due to problems with the way the SQL debug is spit out. I traced this down to a call In the close() function of dbo_source.php, to showLog() which spits out the SQL in an HTML table I call the web service and get the XML as expected. The closing XML is followed by the dump of the SQL like: (default) 36 queries took 127 ms Other web service tools I've worked with operate by giving you access to the debug data so you can spit it out as part of the XML if you want to, so you end up with something like: non-debug datadebug data (usually wrapped in a CDATA) Ideally Cake shouldn't be changing the content-type and spitting out HTML after the well-formed document has been created anyway. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Well formed XML for RESTful web services ...
I'll probably get no response or flames telling me to "just set debug to 1", but I've set up my VolunteerCake code to be a RESTful web service by using the Router::parseExtensions() and Router::mapResources() magic. This works fine as long as debug is not greater than 1. When debug is greater than 1 however, the XML that gets returned is broken due to problems with the way the SQL debug is spit out. I traced this down to a call In the close() function of dbo_source.php, to showLog() which spits out the SQL in an HTML table I call the web service and get the XML as expected. The closing XML is followed by the dump of the SQL like: (default) 36 queries took 127 ms Other web service tools I've worked with operate by giving you access to the debug data so you can spit it out as part of the XML if you want to, so you end up with something like: non-debug datadebug data (usually wrapped in a CDATA) Ideally Cake shouldn't be changing the content-type and spitting out HTML after the well-formed document has been created anyway. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Custom queries/sql in models/behaviors
http://cakebaker.42dh.com/2008/05/18/new-core-behavior-containable/ On Dec 7, 8:27 am, gearvOsh <[EMAIL PROTECTED]> wrote: > So I have this method within the model. The same array is returned > from above but I get a mysql error for the contain. > > SQL Error: 1064: You have an error in your SQL syntax; check the > manual that corresponds to your MySQL server version for the right > syntax to use near 'contain' at line 1 [CORE\cake\libs\model > \datasources\dbo_source.php, line 521] > > function test() { > $this->actsAs = array('Container'); > > $this->bindModel(array( > 'hasMany' => array( > 'TeamMember' => array( > 'className' => > 'TeamMember', > 'foreignKey' => 'team_id', > 'conditions' => > array('TeamMember.status' => 'approved'), > 'order' => > 'TeamMember.joinDate ASC', > 'dependent' => true, > //'finderQuery' => 'SELECT > User.username, User.handle, > User.avatar FROM user AS User, teamMember as TeamMember WHERE User.id > = TeamMember.user_id LIMIT 1' > ), > 'TeamGame' => array( > 'className' => 'TeamGame', > 'foreignKey' => 'team_id' > ) > ) > )); > > $this->contain(array('TeamMember' => array('User'), > 'TeamGame')); > > return $this->find('first'); > } > > On Dec 6, 3:35 am, Adam Royle <[EMAIL PROTECTED]> wrote: > > > Add: > > > var $actsAs = array('Containable'); > > > to your Team model. > > > Then add this before your find() call: > > > $this->Team->contain('TeamMember' => array('User'), 'TeamGame'); > > > Cheers, > > Adam > > > On Dec 6, 12:51 pm, gearvOsh <[EMAIL PROTECTED]> wrote: > > > > Ok thats weird, I dont have foreign keys really setup but it still > > > works. Im using $hasMany for members and games. But within the > > > TeamMember and TeamGame arrays, is there way to get more information > > > returned? I would need the members name, avatar, etc. > > > > Array > > > ( > > > [0] => Array > > > ( > > > [Team] => Array > > > ( > > > [id] => 1 > > > [status] => approved > > > [name] => chair > > > [tag] => _h_ > > > [urlName] => > > > [website] => > > > [irc] => > > > [about] => > > > [servers] => > > > [logo] => > > > [createDate] => 0 > > > [state_id] => 0 > > > [country_id] => 0 > > > [created] => > > > [modified] => > > > ) > > > > [TeamMember] => Array > > > ( > > > [0] => Array > > > ( > > > [id] => 4 > > > [team_id] => 1 > > > [user_id] => 32 > > > [role] => captain > > > [status] => approved > > > [joinDate] => 1211498560 > > > ) > > > ) > > > > [TeamGame] => Array > > > ( > > > [0] => Array > > > ( > > > [team_id] => 1 > > > [gameSystem_id] => 3 > > > ) > > > ) > > > ) > > > ) > > > > On Dec 5, 4:08 pm, gearvOsh <[EMAIL PROTECTED]> wrote: > > > > > Because I cant use foreign keys so all of those features are useless > > > > to me. I also cant use linked models. > > > > > On Dec 5, 1:12 pm, teknoid <[EMAIL PROTECTED]> wrote: > > > > > > > I am not a big fan of the model system because its very limiting if > > > > > > you have advanced queries. > > > > > > How did you come to that conclusion? > > > > > > ... > > > > > > If you properly created your models and associations, a simple find > > > > > ('all') will give you: Team, Roster, Game and League models with all > > > > > the relevant info. > > > > > > On Dec 4, 6:23 pm, gearvOsh <[EMAIL PROTECTED]> wrote: > > > > > > > Ok in my current system (its a gaming league) I have packages. I > > > > > > will > > > > > > use a Team package as an example. In this Team package I have a > > > > > > method > > > > > > getTeamInfo() which calls out to external queries. I do this so I > > > > > > onl
Auth/Acl Limitations..
Hi all, I am working on a site which currently has around 12000 members. I am converting it to a cake site, and am using the Auth and Acl components. Now that I have imported all the users, an issue I am coming up against, is that where I am creating or deleting an aro, the page actually hangs. It performs the task, so when creating, everything happens as it should, but the page isn't being redirected after it. The same goes with the delete. As soon as I comment out the aro code, the redirect works. The code I am using is below: * creating a user... $aro = new Aro(); $aro->create(); $aro->save(array('alias' => $this->data['User']['username'], 'parent_id' => $this->data['User']['user_group_id'])); ** deleting a user $aro = new Aro(); $oldAro = $aro->findByAlias($user['User']['username']); $aro->del($oldAro['Aro']['id']); the redirect happens immediately after the above code excerpts. Has anyone come across this before? I can't see what I am doing wrong here. any help would be greatly appreciated. Thanks Patrick --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Custom queries/sql in models/behaviors
So I have this method within the model. The same array is returned from above but I get a mysql error for the contain. SQL Error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'contain' at line 1 [CORE\cake\libs\model \datasources\dbo_source.php, line 521] function test() { $this->actsAs = array('Container'); $this->bindModel(array( 'hasMany' => array( 'TeamMember' => array( 'className' => 'TeamMember', 'foreignKey'=> 'team_id', 'conditions'=> array('TeamMember.status' => 'approved'), 'order' => 'TeamMember.joinDate ASC', 'dependent' => true, //'finderQuery' => 'SELECT User.username, User.handle, User.avatar FROM user AS User, teamMember as TeamMember WHERE User.id = TeamMember.user_id LIMIT 1' ), 'TeamGame' => array( 'className' => 'TeamGame', 'foreignKey'=> 'team_id' ) ) )); $this->contain(array('TeamMember' => array('User'), 'TeamGame')); return $this->find('first'); } On Dec 6, 3:35 am, Adam Royle <[EMAIL PROTECTED]> wrote: > Add: > > var $actsAs = array('Containable'); > > to your Team model. > > Then add this before your find() call: > > $this->Team->contain('TeamMember' => array('User'), 'TeamGame'); > > Cheers, > Adam > > On Dec 6, 12:51 pm, gearvOsh <[EMAIL PROTECTED]> wrote: > > > Ok thats weird, I dont have foreign keys really setup but it still > > works. Im using $hasMany for members and games. But within the > > TeamMember and TeamGame arrays, is there way to get more information > > returned? I would need the members name, avatar, etc. > > > Array > > ( > > [0] => Array > > ( > > [Team] => Array > > ( > > [id] => 1 > > [status] => approved > > [name] => chair > > [tag] => _h_ > > [urlName] => > > [website] => > > [irc] => > > [about] => > > [servers] => > > [logo] => > > [createDate] => 0 > > [state_id] => 0 > > [country_id] => 0 > > [created] => > > [modified] => > > ) > > > [TeamMember] => Array > > ( > > [0] => Array > > ( > > [id] => 4 > > [team_id] => 1 > > [user_id] => 32 > > [role] => captain > > [status] => approved > > [joinDate] => 1211498560 > > ) > > ) > > > [TeamGame] => Array > > ( > > [0] => Array > > ( > > [team_id] => 1 > > [gameSystem_id] => 3 > > ) > > ) > > ) > > ) > > > On Dec 5, 4:08 pm, gearvOsh <[EMAIL PROTECTED]> wrote: > > > > Because I cant use foreign keys so all of those features are useless > > > to me. I also cant use linked models. > > > > On Dec 5, 1:12 pm, teknoid <[EMAIL PROTECTED]> wrote: > > > > > > I am not a big fan of the model system because its very limiting if > > > > > you have advanced queries. > > > > > How did you come to that conclusion? > > > > > ... > > > > > If you properly created your models and associations, a simple find > > > > ('all') will give you: Team, Roster, Game and League models with all > > > > the relevant info. > > > > > On Dec 4, 6:23 pm, gearvOsh <[EMAIL PROTECTED]> wrote: > > > > > > Ok in my current system (its a gaming league) I have packages. I will > > > > > use a Team package as an example. In this Team package I have a method > > > > > getTeamInfo() which calls out to external queries. I do this so I only > > > > > have to write a query once and can access its results through a method > > > > > call. I prefer this way instead of having to write the same query over > > > > > and over for different instances. > > > > > > require('teamExt.php'); > > > > > require('userExt.php'); > > > > > > class Team { > > > > > > public static function getTeamInfo($team_id) { > > > > >
Re: how to trigger an ajax update?
That's exactly what I was looking for. It's great because I can pass effects in the options array in the same way as $ajax->link () thanks scheimi On Dec 6, 7:23 pm, schneimi <[EMAIL PROTECTED]> wrote: > Hi, > > I think your are looking for $ajax->remoteFunction(). > > On 6 Dez., 19:13, Juan <[EMAIL PROTECTED]> wrote: > > > Hi all, > > > Is there a way I can ask the ajax helper to update a div? I mean, like > > using $ajax-link (), but without waiting for the click on the link. > > > I just want to update a div once the view has finished loading. > > > any help will be very much appreciated. thanks. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: ORM, fetching related rows of corresponding model: undefined index..
I see you are using the Packt Publishing book, ensure that your model relations aren't misspelled or anything else it won't load the answers and thus won't exist, in the controller do a debug on the find, that or in the view do a pr($questions) before the foreach this will display the array and see what exactly what is in the array. On Dec 6, 9:40 am, Tanay <[EMAIL PROTECTED]> wrote: > Tanay wrote: > > i have two dbs questions , and answers.. > > > corresponding models > > > questions has many answers > > answers belogns to questions > > > in questions_controller, i have this home function > > function home() { > > $this->Question->recursive = 1; > > $this->set('questions', $this->Question->find('all')); > > } > > > in my home.ctp, i tried to show the corresponding answers using the > > code below > > i took a question from an array of questions using foreach > > foreach question, $question['Answer'] is expected to give array of > > answers, but it says Undefined index: Answer > > THAT LIne is marked in code below > > > home.ctp: > > > > > No Questions yet. Be the first one to > > post a Question! > > > > > > > > > ?> > > > > link($question['Question']['question'] > > .'?', array('action' => 'show', $question['Question']['id']))); ?> > > > $answer_count = count($question > > ['Answer']); // <<-ERROR HERE > > if(!$answer_count) > > e("(no answers yet)"); > > else if($answer_count == 1) > > e("(1 answer)"); > > else > > e("(".$answer_count." answers)"); > > ?> > > > > > > > > > > > the above code is a part of project in book CakePHP application > > Development, > > the code is same as in book > > is it due to some different version of cakephp that author used? > > i use latest 1.2 version > > . . . . . . > Still the same. But now it says > The new variable name $question['question']['answer'] is undefined > index. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: how to trigger an ajax update?
Hi, I think your are looking for $ajax->remoteFunction(). On 6 Dez., 19:13, Juan <[EMAIL PROTECTED]> wrote: > Hi all, > > Is there a way I can ask the ajax helper to update a div? I mean, like > using $ajax-link (), but without waiting for the click on the link. > > I just want to update a div once the view has finished loading. > > any help will be very much appreciated. thanks. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
how to trigger an ajax update?
Hi all, Is there a way I can ask the ajax helper to update a div? I mean, like using $ajax-link (), but without waiting for the click on the link. I just want to update a div once the view has finished loading. any help will be very much appreciated. thanks. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: ORM, fetching related rows of corresponding model: undefined index..
Tanay wrote: > i have two dbs questions , and answers.. > > corresponding models > > questions has many answers > answers belogns to questions > > in questions_controller, i have this home function > function home() { > $this->Question->recursive = 1; > $this->set('questions', $this->Question->find('all')); >} > > > in my home.ctp, i tried to show the corresponding answers using the > code below > i took a question from an array of questions using foreach > foreach question, $question['Answer'] is expected to give array of > answers, but it says Undefined index: Answer > THAT LIne is marked in code below > > home.ctp: > > >No Questions yet. Be the first one to > post a Question! > > > > ?> > > link($question['Question']['question'] > .'?', array('action' => 'show', $question['Question']['id']))); ?> > $answer_count = count($question > ['Answer']); // <<-ERROR HERE > if(!$answer_count) >e("(no answers yet)"); > else if($answer_count == 1) >e("(1 answer)"); > else >e("(".$answer_count." answers)"); > ?> > > > > > > the above code is a part of project in book CakePHP application > Development, > the code is same as in book > is it due to some different version of cakephp that author used? > i use latest 1.2 version . . . . . . Still the same. But now it says The new variable name $question['question']['answer'] is undefined index. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Adding extra user info to session
> I assume that I would do this by adding some code somewhere in the > AppController, but where and how would I call it? > > I don't think it would go in beforeFilter() as that would try and run > even if a user wasn't authorised, or would I put a call in there that > first checked if the user was logged in and then ran an action which > would add my extra data to the session? Well I have gone for the following which is working, but could someone say if it is the right way to achieve what I want? [code] class AppController extends Controller { ... function beforeFilter() { if ($this->Session->check('Auth.User')) { $this->__AuthExtra(); } } function __AuthExtra() { $authUser = $this->Session->read('Auth.User'); App::import('Model', 'Person'); $person = new Person; $data = $person->find('first', array( 'conditions' => array('Person.user_id' => $authUser['id']), 'fields' => array('Person.id', 'Person.title', 'Person.first_name', 'Person.middle_name', 'Person.last_name', 'Organisation.id', 'Organisation.name') )); if ($authUser['user_group_id'] == 3) { $data = Set::merge($data, $person->Organisation->find('first', array( 'conditions' => array('Organisation.id' => $data ['Organisation']['id']), 'fields' => array('Scheme.id') ))); } if ($authUser['user_group_id'] == 3) { $data = Set::merge($data, $person->Organisation->find('first', array( 'conditions' => array('Organisation.id' => $data ['Organisation']['id']), 'fields' => array('Scheme.id', 'Agency.id') ))); } $this->Session->write('AuthExtra', $data); } } [/code] --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Question on localization
Use domains: __d() search group for multiple po files: http://groups.google.com/group/cake-php/browse_thread/thread/5b32124747245651/0a19edff3a199ca1?lnk=gst&q=multiple+po+files#0a19edff3a199ca1 On Dec 5, 9:31 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi > I have a question on localization of my application. > My application has many service builded on the same CakePHP. > Every service is avaible for some language. > Now I would have a single file language for every service and not a > unique file default.po where there is every thing. > How can I set the language management to recovered the right file .po? > Many Thanks --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: How to add line break in text mail layout?
Just write "\n" Examples: On Dec 5, 1:44 pm, "dr. Hannibal Lecter" <[EMAIL PROTECTED]> wrote: > Well...that's not supposed to happen. Can you check the mail source > and mime headers? Maybe you're not sending your email in plain text..? > > On Dec 5, 1:11 pm, Hipnotik <[EMAIL PROTECTED]> wrote: > > > On 5 Gru, 12:35, "dr. Hannibal Lecter" <[EMAIL PROTECTED]> wrote: > > > > What about simply hitting the enter key? :) > > > Doesn't work... displays all lines in one :( > > > > On Dec 5, 12:14 pm, Hipnotik <[EMAIL PROTECTED]> wrote: > > > > > How to add line break in text mail layout? > > > > > It's in elements/email/text/default.ctp file. > > > > I tried to use: > > > > \n > > > > \r\n > > > > \r > > > > and still it doesn't work correct. > > > > It breaks the lines but new line character (i.e. \n) appears in the > > > > received message too. > > > > > How to do that? > > > > Thanks for help ;) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
How to have each instance of a model access all elements of another table
Hello, I'm new to CakePHP and PHP in general. I turned to the mailing list for help because I'm stuck and couldn't find what I need from searching the internet, so I hope you guys could help me out. [Sorry if this happens to turn out too easy. Like I said, I'm new to Cake and PHP in general, so be nice. ;) ] I'm building an application that would connect serially to a device. As a user can opt to have different device configurations, I made a model named "settings" that have the following fields: | id | port_direction | port_value | etc. | 1 | 00| 00 | . | 2 | 01| 02 | . How do I map these rows to a column of another table containing the commands corresponding to the "settings" fields? | id | command_name| command_code | 1 | port_direction | 1201 | 2 | port_value | 1202 Updating each of the "settings" fields, requires accessing the corresponding element in the "commands" table. I can't really think of an association to connect the two tables (I don't think the "commands" table can really be classified as a model, but more of a simple list), as each "setting" would require using *all* elements of the commands table (hasOne and belongsTo is one-to-one, HATBM would create an extremely large table with repeating relationships). What do you suggest I do to be able to access the "commands" table from the "settings" model? Thanks in advance. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Data Validation error message fails on $this->redirect
Why are you using two actions to begin with? It seems like your inviting issues using such a manner. Have you considered sending all the data to the same action, and on successful validation redirect to the next action? Seems like a cleaner way to go about things. On Dec 6, 1:20 am, Renesistemic <[EMAIL PROTECTED]> wrote: > I've had no luck locating any resource online for resolving my issue > (which I feel is fairly easy), and thought I'd post it on here to see > if anyone has input. > > I'm trying to use the built-in data validation for submitting a form. > The originating action, say, "manage_posts", displays the form to the > user and lets them modify data for that post. When they submit, it > sends the data to "activate_post". > > In the "activate_post" action, I call the if($this->Datavalue->set > ($this->data) && $this->Datavalue->validates) function to test the > data, and if that test fails I redirect back to "manage_posts"... > > The actual validation process seems to be functioning. It accepts > valid data and redirects on invalid data. However, when it redirects > to the previous action, it doesn't actually display the error message > for that HTML element > > In the original form, I am in fact calling $this->Form->error > ($datavalue, $error_msg) after generating the HTML element with $this- > > >Form->input(). > > Likewise, I have other actions throughout my application that use data > validation and work correctly. However, they don't redirect to another > action on failing validation. An example would be an action to > "add_posts"... When the user submits data, it submits to itself, > tests, and upon validation renders the same action/view. > > It seems that I'm only experiencing these problems when I redirect on > the failure of a data validation. Any thoughts? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Multiple Instances of TinyMCE
So I've been playing around with the TinyMCE Helper located in the bakery and so far it's been pretty awesome. However I do have one problem. In one of my areas there are two text boxes that need editing, and so I would like TinyMCE to control both text boxes. This is my code for that part of the form: echo $form->label('description', 'Description:'); echo $tinymce->input('description', array('label' => false, 'rows' => 20, 'cols' => 50)); echo $form->label('tech_description', 'Technical Description:'); echo $tinymce->input('tech_description', array('label' => false, 'rows' => 20, 'cols' => 50)); However, only the first text box gets TinyMCE, the other one gets reduced to a normal textarea box. So I am just wondering if anyone knows how to make it produce two TinyMCE boxes so I can have multiple instances of it. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: store i18n data in database
Hi, thanks for the answers but the don't really cover my problem. Maybe my explanation was a bit blurry... Let's say I have a link like this: $html->link(__('edit data', true), array(...)) This works fine with the translations for 'edit data' in the po-files. But in my application I have to give the users the ability to edit these translations without forcing them to fumble around with the po-files. So it's not really about translating the data in my models, that's why the translate behaviour doesn't seem to fit. Or am I missing something? Regards Guenther --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Adding extra user info to session
Hi all, I am still a newbie to CakePHP and have given myself a huge test by recoding one of my clients large active applications as my first CakePHP project. This application allows my client (a national homeless charity) to offer a management system to its regional affiliated Schemes. The Schemes can log all referrals they get into one database and run off their own reports, but the national charity can then produce stats giving a national perspective. The Charity gets restricted access to all the data, the regional Schemes get full access to their own data and can also give Agencies access to submit referrals and view restricted information about their referrals. I am using Auth in it's most basic form without issue which after a succesful login adds the data from the User model into the session, but I would also like to add extra information into the session from other models depending on the users group, such as Group: Developer (Me) - Auth.Person - Auth.Organisation Group: Administrator (National Charity) - Auth.Person - Auth.Organisation Group: Scheme Manager (Scheme) - Auth.Person - Auth.Organisation - Auth.Scheme Group: Agency Manager (Agency) - Auth.Person - Auth.Organisation - Auth.Scheme - Auth.Agency I assume that I would do this by adding some code somewhere in the AppController, but where and how would I call it? I don't think it would go in beforeFilter() as that would try and run even if a user wasn't authorised, or would I put a call in there that first checked if the user was logged in and then ran an action which would add my extra data to the session? I have looked long and hard at the ACL component, but got nowhere with it and the amount of ACO records I would need to create and maintain for this app would me massive. Thanks, Paul. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Custom queries/sql in models/behaviors
Add: var $actsAs = array('Containable'); to your Team model. Then add this before your find() call: $this->Team->contain('TeamMember' => array('User'), 'TeamGame'); Cheers, Adam On Dec 6, 12:51 pm, gearvOsh <[EMAIL PROTECTED]> wrote: > Ok thats weird, I dont have foreign keys really setup but it still > works. Im using $hasMany for members and games. But within the > TeamMember and TeamGame arrays, is there way to get more information > returned? I would need the members name, avatar, etc. > > Array > ( > [0] => Array > ( > [Team] => Array > ( > [id] => 1 > [status] => approved > [name] => chair > [tag] => _h_ > [urlName] => > [website] => > [irc] => > [about] => > [servers] => > [logo] => > [createDate] => 0 > [state_id] => 0 > [country_id] => 0 > [created] => > [modified] => > ) > > [TeamMember] => Array > ( > [0] => Array > ( > [id] => 4 > [team_id] => 1 > [user_id] => 32 > [role] => captain > [status] => approved > [joinDate] => 1211498560 > ) > ) > > [TeamGame] => Array > ( > [0] => Array > ( > [team_id] => 1 > [gameSystem_id] => 3 > ) > ) > ) > ) > > On Dec 5, 4:08 pm, gearvOsh <[EMAIL PROTECTED]> wrote: > > > Because I cant use foreign keys so all of those features are useless > > to me. I also cant use linked models. > > > On Dec 5, 1:12 pm, teknoid <[EMAIL PROTECTED]> wrote: > > > > > I am not a big fan of the model system because its very limiting if you > > > > have advanced queries. > > > > How did you come to that conclusion? > > > > ... > > > > If you properly created your models and associations, a simple find > > > ('all') will give you: Team, Roster, Game and League models with all > > > the relevant info. > > > > On Dec 4, 6:23 pm, gearvOsh <[EMAIL PROTECTED]> wrote: > > > > > Ok in my current system (its a gaming league) I have packages. I will > > > > use a Team package as an example. In this Team package I have a method > > > > getTeamInfo() which calls out to external queries. I do this so I only > > > > have to write a query once and can access its results through a method > > > > call. I prefer this way instead of having to write the same query over > > > > and over for different instances. > > > > > require('teamExt.php'); > > > > require('userExt.php'); > > > > > class Team { > > > > > public static function getTeamInfo($team_id) { > > > > $team = TeamExt::getTeamInfo($team_id); > > > > > if (!empty($team)) { > > > > $team['roster'] = TeamExt::getRoster($team_id); > > > > $team['games'] = > > > > TeamExt::getGamesPlayed($team_id); > > > > $team['stats'] = TeamExt::getStats($team_id); > > > > $team['leader'] = > > > > UserExt::getUser($team['leader_id']); > > > > } > > > > > return $team; > > > > } > > > > > } > > > > > Now when I call Team::getTeamInfo I should have its team info, roster, > > > > games played, the team leader and league statistics. Now the problem > > > > with CakePHP is its model system. I am not a big fan of the model > > > > system because its very limiting if you have advanced queries. I was > > > > thinking of doing it this way: > > > > > Class Team = Model Team > > > > TeamExt = Team Behavior > > > > UserExt = User Behavior > > > > > $team = $this->Team->getTeamInfo(); > > > > > But how would I do custom queries in a behavior? And the logic for > > > > behavior is wrong with my idea anyways. Anyone have an idea of how I > > > > can accomplish my setup in CakePHP, because this is the one thing > > > > stopping me from using CakePHP. And no I will not use joins. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Handling Multiple Checkbox in Pagination
Perhaps you can save them into an array and place the array into a session. On Dec 6, 1:26 am, krishna <[EMAIL PROTECTED]> wrote: > Handling Multiple Checkbox in Pagination > > Hi Cake Bakers, > > In my project i am having a users table. In the admin, i have an > option for the admin to message to particular users based selection. > This selection is based on the pagination. > Now my problem is that, when the admin selects 3 users(say) from the > first page, > then selects another 3 users from next page, how can i track the users > list for which the > message to be sent. > > Kindly help. > > Regards, > Krishnan Nair > > === > > Cake Bake --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: HABTM on multiple DB---Please help me
Hi Marco, I think that you can't do it with official methods, however you can implement this functionality. On Dec 5, 11:27 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I have this question that I can't resolve. > I hope that someone can help me. > How can I set a HABTM relation between table on different DataBase? > Many Thanks > Marco --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Handling Multiple Checkbox in Pagination
Handling Multiple Checkbox in Pagination Hi Cake Bakers, In my project i am having a users table. In the admin, i have an option for the admin to message to particular users based selection. This selection is based on the pagination. Now my problem is that, when the admin selects 3 users(say) from the first page, then selects another 3 users from next page, how can i track the users list for which the message to be sent. Kindly help. Regards, Krishnan Nair === Cake Bake --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: admin routing
hello grigri thanks for ur message after i added this line i got following error please letme know what to add in controller.php Router::connect('/admin/',array ('controller'=>'administrators','action'=>'index','admin'=>'true','prefix'=>'admin')); Router::connect('/admin/*',array ('controller'=>'administrators','action'=>'index','admin'=>'true','prefix'=>'admin')); error : Missing Controller Error: Controller could not be found. Error: Create the class Controller below in file: app\controllers \controller.php Notice: If you want to customize this error message, create app\views \errors\missing_controller.ctp --- On Dec 5, 9:12 pm, grigri <[EMAIL PROTECTED]> wrote: > The problem here is that cake doesn't know where to go with a plain > 'admin/' route since there is no controller or action specified. You > need to specify a default controller / action in the routes.php config > file. > > If for example you wanted to have `/admin` be equivalent to `/admin/ > posts/latest/` then you would add this line: > > Router::connect('/admin/', array('controller' => 'posts', 'action' => > 'latest', 'prefix' => 'admin', 'admin' => true)); > > hth > grigri > > On Dec 5, 1:22 pm, dravid <[EMAIL PROTECTED]> wrote: > > > hello Cake PHP Group, > > > In one of our simple project using CAKE PHP (1.2) we tried to add > > administrative pages and access based on admin user roles. > > > The problem is we are not able to view the page by simply entering > > {URL to CAKE PHP}/admin/ > > instead we are only able to open the admin section when we enter > > {URL to CAKE PHP}/admin/{Controller}/ or > > {URL to CAKE PHP}/admin/{controller}/{action} > > > Anybody please help to configure this Admin Routing in routes.php and > > steps to implement the admin routing. > > > For your reference, i am listing the steps what i did so far. > > 1. I have take the comment in the app/config/core.php > > Configure::write('Routing.admin', 'admin'); > > > 2. Then added the following lines in the app/config/routes.php > > Router::connect('/admin/:controller/:action/*', array > > ('admin'=>'true','prefix'=>'admin',)); > > Router::connect('/admin', array('controller' => 'pages', 'action' > > =>'index','admin'=>'true','prefix'=>'admin')); > > > 3. Then implemented the admin_index(), admin_login() etc., in the > > 'administrators' controller. > > > 4. Then implemented the admin_index() function in the cake/libs/ > > controller/pages_controller.php > > > 5. Then implemented the admin_index.ctp file in the folder app/views/ > > pages/ > > > 6. Then implemented the admin_index.ctp and admin_login.ctp in the > > folders app/views/administrators/ > > > The finall summary: the problem is we are not able to view the admin > > actions by simply entering {URL to CAKE PHP}/admin/ > > > Please help us to solve this issue in 'Route::connect()' so that we > > can implement the role based page access. > > > Thanks in advance and looking forward for your reply. > > > With best regards > > > Dravid --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---