Re: Validate data md5
Thank you guys, this was really helpful Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Problem with models....help please!!!
I think you have a typo: var $actAs = array('Containable'); should be var $actsAs = array('Containable'); you forgot the 's' On 6 jun, 21:09, Christopher Hanson phpcoder2...@gmail.com wrote: hey, i tried the following ?php class Invoice extends AppModel { var $name = 'Invoice'; var $actAs = array('Containable'); var $hasMany = array( 'InvoiceRows' = array( 'className' = 'InvoiceRows', 'foreignKey' = 'invoice_id', 'order' = 'InvoiceRows.delta ASC', ), ); var $belongsTo = array( 'Client' = array( 'className' = 'Client', ), ); } and ?php class InvoicesController extends AppController { var $name = 'Invoices'; function index(){} function view($invoice_id) { $this-Invoice-contain('Country'); $data = $this-Invoice-find('all'); //$data = $this-Invoice-findById($invoice_id); debug($data); $this-set('client_data', $data); } } also even if i try contain(); it still comes back with this error *Warning* (512) javascript:void(0);:*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*673*] Chris -- Best Regards Christopher Hanson Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: cakephp html link helper to create absolute urls
http://api12.cakephp.org/class/html-helper#method-HtmlHelperurl You can add the array('action' = 'view', 5) parameter and it will be compatible with custom routes (look here: http://api12.cakephp.org/view_source/html-helper/#line-278) On Jun 7, 7:33 am, Andras Kende and...@kende.com wrote: Hello, Is it possible for cakephp html link helper to create absolute urls? I saw this could be done with html-url() something like : ?php echo $html-link('TEST LINK', $html-url('/advances/forward', true)); ? but not sure how compatible that with custom routes etc... Thanks, Andras Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Problem with models....help please!!!
On 06/06/2010 20:18, Jens Ulf Dittrich wrote: I guess you have no Class InvoiceRows in your Models. I think your Invoice AppModel should be something like: ... var $hasMany = array( 'InvoiceRows' = array( // I guess that is ok for the name 'className' = 'Invoice', // -- this one has to be a name of an actually existing Model/Table . Hi Jens InvoiceRows works fine alrready, i Have classname as InvoiceRows, a table in db invoice_rows and model file invoice_rows.php but thanks for the help anyway. -- Best Regards Christopher Hanson Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Problem with using XML with CAKEPHP
Hi I would use XML in my application. I define my default layout in xml like : ?php header(Expires: Mon, 26 Jul 1997 05:00:00 GMT\n); header(Last-Modified: . gmdate(D, d M Y H:i:s) . GMT ); header(Cache-Control: no-cache, must-revalidate ); header(Pragma: no-cache ); header(Content-type:text/xml); print (?xml version=\1.0\ encoding=\UTF-8\ ?); ? ? echo $content_for_layout; ? Now when I call a page like : /{controller}/{action}.xml I get this error : Error interpretation XML: non well-formed Line number 2, column 3: ? echo $content_for_layout; ? ---^ Can someone help me about this? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Problem with using XML with CAKEPHP
Well you have ?php at start of file and ? before the echo... Does you're host allow short PHP tags? t. On Jun 7, 11:35 am, marco.rizze...@gmail.com marco.rizze...@gmail.com wrote: Hi I would use XML in my application. I define my default layout in xml like : ?php header(Expires: Mon, 26 Jul 1997 05:00:00 GMT\n); header(Last-Modified: . gmdate(D, d M Y H:i:s) . GMT ); header(Cache-Control: no-cache, must-revalidate ); header(Pragma: no-cache ); header(Content-type:text/xml); print (?xml version=\1.0\ encoding=\UTF-8\ ?); ? ? echo $content_for_layout; ? Now when I call a page like : /{controller}/{action}.xml I get this error : Error interpretation XML: non well-formed Line number 2, column 3: ? echo $content_for_layout; ? ---^ Can someone help me about this? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Query question(s)
Based on what you have posted I would ask whether a redesign of the database would be a better idea! I refer to the issue you have created yourself, by having one column contain more than one value at the same time: [quote] ... The problem I'm running into is that $array can contain any number and combination of values (A, C, E), (A, B), (E) ... etc. And 'SomeCol.contents' can also contain any number and combination of values stored as a comma separated string. (it was originally stored as a serialized array). ... [/quote] Can you explain why you have not separated/normalized the SomeCol.contents? And do you have other such columns in your database? Enjoy, John On Jun 6, 11:24 pm, Ed Propsner crotchf...@gmail.com wrote: I found a usable solution, a bit exhaustive and long-winded perhaps, but usable nonetheless. I still need to put together a dynamic query and I'm finding myself avoiding having to do it at this time. I need to build a query dynamically based on what elements a user chooses from a form. There could be 20 choices or there could be 2. Every solution I'm coming up with is ridiculously excessive for something that should be so simple. I'm sure the answer is there, I'm just not familiar enough with Cake at this point to see it. - Ed On Sat, Jun 5, 2010 at 4:36 PM, Ed Propsner crotchf...@gmail.com wrote: Perhaps I'm over-complicating this but I'm still having some problems with building my query. I'm looking to do something like: $array = array (A, B, C, D, E); $list = implode( ',' , $array); 'conditions' = array( 'SomeCol.contents' = array($list) ) The problem I'm running into is that $array can contain any number and combination of values (A, C, E), (A, B), (E) ... etc. And 'SomeCol.contents' can also contain any number and combination of values stored as a comma separated string. (it was originally stored as a serialized array). I need the query to return a result if 'SomeCol.contents' and $array have any one of their values in common. I was thinking along the lines of : 'conditions' = array( 'SomeCol.contents LIKE' = '%'.$array[0].'%' OR 'SomeCol.contents LIKE' = '%'.$array[1].'%' etc, etc // this way should include any record in the result that shares a value with $array but I assume I would run into an issue with an undefined index by not knowing how many values $array contains. (I do know it has the potential to store a max of 7 values) I had this all worked out with conventional PHP but now I need to use Paginate and containable with this query as well as a bunch of other conditions (with a set value) and I'm confusing myself more than anything else which isn't a real stretch for me to begin with 8-). Any suggestions are appreciated. Thanks. - Ed On Fri, Jun 4, 2010 at 11:54 PM, Ed Propsner crotchf...@gmail.com wrote: Thanks Calvin, point well taken. I'll just stick with GET like I always have for searches. I tweaked the routing and got things cleaned up a bit so I guess I'm okay with it. I'm not quite sure what I was expecting in the first place? 8-) The search uses a lot of checkboxes and results in something like http://mysite.com/search/results/value1=0value1=1value2=0value2=1. I can't seem to clean it up any more when submitting with GET, or am I still missing something? Anyhow, at least it's working the way that I want it to. I'm still having some issues with query so I'll quit fussing with the url for now. - Ed On Fri, Jun 4, 2010 at 10:15 PM, calvin cal...@rottenrecords.com wrote: POST requests are generally not cached, but you can force it to be cached using the Cache-Control and Expires headers. However, I've never tried this so I don't know if the browser will still show the form submission dialog (it may need to resend the form data to check to see if the document has changed since last requested). It probably won't, but I would still strongly advise against this. A search request is generally an idempotent operation (multiple requests do not have any side-effects), which is precisely what the GET request is designed for. There's no reason to use POST in this case. Cake has a perfectly good way of hiding ugly URL-encoding using its REST-style routing patterns, e.g.: http://yoursite.com/pages/search/foo/bar/foo2/bar2/... You can also use named parameters to make the search URL more readable, e.g.: http://yoursite.com/products/search/q:paegan/artist:acid+bath/categor... Unless you have a ton of search options, I see no reason to use POST. And even if you use POST and generate shorter/cleaner URL--what's the point? What will that clean URL achieve? The user can't bookmark it. They can't link a friend to it. They can't do anything
I'm trying to make a good find with three HABTM models
My setup is pretty straightforward; User HABTM Group Group HABTM Project Project HABTM User I would like to produce a find-query that takes a single project-id and builds a hierarchic contact list, in which the users belong to their respective group(s). Something along these lines: [Project 1] [Group 1] [User 1] [User 5] [Group 2] [User 1] [User 2] [User 3] [Group 4] [User 3] [User 4] ... Is this possible and if so, how? All I've been able to produce is something of a flat structure where I can't match the user to a group; [Project 1] [User 1] [User 3] [User 4] [User 6] [Group 1] [Group 3] [Group 4] This is produced when I do; $this-Project-find('all'); Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Facebook fan pages and application
Cake is PHP so the PHP libraries for the Facebook Graph API are what you need to use and are likely to have their own forums/groups. If you want to know how to import those libraries look at Vendors in the book, you simply place the library in your vendors folder and import it where you need it. http://book.cakephp.org/view/538/Loading-Vendor-Files HTH Paul. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: How to pass array value from one ctp file to another ctp file
The book is your friend: http://book.cakephp.org/view/97/Elements HTH Paul. On Jun 4, 5:21 am, Narendra Padala crazycake...@gmail.com wrote: can u please send any working example... On Wed, Jun 2, 2010 at 6:56 PM, Shaz shazam...@gmail.com wrote: Use elements, you can pass values between them: $this-element('whatever', $valuetobepassed); On 2 June, 13:16, Narendra Padala crazycake...@gmail.com wrote: Hi flocks, I am, new to cake php actually i want display one report, in the down i put the link download link for Excel. For that purpose , i have to display same content for report and excel, so i was set the query results in one variable rows, using that variable i was displayed the records now same variable i have to use in In the export_xls.ctp file so, for that purpose i passed variable through query string. so in that time i din't get data, simple its shows array() in address bar. so how to pass array value form one ctp to ctp in same controller. please help me out. I wrote code like this... MyConroller -- ?php class MyviewsController extends AppController { var $name = 'Myviews'; function display() { $this-Myview-recursive = 1; $data = $this-Myview-find('all'); $this-set('rows',$data); } function export_xls($data) { $this-set('rows',$data); $this-render('export_xls','export_xls'); }} ? --- ctp files display.ctp STYLE type=text/css .tableTd { border-width: 0.5pt; border: solid; } .tableTdContent{ border-width: 0.5pt; border: solid; } #titles{ font-weight: bolder; } /STYLE table tr tdbExport To Excel Sampleb/td /tr tr tdbDate:/b/td td?php echo date(F j, Y, g:i a); ?/td /tr tr tdbNumber of Rows:/b/td td style=text-align:left?php echo count($rows);?/td /tr tr td/td /tr tr id=titles td class=tableTdColumn 1/td td class=tableTdColumn 2/td /tr ?php foreach($rows as $row): echo 'tr'; echo 'td class=tableTdContent'.$row['Myview']['no'].'/td'; echo 'td class=tableTdContent'.$row['Myview']['name'].'/td'; echo '/tr'; endforeach; ? /table br / table tr align=center td?php echo $html-image('button_excel_onclick.gif', array('border' = '0', 'url' = array('controller'= 'myviews', 'action' = 'export_xls', $rows))); ? /td /tr table - export_xls.ctp STYLE type=text/css .tableTd { border-width: 0.5pt; border: solid; } .tableTdContent{ border-width: 0.5pt; border: solid; } #titles{ font-weight: bolder; } /STYLE table tr tdbExport To Excel Sampleb/td /tr tr tdbDate:/b/td td?php echo date(F j, Y, g:i a); ?/td /tr tr tdbNumber of Rows:/b/td td style=text-align:left?php echo count($rows);?/td /tr tr td/td /tr tr id=titles td class=tableTdColumn 1/td td class=tableTdColumn 2/td /tr ?php foreach($rows as $row): echo 'tr'; echo 'td class=tableTdContent'.$row['Myview']['no'].'/td'; echo 'td class=tableTdContent'.$row['Myview']['name'].'/td'; echo '/tr'; endforeach; ? /table --- please any one can help me out..! thanks in advance...! Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions. 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.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at
Re: CakePHP Gigya Social Network Plugin
Thanks for the update, and congrats on pricking Gigya's attention! I will feedback to you after my discussion with them. Paul. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: saveField() causes a SELECT COUNT(*)
I think it's to be sure that the record actually exists and it's updated. If you make mysql update call on a non-existent record you won't get an error, so the saveField() would return true when it should return false. By executing the COUNT statement saveField() can return false if the record doesn't exist On Jun 6, 8:28 pm, Jake Moilanen moila...@gmail.com wrote: I have a very expensive background analytic process which is hammering my database and I am wanting to reduce the unnecessary database calls where ever I can. I have a general log on my database and I noticed whenever the code does a saveField() that first it tries getting the count on a primary key (which should always be 1): SELECT COUNT(*) AS `count` FROM `page_instances` AS `PageInstance` WHERE `PageInstance`.`id` = 3214334 UPDATE `page_instances` SET `visible` = '0' WHERE `page_instances`.`id` = 3214334 I can do the UPDATE manually in my model and it avoids this SELECT COUNT(*), but I was unsure if getting the count was for good reason. Using version 1.2.6. Thanks, Jake Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: I'm trying to make a good find with three HABTM models
You can try Containable behavior. In models put var $actsAs = array('Containable'); and then in the controller $this-Project-find('all', array('contain' = array('Group' = array('User'; you can find out more about the Containable behavior in the cook book http://book.cakephp.org/view/1323/Containable On Jun 7, 2:54 pm, DrLaban jbh...@gmail.com wrote: My setup is pretty straightforward; User HABTM Group Group HABTM Project Project HABTM User I would like to produce a find-query that takes a single project-id and builds a hierarchic contact list, in which the users belong to their respective group(s). Something along these lines: [Project 1] [Group 1] [User 1] [User 5] [Group 2] [User 1] [User 2] [User 3] [Group 4] [User 3] [User 4] ... Is this possible and if so, how? All I've been able to produce is something of a flat structure where I can't match the user to a group; [Project 1] [User 1] [User 3] [User 4] [User 6] [Group 1] [Group 3] [Group 4] This is produced when I do; $this-Project-find('all'); Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: URL is showing wrong
does anybody else have this issue too? 2010/6/6 Davor Ilic webfa...@gmail.com Hi, my url is this: http://my.site/*app/webroot/index.php/*clients/add_client why is it like this it change after time but can´t say i´ve changed something. i wont to show the link like this with $html-link() : http://my.site/clients/add_client Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Facebook fan pages and application
isnt there a powerful plugin for that? http://groups.google.com/group/cake-php/browse_thread/thread/9bbeba60afebae6b/8167bafc74f67bfb#8167bafc74f67bfb On 7 Jun., 14:56, WebbedIT p...@webbedit.co.uk wrote: Cake is PHP so the PHP libraries for the Facebook Graph API are what you need to use and are likely to have their own forums/groups. If you want to know how to import those libraries look at Vendors in the book, you simply place the library in your vendors folder and import it where you need it. http://book.cakephp.org/view/538/Loading-Vendor-Files HTH Paul. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: URL is showing wrong
Please provide more information!! How is it showing wrong? Where is it showing wrong? What code is creating it? Without that we have no idea what you are talking about!! :) Enjoy, John On Jun 7, 4:28 pm, Davor Ilic webfa...@gmail.com wrote: does anybody else have this issue too? 2010/6/6 Davor Ilic webfa...@gmail.com Hi, my url is this:http://my.site/*app/webroot/index.php/*clients/add_client why is it like this it change after time but can´t say i´ve changed something. i wont to show the link like this with $html-link() : http://my.site/clients/add_client Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: URL is showing wrong
And I were too fast here, sorry for that! What is the code that creates the link? Enjoy, John On Jun 7, 4:28 pm, Davor Ilic webfa...@gmail.com wrote: does anybody else have this issue too? 2010/6/6 Davor Ilic webfa...@gmail.com Hi, my url is this:http://my.site/*app/webroot/index.php/*clients/add_client why is it like this it change after time but can´t say i´ve changed something. i wont to show the link like this with $html-link() : http://my.site/clients/add_client Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Total count of posts?
Just put it in the AppController (e.g. in beforeRender() or beforeFilter()). That's what I do for my navigation variables. On Jun 6, 3:49 am, saidbakr said@gmail.com wrote: Hi, What I meant is placing this in the layout to be available in all parts or pages of the application. I discovered that requestAction() method is able to do this in the layout. However, requestAction() method could not able to call private actions - Actions of name start with underscore _ such as _postcount. My question now is how to make requestAction able to call private action? On Jun 6, 4:20 am, Andras Kende and...@kende.com wrote: Hello, in the controller: $this-set('postcount', $this-Post-find('count')); in the view: ?php echo $postcount; ? Andras On Jun 5, 2010, at 6:34 PM, saidbakr wrote: Hi, How could I set dynamic data in the layout? In other word, I need to place the total count of posts in the layout footer. My application has posts controller and post model. Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others with their CakePHP related questions. 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 For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: URL is showing wrong
this creates link http://my.site/*app/webroot/index.php/*clients/add_client; but i want to tell link to show it without *app/webroot/index.php/ it should look like this url * http://my.site/clients/add_client . thanks 2010/6/7 John Andersen j.andersen...@gmail.com And I were too fast here, sorry for that! What is the code that creates the link? Enjoy, John On Jun 7, 4:28 pm, Davor Ilic webfa...@gmail.com wrote: does anybody else have this issue too? 2010/6/6 Davor Ilic webfa...@gmail.com Hi, my url is this: http://my.site/*app/webroot/index.php/*clients/add_client why is it like this it change after time but can´t say i´ve changed something. i wont to show the link like this with $html-link() : http://my.site/clients/add_client Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Dynamic Navigation (Menu and submenu)
He's laid out pretty much how to implement it yourself (with example code). Why not just follow the article and implement it on your site yourself instead of waiting for someone to hand you a complete plugin for what is a relatively simple task? On Jun 6, 10:53 pm, saavedrajj saavedr...@gmail.com wrote: OMG Hi JeremyPlease if you have some working example there send it to me if you can. saavedrajj -at- gmail.com otherwise... i have to wait :( good luck with the update On 7 jun, 01:21, Jeremy Burns jeremybu...@me.com wrote: That's my article. It needs updating as I have improved it substantially since writing it. It also needs some code to download. I can't commit to a timeframe, but I will work on it. Jeremy Burns jeremybu...@me.com On 7 Jun 2010, at 05:06, saavedrajj wrote: I'm tired of search all the web for the best article about Dynamic Navigation in CakePHP I think this is one of the best articles that i found, but doesn't have a code to download http://articles.classoutfit.com/2009/11/cakephp-dynamic-navigation-bars/ I realized that nobody wants to share how to do this it would be nice that SOMEONE post the ultimate dynamic navigation helper for everybody I can believe that it's very difficult to make a menu and submenu with active tabs!! Any help please? Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others with their CakePHP related questions. 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 For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
cakephp
Hi i am new to cakephp i am getting this error when i am running http://localhost/quickwall/ Error: The requested address '/' was not found on this server. help me to correct this error Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: No form data
Thank guys, now it is working! On 4 Jun., 17:27, calvin cal...@rottenrecords.com wrote: 1. Controllers are plural. So it would be 'checkouts' not 'checkout'. 2. Read the Cookbook; you're not using $form-input() correctly. On Jun 4, 6:47 am, Christoph christophwe...@googlemail.com wrote: hi, i have a little bit trouble because i don't get anyformdatain $this-data. i only get thedatain $this-params['form']. is there a way to change that? that myform: print $form-create(Checkout, array( url = array(controller = checkout, action = step2), type = post)); print $form-input (select, array ( options = array(Herr = Herr, Frau = Frau), label = Anrede:, name = anrede, id = anrede ) ); print $form-input (input, array ( label = Name:, name = name, id = name ) ); print $form-input (input, array ( label = Vorname:, name = vorname, id = vorname ) ); print $form-input (input, array ( label = Straszlig;e, Nr:, name = strasse, id = strasse ) ); print $form-input (input, array ( label = Postleitzahl:, name = plz, id = plz ) ); print $form-input (input, array ( label = Email:, name = email, id = email ) ); print $form-input (input, array ( label = Telefon:, name = telefon, id = telefon ) ); print $form-end(buttons/weiter.png); Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Auth Component and user information.
Hi, I use User model to handle user's basic data such as Name, username, password and so on. The User model is associated with Rule model by belongsTo association, while Rule model is associated to User model by hasMany association. The later model Rule is meant by something like users groups so it handles name, description, value and of-course id, for example, two records from rules table: id - 1 name - Administrators description - The super users group! value - ABC id - 2 name - Editors decription - reviewers and articles writers. value - BC In AuthComponent documentation : http://book.cakephp.org/view/247/AuthComponent-Methods#user-387 when they talked about user method of the component, they regards that it is possible to retrieve the current user data from the session in the view like: # $session-read('Auth.User.first_name') //returns particular field value This example shows that the access of User model property first_name. My Question Is, How could I able to access the associated model property Rule such as Rule.name ? Best Regards! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Query question(s)
I'm not sure what you ought to do about the custom query (you may just have to build it the hard way or do as Ed suggest and redesign the DB), but regarding the URL, there are a few ways to go about it. Firstly, I should point out that the URL you wrote doesn't look right. Usually, with something like checkboxes, you want to transmit the data as an array: http://mysite.com/search/results/value1[]=0value1[]=1value2[]=0value2[]=1 I think that's how URL-encoded array data usually looks. As to how to get from the standard http URL-encoding to Cake's REST- style encoding, there are a few ways to go about it. The most obvious way is to use JavaScript to build the Cake URL. That would be easy to do, but it's not a good approach from an accessibility standpoint. Instead, I would recommend accepting the ugly url and then, in the controller, translate that into a Cake URL and redirect the user there. For example, you'd start with a standard search form with an action url of: http://mysite.com/search which produces URLs like: http://mysite.com/search?value1[]=0value1[]=1value2[]=0value2[]=1... Then the action that http://mysite.com/search routes to will take those GET variables and convert them into: http://mysite.com/search/result/value1:0,1/value2:0,1/... I'm not sure if Cake has its own way of serializing arrays for URLs, but that would seem like the most readable way to do it. You might also try: /search/result/value1[]:0/value1[]:1/value2[]:0/value2[]:1 or use PHP's serialize() function, which would return something like: /search/result/value1:a:2:{i:0;i:0;i:1;i:1;}/value2:a:2:{i:0;i:0;i:1;i: 1;} --which is not very pretty. On Jun 4, 8:54 pm, Ed Propsner crotchf...@gmail.com wrote: Thanks Calvin, point well taken. I'll just stick with GET like I always have for searches. I tweaked the routing and got things cleaned up a bit so I guess I'm okay with it. I'm not quite sure what I was expecting in the first place? 8-) The search uses a lot of checkboxes and results in something likehttp://mysite.com/search/results/value1=0value1=1value2=0value2=1. I can't seem to clean it up any more when submitting with GET, or am I still missing something? Anyhow, at least it's working the way that I want it to. I'm still having some issues with query so I'll quit fussing with the url for now. - Ed On Fri, Jun 4, 2010 at 10:15 PM, calvin cal...@rottenrecords.com wrote: POST requests are generally not cached, but you can force it to be cached using the Cache-Control and Expires headers. However, I've never tried this so I don't know if the browser will still show the form submission dialog (it may need to resend the form data to check to see if the document has changed since last requested). It probably won't, but I would still strongly advise against this. A search request is generally an idempotent operation (multiple requests do not have any side-effects), which is precisely what the GET request is designed for. There's no reason to use POST in this case. Cake has a perfectly good way of hiding ugly URL-encoding using its REST-style routing patterns, e.g.: http://yoursite.com/pages/search/foo/bar/foo2/bar2/... You can also use named parameters to make the search URL more readable, e.g.: http://yoursite.com/products/search/q:paegan/artist:acid+bath/categor... Unless you have a ton of search options, I see no reason to use POST. And even if you use POST and generate shorter/cleaner URL--what's the point? What will that clean URL achieve? The user can't bookmark it. They can't link a friend to it. They can't do anything with it. A happy compromise would be to do what a lot of forums do, and cache each search server-side. Then when the user performs a search (with either POST or GET), they get redirected to the cached search result, which might be something like: http://yoursite.com/search/paegan+terrorism+tactics/f83e3a4b389c6b That will decrease your server load, allow you to use a POST form, and still allow the user to bookmark/link the search results (at least for a time). On Jun 4, 10:40 am, Ed Propsner crotchf...@gmail.com wrote: I was checking out the book on complex queries and not really finding what I'm looking for. I'm trying to create a query that covers both a basic and advanced search. The form may be submitting all or just some of the options available on the page depending on what the user chooses. Once the form has been submitted clicking any one of the query results would navigate the user away from the 'results page'. To avoid getting hit with the form submission dialogue when the users clicks the back button to return to the search results page and to cover the 'conditional query' ... I used to use a combo of $_GET and if(isset. ie: $query= SELECT something FROM somewhere WHERE etc. etc. etc. AND ; if (isset($_GET['some_value']) $_GET['some_value'] != ''
Re: Query question(s)
If all of your search options are OR conditions, then you could theoretically do something like this: SELECT ... WHERE contents REGEXP '(opt1|opt2|opt3|opt4|opt5|opt6)'; http://dev.mysql.com/doc/refman/5.0/en/regexp.html#operator_regexp On Jun 6, 1:24 pm, Ed Propsner crotchf...@gmail.com wrote: I found a usable solution, a bit exhaustive and long-winded perhaps, but usable nonetheless. I still need to put together a dynamic query and I'm finding myself avoiding having to do it at this time. I need to build a query dynamically based on what elements a user chooses from a form. There could be 20 choices or there could be 2. Every solution I'm coming up with is ridiculously excessive for something that should be so simple. I'm sure the answer is there, I'm just not familiar enough with Cake at this point to see it. - Ed On Sat, Jun 5, 2010 at 4:36 PM, Ed Propsner crotchf...@gmail.com wrote: Perhaps I'm over-complicating this but I'm still having some problems with building my query. I'm looking to do something like: $array = array (A, B, C, D, E); $list = implode( ',' , $array); 'conditions' = array( 'SomeCol.contents' = array($list) ) The problem I'm running into is that $array can contain any number and combination of values (A, C, E), (A, B), (E) ... etc. And 'SomeCol.contents' can also contain any number and combination of values stored as a comma separated string. (it was originally stored as a serialized array). I need the query to return a result if 'SomeCol.contents' and $array have any one of their values in common. I was thinking along the lines of : 'conditions' = array( 'SomeCol.contents LIKE' = '%'.$array[0].'%' OR 'SomeCol.contents LIKE' = '%'.$array[1].'%' etc, etc // this way should include any record in the result that shares a value with $array but I assume I would run into an issue with an undefined index by not knowing how many values $array contains. (I do know it has the potential to store a max of 7 values) I had this all worked out with conventional PHP but now I need to use Paginate and containable with this query as well as a bunch of other conditions (with a set value) and I'm confusing myself more than anything else which isn't a real stretch for me to begin with 8-). Any suggestions are appreciated. Thanks. - Ed On Fri, Jun 4, 2010 at 11:54 PM, Ed Propsner crotchf...@gmail.com wrote: Thanks Calvin, point well taken. I'll just stick with GET like I always have for searches. I tweaked the routing and got things cleaned up a bit so I guess I'm okay with it. I'm not quite sure what I was expecting in the first place? 8-) The search uses a lot of checkboxes and results in something like http://mysite.com/search/results/value1=0value1=1value2=0value2=1. I can't seem to clean it up any more when submitting with GET, or am I still missing something? Anyhow, at least it's working the way that I want it to. I'm still having some issues with query so I'll quit fussing with the url for now. - Ed On Fri, Jun 4, 2010 at 10:15 PM, calvin cal...@rottenrecords.com wrote: POST requests are generally not cached, but you can force it to be cached using the Cache-Control and Expires headers. However, I've never tried this so I don't know if the browser will still show the form submission dialog (it may need to resend the form data to check to see if the document has changed since last requested). It probably won't, but I would still strongly advise against this. A search request is generally an idempotent operation (multiple requests do not have any side-effects), which is precisely what the GET request is designed for. There's no reason to use POST in this case. Cake has a perfectly good way of hiding ugly URL-encoding using its REST-style routing patterns, e.g.: http://yoursite.com/pages/search/foo/bar/foo2/bar2/... You can also use named parameters to make the search URL more readable, e.g.: http://yoursite.com/products/search/q:paegan/artist:acid+bath/categor... Unless you have a ton of search options, I see no reason to use POST. And even if you use POST and generate shorter/cleaner URL--what's the point? What will that clean URL achieve? The user can't bookmark it. They can't link a friend to it. They can't do anything with it. A happy compromise would be to do what a lot of forums do, and cache each search server-side. Then when the user performs a search (with either POST or GET), they get redirected to the cached search result, which might be something like: http://yoursite.com/search/paegan+terrorism+tactics/f83e3a4b389c6b That will decrease your server load, allow you to use a POST form, and still allow the user to
Re: User errors and fat model, skinny controller
I've been using fat model for a while now. It was difficult for me to get over what now appear to insignificant problems but at the time they looked huge. As the model's primary responsibility is to deal with data, I found it useful to always return something more than a boolean. So most of my model functions return a mixed data array. Part of that result array is a status structure which I can then refer to from the controller to display errors or redirect etc. This also allows the model to process a set of data and return an iterative list of errors. As an example I have a csv import which will process the first 100 rows of an import. Each row has the potential of creating an error, and the loop moves on to the next row. all these errors are returned in a single result. The model then passes the file to a background task to process the remainder of the rows. The controller displays via the view to the user the results of the first 100 rows along with the list of errors. I did this because some of these files are huge and would timeout. I can process 100 rows fairly quick and return control back to the user where they can see those newly imported records along with any errors. A second reason for this process is the model code doesn't know if it is being called by human interaction or via a cron script in either case the errors are also written to a logger which the user can review at any point in the app. In a previous post to this thread you mentioned you needed to redirect in certain conditions. Don't get your business logic (model) confused with your application flow (controller). A lighter controller doesn't mean there isn't any logic in those functions it just means there is less logic in them. Logic to control redirects definitely does belong in the controller and your model needs to be able to give enough information back to the controller to make those decisions. I've also found building test for the models is a lot easier than for the controller. If your using test do your best to write the test first. If your not using test, at least think in the mindset of the model code being called from human interaction as well as from a headless script. This will force you to deal with errors in a batch mode instead of one off exceptions. Overall your on the right track your making your model fat and you have identified the model is too deep for direct human interaction. I think there are many ways to deal with this without breaking the MVC pattern. My method explained above may seam too much for some, but having the errors logged and being able to review them has helped in identifying pieces of code which were in need of rework. A type of live profiling. Not so much of the performance but more so on quality and intuitive use or to identify poor assumptions on my part about the ability of my users. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: cakephp
Hey Ats, Please on your debug mode. State it as 2. You can get this in the app/config/core.php so that you can view the actual errors. On Mon, Jun 7, 2010 at 9:48 AM, Ats swamy0...@gmail.com wrote: Hi i am new to cakephp i am getting this error when i am running http://localhost/quickwall/ Error: The requested address '/' was not found on this server. help me to correct this error Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en -- Thanks Regards, Vijayk. You Bring the Dreams, We'll Bring the Means Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: URL is showing wrong
Yes, I understand what the result is, but which code (please show) is the base for the link? Have you defined any routes that may affect this - if yes, then show them too! Which folder is your webroot set to in your web server? Is it the app folder or the app/webroot folder? Enjoy, John On Jun 7, 5:36 pm, Davor Ilic webfa...@gmail.com wrote: this creates link http://my.site/*app/webroot/index.php/*clients/add_client; but i want to tell link to show it without *app/webroot/index.php/ it should look like this url *http://my.site/clients/add_client. thanks 2010/6/7 John Andersen j.andersen...@gmail.com And I were too fast here, sorry for that! What is the code that creates the link? Enjoy, John On Jun 7, 4:28 pm, Davor Ilic webfa...@gmail.com wrote: does anybody else have this issue too? 2010/6/6 Davor Ilic webfa...@gmail.com Hi, my url is this: http://my.site/*app/webroot/index.php/*clients/add_client why is it like this it change after time but can´t say i´ve changed something. i wont to show the link like this with $html-link() : http://my.site/clients/add_client Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions. 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.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Dynamic Navigation (Menu and submenu)
On Jun 7, 10:42 am, calvin cal...@rottenrecords.com wrote: He's laid out pretty much how to implement it yourself (with example code). Why not just follow the article and implement it on your site yourself instead of waiting for someone to hand you a complete plugin for what is a relatively simple task? He said he was tired, though. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Auth Component and user information.
On Jun 7, 11:39 am, saidbakr said@gmail.com wrote: Hi, I use User model to handle user's basic data such as Name, username, password and so on. The User model is associated with Rule model by belongsTo association, while Rule model is associated to User model by hasMany association. The later model Rule is meant by something like users groups so it handles name, description, value and of-course id, for example, two records from rules table: id - 1 name - Administrators description - The super users group! value - ABC id - 2 name - Editors decription - reviewers and articles writers. value - BC In AuthComponent documentation :http://book.cakephp.org/view/247/AuthComponent-Methods#user-387 when they talked about user method of the component, they regards that it is possible to retrieve the current user data from the session in the view like: # $session-read('Auth.User.first_name') //returns particular field value This example shows that the access of User model property first_name. My Question Is, How could I able to access the associated model property Rule such as Rule.name ? Best Regards! You should implement a login() method in your UsersController. In there, do something like: $this-Session-write('Auth.User.foo', 'bar'); When you need to read the info: echo $this-Auth-user('foo'); Basically, Auth::user() simply reads whatever data has been written to the Session's 'Auth.User' key (note the uppercase U). You can also write entire arrays: $this-Session-write('Auth.User.extra', array('foo' = 'bar')); Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: cakephp
On Jun 7, 12:19 pm, Vijay Kumbhar k.vidn...@gmail.com wrote: Hey Ats, Please on your debug mode. State it as 2. You can get this in the app/config/core.php so that you can view the actual errors. Just to add to Vijay's comment: Cake does a 404 redirect whenever it encounters a (non-fatal) error when debug is 0. This is so that errors aren't displayed in production mode. Set the debug to 2 in app/config/ core.php and you should see an error message. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Auth Component and user information.
Well, but what about the data in the associated Model Rules? How could I get it? On Jun 7, 8:27 pm, cricket zijn.digi...@gmail.com wrote: On Jun 7, 11:39 am, saidbakr said@gmail.com wrote: Hi, I use User model to handle user's basic data such as Name, username, password and so on. The User model is associated with Rule model by belongsTo association, while Rule model is associated to User model by hasMany association. The later model Rule is meant by something like users groups so it handles name, description, value and of-course id, for example, two records from rules table: id - 1 name - Administrators description - The super users group! value - ABC id - 2 name - Editors decription - reviewers and articles writers. value - BC In AuthComponent documentation :http://book.cakephp.org/view/247/AuthComponent-Methods#user-387 when they talked about user method of the component, they regards that it is possible to retrieve the current user data from the session in the view like: # $session-read('Auth.User.first_name') //returns particular field value This example shows that the access of User model property first_name. My Question Is, How could I able to access the associated model property Rule such as Rule.name ? Best Regards! You should implement a login() method in your UsersController. In there, do something like: $this-Session-write('Auth.User.foo', 'bar'); When you need to read the info: echo $this-Auth-user('foo'); Basically, Auth::user() simply reads whatever data has been written to the Session's 'Auth.User' key (note the uppercase U). You can also write entire arrays: $this-Session-write('Auth.User.extra', array('foo' = 'bar')); Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Auth Component and user information.
I also noticed another thing: The output of $this-Auth-user() ,without key parameter, is an array which is listing User model only without regarding the associated model. Array ( [User] = Array ( [id] = 1 [username] = admin [name] = Said Bakr [join_date] = 2010-06-14 19:35:00 [email] = said@gmail.com [rule_id] = 1 ) ) On Jun 7, 8:27 pm, cricket zijn.digi...@gmail.com wrote: On Jun 7, 11:39 am, saidbakr said@gmail.com wrote: Hi, I use User model to handle user's basic data such as Name, username, password and so on. The User model is associated with Rule model by belongsTo association, while Rule model is associated to User model by hasMany association. The later model Rule is meant by something like users groups so it handles name, description, value and of-course id, for example, two records from rules table: id - 1 name - Administrators description - The super users group! value - ABC id - 2 name - Editors decription - reviewers and articles writers. value - BC In AuthComponent documentation :http://book.cakephp.org/view/247/AuthComponent-Methods#user-387 when they talked about user method of the component, they regards that it is possible to retrieve the current user data from the session in the view like: # $session-read('Auth.User.first_name') //returns particular field value This example shows that the access of User model property first_name. My Question Is, How could I able to access the associated model property Rule such as Rule.name ? Best Regards! You should implement a login() method in your UsersController. In there, do something like: $this-Session-write('Auth.User.foo', 'bar'); When you need to read the info: echo $this-Auth-user('foo'); Basically, Auth::user() simply reads whatever data has been written to the Session's 'Auth.User' key (note the uppercase U). You can also write entire arrays: $this-Session-write('Auth.User.extra', array('foo' = 'bar')); Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Strange error after model save method
Hello. I was creating an add form for a model called Practitioner. Everything seems to work fine, after submitting the form changes are saved successfully in Practitioner table and in every table related to Practitioner model, but a weird error is showing up that's claiming for a rght field in my Practitioner model, and I don't know what this rght field stands for and it isn't in any of my tables. Any suggestions are greatly appreciated. This is the error I get: Warning (512): SQL Error: 1054: Unknown column 'Practitioner.rght' in 'field list' [CORE/cake/libs/model/datasources/dbo_source.php, line 666] Code | Context $out = null; if ($error) { trigger_error('span style=color:Red;text- align:leftb' . __('SQL Error:', true) . /b {$this-error}/ span, E_USER_WARNING); $sql= SELECT MAX(`Practitioner`.`rght`) AS `rght` FROM `practitioners` AS `Practitioner` WHERE 1 = 1LIMIT 1 $error = 1054: Unknown column 'Practitioner.rght' in 'field list' $out= null DboSource::showQuery() - CORE/cake/libs/model/datasources/ dbo_source.php, line 666 DboSource::execute() - CORE/cake/libs/model/datasources/ dbo_source.php, line 256 DboSource::fetchAll() - CORE/cake/libs/model/datasources/ dbo_source.php, line 400 DboSource::read() - CORE/cake/libs/model/datasources/dbo_source.php, line 805 Model::find() - CORE/cake/libs/model/model.php, line 2093 AppModel::find() - APP/app_model.php, line 40 TreeBehavior::__getMax() - CORE/cake/libs/model/behaviors/tree.php, line 904 TreeBehavior::beforeSave() - CORE/cake/libs/model/behaviors/tree.php, line 157 ModelBehavior::dispatchMethod() - CORE/cake/libs/model/ model_behavior.php, line 169 BehaviorCollection::trigger() - CORE/cake/libs/model/ model_behavior.php, line 494 Model::save() - CORE/cake/libs/model/model.php, line 1284 PractitionersController::admin_add() - APP/controllers/ practitioners_controller.php, line 650 Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 204 Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171 [main] - APP/webroot/index.php, line 83 Query: SELECT MAX(`Practitioner`.`rght`) AS `rght` FROM `practitioners` AS `Practitioner` WHERE 1 = 1 LIMIT 1 Warning (2): array_values() expects parameter 1 to be array, boolean given [CORE/cake/libs/model/behaviors/tree.php, line 904] Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Auth Component and user information.
I think the point is that as part of your log in process you scrape information from your associated model and add it to the User array. You could also do an update if the associated model data was changed, I guess. Jeremy Burns jeremybu...@me.com On 7 Jun 2010, at 19:33, saidbakr wrote: I also noticed another thing: The output of $this-Auth-user() ,without key parameter, is an array which is listing User model only without regarding the associated model. Array ( [User] = Array ( [id] = 1 [username] = admin [name] = Said Bakr [join_date] = 2010-06-14 19:35:00 [email] = said@gmail.com [rule_id] = 1 ) ) On Jun 7, 8:27 pm, cricket zijn.digi...@gmail.com wrote: On Jun 7, 11:39 am, saidbakr said@gmail.com wrote: Hi, I use User model to handle user's basic data such as Name, username, password and so on. The User model is associated with Rule model by belongsTo association, while Rule model is associated to User model by hasMany association. The later model Rule is meant by something like users groups so it handles name, description, value and of-course id, for example, two records from rules table: id - 1 name - Administrators description - The super users group! value - ABC id - 2 name - Editors decription - reviewers and articles writers. value - BC In AuthComponent documentation :http://book.cakephp.org/view/247/AuthComponent-Methods#user-387 when they talked about user method of the component, they regards that it is possible to retrieve the current user data from the session in the view like: # $session-read('Auth.User.first_name') //returns particular field value This example shows that the access of User model property first_name. My Question Is, How could I able to access the associated model property Rule such as Rule.name ? Best Regards! You should implement a login() method in your UsersController. In there, do something like: $this-Session-write('Auth.User.foo', 'bar'); When you need to read the info: echo $this-Auth-user('foo'); Basically, Auth::user() simply reads whatever data has been written to the Session's 'Auth.User' key (note the uppercase U). You can also write entire arrays: $this-Session-write('Auth.User.extra', array('foo' = 'bar')); Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Auth Component and user information.
On Jun 7, 2:19 pm, saidbakr said@gmail.com wrote: Well, but what about the data in the associated Model Rules? How could I get it? The AuthComponent does not require anything in the User::login() method. However, if you wish to run some code upon login, you implement it there. public function login() { if ($user = $this-Auth-user()) { /* fetch and store your associated data */ $this-Session-write( 'Auth.User.whatever', $this-User-find(...) ); $this-redirect($this-Auth-loginRedirect); } } Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: I'm trying to make a good find with three HABTM models
Oooh! That's pretty awesome, and it seems to work like a charm, thanks! Just one more question on this subject. This involves a bit more trickery I believe; I'd also like to be able to view all the Groups/Users for all the projects I'm involved at. This would look something like [Project 1] [Group 1] [User 2] [User 3] [User 4] [Group 10] [User 1] [User 3] [Project 2] [Group 25] [User 1] [User 3] [User 7] Now, the information about what projects I'm involved at is stored in projects_users. I guess I somehow have to use this information to be able to present it in the above described way? Otherwise I'm not sure as to how I could first filter out all the projects I'm involved with and then go hunt for the groups and users. Any insights on this matter is really appreciated. Thank you in advance! On Jun 7, 3:26 pm, vekija vedran.konto...@gmail.com wrote: You can try Containable behavior. In models put var $actsAs = array('Containable'); and then in the controller $this-Project-find('all', array('contain' = array('Group' = array('User'; you can find out more about the Containable behavior in the cook bookhttp://book.cakephp.org/view/1323/Containable On Jun 7, 2:54 pm, DrLaban jbh...@gmail.com wrote: My setup is pretty straightforward; User HABTM Group Group HABTM Project Project HABTM User I would like to produce a find-query that takes a single project-id and builds a hierarchic contact list, in which the users belong to their respective group(s). Something along these lines: [Project 1] [Group 1] [User 1] [User 5] [Group 2] [User 1] [User 2] [User 3] [Group 4] [User 3] [User 4] ... Is this possible and if so, how? All I've been able to produce is something of a flat structure where I can't match the user to a group; [Project 1] [User 1] [User 3] [User 4] [User 6] [Group 1] [Group 3] [Group 4] This is produced when I do; $this-Project-find('all'); Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Auth Component and user information.
On Jun 7, 2:33 pm, saidbakr said@gmail.com wrote: I also noticed another thing: The output of $this-Auth-user() ,without key parameter, is an array which is listing User model only without regarding the associated model. Look at the API: http://api.cakephp.org/class/auth-component#method-AuthComponentuser Parameters: $keystring field to retrive. Leave null to get entire User record optionalNULL if ($key == null) { $model = $this-getModel(); return array($model-alias = $this-Session-read($this- sessionKey)); } else { And, of course, $this-sessionKey cannot be some arbitrary string that the component doesn't know about. It can't read your mind so it defaults to what it knows. Namely, 'Auth.User'. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: cakephp
On Jun 7, 12:18 am, Ats swamy0...@gmail.com wrote: Hi i am new to cakephp i am getting this error when i am runninghttp://localhost/quickwall/ Error: The requested address '/' was not found on this server. help me to correct this error BTW, in the future, please use a subject line that's a bit more informative than cakephp. It would be very difficult to follow threads if everyone just used the name of the group as a subject. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Query question(s)
@John: [quote] Can you explain why you have not separated/normalized the SomeCol.contents? And do you have other such columns in your database? [/quote] No, that is the only column in the db that stores multiple values in one field (that aren't for display only). At one point in time the data in that column wasn't searchable and it never presented an issue. A little hard to explain but even though there are separate values, with the exception of the recently added query they get treated as a whole within the app. I figured that if the app ever changes down the road and needs to handle the values individually it would be easy enough to explode the data. So to answer your question of why? To be honest ... I thought I had good enough reasons but in the end I suppose I didn't think it through well enough or far enough ahead. If need be a restructuring of the db is not out of the question I just assumed it wouldn't be a real stretch to come up with a creative solution which ultimately ended up being the case. Just for the record, I do recognize that a 'creative' solution is not always the best solution 8-). @Calvin: About the queries ... there was a basic and an advanced. The basic is done and working. With the advanced search since I don't know fields elements are being submitted for the search I would normally concatenate the query itself. [example] $query= SELECT something FROM somewhere WHERE etc. etc. etc. ; if (isset($_GET['some_value']) $_GET['some_value'] != '' ) { $value = $_GET['some_value']; $query .= AND something = '.addslashes($value).'; } if (isset($_GET['some_other_value']) $_GET['some_other_value'] != '' ) { $value = $_GET['some_other_value']; $query .= AND something = '.addslashes($value).'; } $query .= WHERE some_col = some_criteria mysql_query($query); [/example] This worked well enough in the past. I agree that if the conditions were all 'OR' I would be good to go, unfortunately they all need to be 'AND'. The closest example I can find in the book ( http://book.cakephp.org/view/1030/Complex-Find-Conditions ) that seems even remotely close would be $dbo-buildStatement but to be brutally honest I have no clue how I would implement that (or something similar) in this case. Cake will accept the query whichever way I present it but the real problem lies in 'paginate' and 'containable', both of which I need. I suppose both could be written manually but then I would be well off the beaten path as far as Cake conventions and given my track record it would undoubtedly create some unforeseen problem somewhere down the line. As far as URL-encoded array data goes I just set the form method to GET and let Cake do it's thing. In the controller I pull the data from the URL using $this-params['url']['something']. If you are saying I can configure the routes to convert it over to named params I'll play around with it some more. The furthest I experimenting I've done with routes is to change from mySite/thisIsMyPage to my-site/this-is-my-page. - Ed On Mon, Jun 7, 2010 at 11:55 AM, calvin cal...@rottenrecords.com wrote: If all of your search options are OR conditions, then you could theoretically do something like this: SELECT ... WHERE contents REGEXP '(opt1|opt2|opt3|opt4|opt5|opt6)'; http://dev.mysql.com/doc/refman/5.0/en/regexp.html#operator_regexp On Jun 6, 1:24 pm, Ed Propsner crotchf...@gmail.com wrote: I found a usable solution, a bit exhaustive and long-winded perhaps, but usable nonetheless. I still need to put together a dynamic query and I'm finding myself avoiding having to do it at this time. I need to build a query dynamically based on what elements a user chooses from a form. There could be 20 choices or there could be 2. Every solution I'm coming up with is ridiculously excessive for something that should be so simple. I'm sure the answer is there, I'm just not familiar enough with Cake at this point to see it. - Ed On Sat, Jun 5, 2010 at 4:36 PM, Ed Propsner crotchf...@gmail.com wrote: Perhaps I'm over-complicating this but I'm still having some problems with building my query. I'm looking to do something like: $array = array (A, B, C, D, E); $list = implode( ',' , $array); 'conditions' = array( 'SomeCol.contents' = array($list) ) The problem I'm running into is that $array can contain any number and combination of values (A, C, E), (A, B), (E) ... etc. And 'SomeCol.contents' can also contain any number and combination of values stored as a comma separated string. (it was originally stored as a serialized array). I need the query to return a result if 'SomeCol.contents' and $array have any one of their values in common. I was thinking along the lines of : 'conditions' = array( 'SomeCol.contents LIKE' = '%'.$array[0].'%'
Re: Strange error after model save method
Are you using a custom Join statement in your query, particularly a RIGHT JOIN? On Mon, Jun 7, 2010 at 2:34 PM, Roland Pish rolandp...@gmail.com wrote: Hello. I was creating an add form for a model called Practitioner. Everything seems to work fine, after submitting the form changes are saved successfully in Practitioner table and in every table related to Practitioner model, but a weird error is showing up that's claiming for a rght field in my Practitioner model, and I don't know what this rght field stands for and it isn't in any of my tables. Any suggestions are greatly appreciated. This is the error I get: Warning (512): SQL Error: 1054: Unknown column 'Practitioner.rght' in 'field list' [CORE/cake/libs/model/datasources/dbo_source.php, line 666] Code | Context $out = null; if ($error) { trigger_error('span style=color:Red;text- align:leftb' . __('SQL Error:', true) . /b {$this-error}/ span, E_USER_WARNING); $sql= SELECT MAX(`Practitioner`.`rght`) AS `rght` FROM `practitioners` AS `Practitioner` WHERE 1 = 1LIMIT 1 $error = 1054: Unknown column 'Practitioner.rght' in 'field list' $out= null DboSource::showQuery() - CORE/cake/libs/model/datasources/ dbo_source.php, line 666 DboSource::execute() - CORE/cake/libs/model/datasources/ dbo_source.php, line 256 DboSource::fetchAll() - CORE/cake/libs/model/datasources/ dbo_source.php, line 400 DboSource::read() - CORE/cake/libs/model/datasources/dbo_source.php, line 805 Model::find() - CORE/cake/libs/model/model.php, line 2093 AppModel::find() - APP/app_model.php, line 40 TreeBehavior::__getMax() - CORE/cake/libs/model/behaviors/tree.php, line 904 TreeBehavior::beforeSave() - CORE/cake/libs/model/behaviors/tree.php, line 157 ModelBehavior::dispatchMethod() - CORE/cake/libs/model/ model_behavior.php, line 169 BehaviorCollection::trigger() - CORE/cake/libs/model/ model_behavior.php, line 494 Model::save() - CORE/cake/libs/model/model.php, line 1284 PractitionersController::admin_add() - APP/controllers/ practitioners_controller.php, line 650 Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 204 Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171 [main] - APP/webroot/index.php, line 83 Query: SELECT MAX(`Practitioner`.`rght`) AS `rght` FROM `practitioners` AS `Practitioner` WHERE 1 = 1 LIMIT 1 Warning (2): array_values() expects parameter 1 to be array, boolean given [CORE/cake/libs/model/behaviors/tree.php, line 904] Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Strange error after model save method
On Jun 7, 3:20 pm, Ed Propsner crotchf...@gmail.com wrote: Are you using a custom Join statement in your query, particularly a RIGHT JOIN? On Mon, Jun 7, 2010 at 2:34 PM, Roland Pish rolandp...@gmail.com wrote: Hello. I was creating an add form for a model called Practitioner. Everything seems to work fine, after submitting the form changes are saved successfully in Practitioner table and in every table related to Practitioner model, but a weird error is showing up that's claiming for a rght field in my Practitioner model, and I don't know what this rght field stands for and it isn't in any of my tables. Any suggestions are greatly appreciated. This is the error I get: Warning (512): SQL Error: 1054: Unknown column 'Practitioner.rght' in 'field list' [CORE/cake/libs/model/datasources/dbo_source.php, line 666] It looks to me like you have $actsAs = array('Tree') in your model. The rght and lft column names are used for the right left fields when using MPTT ordering. I imagine that TreeBehavior is attempting to order your records but the table doesn't have those columns. http://www.ad7six.com/entries/view/56/Working-with-Tree-data-%28MPTT%29 Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Strange error after model save method
Looks like Cricket knows what the deal is. I suggested the custom join because I messed one up once and it ended up looking for a column named 'right'. 8-) On Mon, Jun 7, 2010 at 3:30 PM, cricket zijn.digi...@gmail.com wrote: On Jun 7, 3:20 pm, Ed Propsner crotchf...@gmail.com wrote: Are you using a custom Join statement in your query, particularly a RIGHT JOIN? On Mon, Jun 7, 2010 at 2:34 PM, Roland Pish rolandp...@gmail.com wrote: Hello. I was creating an add form for a model called Practitioner. Everything seems to work fine, after submitting the form changes are saved successfully in Practitioner table and in every table related to Practitioner model, but a weird error is showing up that's claiming for a rght field in my Practitioner model, and I don't know what this rght field stands for and it isn't in any of my tables. Any suggestions are greatly appreciated. This is the error I get: Warning (512): SQL Error: 1054: Unknown column 'Practitioner.rght' in 'field list' [CORE/cake/libs/model/datasources/dbo_source.php, line 666] It looks to me like you have $actsAs = array('Tree') in your model. The rght and lft column names are used for the right left fields when using MPTT ordering. I imagine that TreeBehavior is attempting to order your records but the table doesn't have those columns. http://www.ad7six.com/entries/view/56/Working-with-Tree-data-%28MPTT%29 Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: I'm trying to make a good find with three HABTM models
The easiest way that comes to mine mind would be to get the ids of the projects you are involved at first and then pass those as condition in the before mentioned find call. Something like... $this-loadModel('ProjectsUser'); $ids = $this-ProjectsUser-find('list', array('conditions' = array('ProjectsUser.user_id = $yourId))); $projects = $this-Project-find('all', array( 'contain' = array( 'Group' = array('User') ), 'conditions = array('Project.id' = array_keys($ids)) )); there are probably other ways of doing this, but I would have to think and test before I recommend them. :) Cheers On Jun 7, 9:03 pm, DrLaban jbh...@gmail.com wrote: Oooh! That's pretty awesome, and it seems to work like a charm, thanks! Just one more question on this subject. This involves a bit more trickery I believe; I'd also like to be able to view all the Groups/Users for all the projects I'm involved at. This would look something like [Project 1] [Group 1] [User 2] [User 3] [User 4] [Group 10] [User 1] [User 3] [Project 2] [Group 25] [User 1] [User 3] [User 7] Now, the information about what projects I'm involved at is stored in projects_users. I guess I somehow have to use this information to be able to present it in the above described way? Otherwise I'm not sure as to how I could first filter out all the projects I'm involved with and then go hunt for the groups and users. Any insights on this matter is really appreciated. Thank you in advance! On Jun 7, 3:26 pm, vekija vedran.konto...@gmail.com wrote: You can try Containable behavior. In models put var $actsAs = array('Containable'); and then in the controller $this-Project-find('all', array('contain' = array('Group' = array('User'; you can find out more about the Containable behavior in the cook bookhttp://book.cakephp.org/view/1323/Containable On Jun 7, 2:54 pm, DrLaban jbh...@gmail.com wrote: My setup is pretty straightforward; User HABTM Group Group HABTM Project Project HABTM User I would like to produce a find-query that takes a single project-id and builds a hierarchic contact list, in which the users belong to their respective group(s). Something along these lines: [Project 1] [Group 1] [User 1] [User 5] [Group 2] [User 1] [User 2] [User 3] [Group 4] [User 3] [User 4] ... Is this possible and if so, how? All I've been able to produce is something of a flat structure where I can't match the user to a group; [Project 1] [User 1] [User 3] [User 4] [User 6] [Group 1] [Group 3] [Group 4] This is produced when I do; $this-Project-find('all'); Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Stop Auth component from redirecting
How can I stop the auth component from redirecting? Currently, when I make an ajax call, and the user isn't allowed to the requested action, cake redirects to the index of the requested controller. I want to know how I can stop it from redirecting so I can pop up an error message. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Stop Auth component from redirecting
If I'm following you correctly you could use $this-Auth-autoRedirect = false; On Mon, Jun 7, 2010 at 4:11 PM, junker37 junke...@gmail.com wrote: How can I stop the auth component from redirecting? Currently, when I make an ajax call, and the user isn't allowed to the requested action, cake redirects to the index of the requested controller. I want to know how I can stop it from redirecting so I can pop up an error message. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Saving A User, Their Profile, and Some Tags At The Same Time
I'm putting together a database of instructors and I'm having a little trouble with saving my associated models. My tables are 'users', 'instructors', 'subjects', and 'instructors_subjects'. My model User hasOne Instructor. My model Instructor hasAndBelongsToMany Subjects. My function looks like this: function instructor_register() { $this-set('states', $this-User-Instructor-State- find('list')); if (!empty($this-data)) { // Set the group to Instructor $this-data['User']['group_id'] = 2; // Save the user data $user = $this-User-save($this-data, true, array( 'username', 'password', 'group_id' )); // If the user was saved, save the instructor's info if (!empty($user)) { $this-data['Instructor']['user_id'] = $this-User- id; $instructor = $this-User-Instructor-save($this- data, true, array( 'user_id', 'name', 'email', 'phone', 'city', 'zip_code', 'state_id', 'website', 'description' )); // If the instructor was saved, save the rest if(!empty($instructor)) { $instructorId = $this-User-Instructor-id; $this-data['Instructor']['id'] = $instructorId; // Save each subject seperately $subjects = explode(,, $this-data['Subject'] ['name']); foreach ($subjects as $_subject) { // Get the correct subject format $_subject = strtolower(trim($_subject)); $this-User-Instructor-Subject-create($this- data); $this-User-Instructor-Subject-set(array( 'name' = $_subject )); $this-User-Instructor-Subject-save(); } } } } } My data looks like this: Array ( [User] = Array ( [username] = MrInstructor [password] = cddb06c93c72f34eb9408610529a34645c29c55d [group_id] = 2 ) [Instructor] = Array ( [name] = Jimmy Bob [email] = j...@gmail.com [phone] = 111222 [city] = Beverly Hills [zip_code] = 90210 [states] = 5 [website] = www.jimmybobschool.com [description] = Jimmy Box is an instructor. [user_id] = 1 [id] = 1 ) [Subject] = Array ( [name] = hitting, pitching ) ) Array ( [0] = hitting [1] = pitching ) For some reason my join table for Instructors and Subjects (instructors_subjects) has a bunch of extra entries. There's an entry for both hitting and pitching that is correct with the proper instructor_id and the subject_id. But, then there's a bunch of entries where the instructor_id is either the phone number, the zip code, or the user id. Anyone know why these other fields are getting confused as instructor_id's? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Model with two belongsTo associations
Hi all, I've been working on this for a while and searching for a solution, but can't seem to get it working correctly. Let's say I have Category, Label, and Item models with the following associations: Category hasMany Items Item belongsTo Category Label hasMany Items Item belongsTo Label So, Categories and Labels are completely unrelated, but the Item belongs to both of them. Now, in my Category view (and Category controller) I want to display the Cateogry info (obviously) and a list of all of that Category's Items. So far so good. However, what I'd also like is, for each Item that is listed, to display that Item's associated Label. Something like: Category 1 Item 1 (Label for Item 1) Item 2 (Label for Item 2) Category 2 Item 3 (Label for Item 3) I've tried different combinations of recursion (on all three models) and I've tried using the containable behavior but I can't seem to get the Label data to be included. The label data appears fine when I'm working with the Item views and controller, but when I'm up one level higher (in the context of a Category) they aren't attached. Any thoughts on this? Thanks! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Model with two belongsTo associations
It should work with Containable behavior. for example $categories = $this-Category-find('all', array('contain' = array('Item' = array('Label'; should return an array like: Category 1 Item 1 Label 1 Item 2 Label 2 Category 2 Item 3 Label 3 On Jun 7, 10:17 pm, bmcelhany bmcelh...@gmail.com wrote: Hi all, I've been working on this for a while and searching for a solution, but can't seem to get it working correctly. Let's say I have Category, Label, and Item models with the following associations: Category hasMany Items Item belongsTo Category Label hasMany Items Item belongsTo Label So, Categories and Labels are completely unrelated, but the Item belongs to both of them. Now, in my Category view (and Category controller) I want to display the Cateogry info (obviously) and a list of all of that Category's Items. So far so good. However, what I'd also like is, for each Item that is listed, to display that Item's associated Label. Something like: Category 1 Item 1 (Label for Item 1) Item 2 (Label for Item 2) Category 2 Item 3 (Label for Item 3) I've tried different combinations of recursion (on all three models) and I've tried using the containable behavior but I can't seem to get the Label data to be included. The label data appears fine when I'm working with the Item views and controller, but when I'm up one level higher (in the context of a Category) they aren't attached. Any thoughts on this? Thanks! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Model with two belongsTo associations
Ah, I didn't realize you could nest models within a single contain...good to know! So, I gave that a shot and it works perfectly...just what I need! One additional question: I notice that for each Item there is an additional query performed to get that Item's Label information. I'm not dealing with a huge amount of data so I'm not too concerned, but it would be nice if I could maybe get the Label info via a join to the Item, cutting the number of queries in half. In fact, most likely, any time I need an Item I'm going to need it's associated Label as well. Any way I could modify the Item model and tell it to always load it's associated Label? Or am I better off just doing it via contain and leaving well enough alone? Thanks for your quick response! On Jun 7, 1:23 pm, vekija vedran.konto...@gmail.com wrote: It should work with Containable behavior. for example $categories = $this-Category-find('all', array('contain' = array('Item' = array('Label'; should return an array like: Category 1 Item 1 Label 1 Item 2 Label 2 Category 2 Item 3 Label 3 On Jun 7, 10:17 pm, bmcelhany bmcelh...@gmail.com wrote: Hi all, I've been working on this for a while and searching for a solution, but can't seem to get it working correctly. Let's say I have Category, Label, and Item models with the following associations: Category hasMany Items Item belongsTo Category Label hasMany Items Item belongsTo Label So, Categories and Labels are completely unrelated, but the Item belongs to both of them. Now, in my Category view (and Category controller) I want to display the Cateogry info (obviously) and a list of all of that Category's Items. So far so good. However, what I'd also like is, for each Item that is listed, to display that Item's associated Label. Something like: Category 1 Item 1 (Label for Item 1) Item 2 (Label for Item 2) Category 2 Item 3 (Label for Item 3) I've tried different combinations of recursion (on all three models) and I've tried using the containable behavior but I can't seem to get the Label data to be included. The label data appears fine when I'm working with the Item views and controller, but when I'm up one level higher (in the context of a Category) they aren't attached. Any thoughts on this? Thanks! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
cakePHP - ACL tutorial SQL Error: 1104
Greetings! I run into a problem/bug in production environment with SQL Error: 1104 when deploying a project secured with the ACL tutorial. The full error: SQL Error: 1104: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay [CORE/cake/libs/model/ datasources/dbo_source.php, line 666] I've build a small site, worked through the ACL tutorial from the official cake book and locally everything is spiffy. dev. setup consists of: XAMPP: myslq 5.1.33, php 5.3 cakePHP 1.2.7 prod. setup: mysql 5.0.33 php 5.2.2 One of the differences I noticed with mysql setup between local and production servers, is that SQL_BIG_SELECTS is disabled on the production server ( and I don't have privileges to change that, posted a support ticked, didn't hear anything yet) Is there anything I can do about this from my end? Thanks in advance. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Using Javascript-link Inside An Element
I'm pretty new to CakePHP so it is likely that my issue is rather simple to fix. I have a custom element which I created called nav_menu.cpt. I call this element from default.cpt using: ?php echo $this-element('nav_menu'); ? For my element to work properly, I need to import 3x .js files and 1x .css file; I have placed these files in /webroot/js/ and /webroot/ css/ respectively and am attempting to call them inside the element like so: ?php $javascript-link('mootools-for-dropdown', false); $javascript-link('UvumiDropdown-compressed', false); $javascript-link('nav_menu', false); $html-css('uvumi-dropdown'); ? However, when the page loads and I check page source, it doesn't include these files in the header. I've also tried calling this following line in default.cpt with no success: ?php e($scripts_for_layout); ? What am I doing wrong?? Thanks, Dima Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: cakephp
This sounds like an issue with the router which is located at /config/ routes.php Try adding the following line into that file: Router::connect('/', array('controller' = 'questions', 'action' = 'home')); This will tell CakePHP that if you go to localhost/ it will take you to the questions controller and the home action. I just finished going through the quickwall tutorial myself and had this issue :) In case this doesn't work, try playing around with that line and giving it different parameters based on how you set your app folder up. Dima On Jun 6, 11:18 pm, Ats swamy0...@gmail.com wrote: Hi i am new to cakephp i am getting this error when i am runninghttp://localhost/quickwall/ Error: The requested address '/' was not found on this server. help me to correct this error Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Optional Validation
How do you set Cake validation to only verify the rules IF there is content. If the field is left blank (optional field), skip validation. e.g. var $validate = array( 'state' = array( 'rule' = '/^[a-z]{2}$/i', // 2 letters 'message' = 'You must enter a valid state.' ) ); This always runs, even if the content of the field is left blank. I want it to skip validation if the field is left blank. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Optional Validation
just add 'allowEmpty' = true to the 'state' array On Jun 7, 10:51 pm, naidim nai...@gmail.com wrote: How do you set Cake validation to only verify the rules IF there is content. If the field is left blank (optional field), skip validation. e.g. var $validate = array( 'state' = array( 'rule' = '/^[a-z]{2}$/i', // 2 letters 'message' = 'You must enter a valid state.' ) ); This always runs, even if the content of the field is left blank. I want it to skip validation if the field is left blank. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Using Javascript-link Inside An Element
you have to echo those :) echo $javascript-link('mootools-for-dropdown', false); On Jun 7, 8:43 pm, Dima dmitriy.pind...@gmail.com wrote: I'm pretty new to CakePHP so it is likely that my issue is rather simple to fix. I have a custom element which I created called nav_menu.cpt. I call this element from default.cpt using: ?php echo $this-element('nav_menu'); ? For my element to work properly, I need to import 3x .js files and 1x .css file; I have placed these files in /webroot/js/ and /webroot/ css/ respectively and am attempting to call them inside the element like so: ?php $javascript-link('mootools-for-dropdown', false); $javascript-link('UvumiDropdown-compressed', false); $javascript-link('nav_menu', false); $html-css('uvumi-dropdown'); ? However, when the page loads and I check page source, it doesn't include these files in the header. I've also tried calling this following line in default.cpt with no success: ?php e($scripts_for_layout); ? What am I doing wrong?? Thanks, Dima Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Model with two belongsTo associations
hmm, not sure... you could always write your own query or/and implement caching, depends on the load on you application. On Jun 7, 10:42 pm, bmcelhany bmcelh...@gmail.com wrote: Ah, I didn't realize you could nest models within a single contain...good to know! So, I gave that a shot and it works perfectly...just what I need! One additional question: I notice that for each Item there is an additional query performed to get that Item's Label information. I'm not dealing with a huge amount of data so I'm not too concerned, but it would be nice if I could maybe get the Label info via a join to the Item, cutting the number of queries in half. In fact, most likely, any time I need an Item I'm going to need it's associated Label as well. Any way I could modify the Item model and tell it to always load it's associated Label? Or am I better off just doing it via contain and leaving well enough alone? Thanks for your quick response! On Jun 7, 1:23 pm, vekija vedran.konto...@gmail.com wrote: It should work with Containable behavior. for example $categories = $this-Category-find('all', array('contain' = array('Item' = array('Label'; should return an array like: Category 1 Item 1 Label 1 Item 2 Label 2 Category 2 Item 3 Label 3 On Jun 7, 10:17 pm, bmcelhany bmcelh...@gmail.com wrote: Hi all, I've been working on this for a while and searching for a solution, but can't seem to get it working correctly. Let's say I have Category, Label, and Item models with the following associations: Category hasMany Items Item belongsTo Category Label hasMany Items Item belongsTo Label So, Categories and Labels are completely unrelated, but the Item belongs to both of them. Now, in my Category view (and Category controller) I want to display the Cateogry info (obviously) and a list of all of that Category's Items. So far so good. However, what I'd also like is, for each Item that is listed, to display that Item's associated Label. Something like: Category 1 Item 1 (Label for Item 1) Item 2 (Label for Item 2) Category 2 Item 3 (Label for Item 3) I've tried different combinations of recursion (on all three models) and I've tried using the containable behavior but I can't seem to get the Label data to be included. The label data appears fine when I'm working with the Item views and controller, but when I'm up one level higher (in the context of a Category) they aren't attached. Any thoughts on this? Thanks! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Using Javascript-link Inside An Element
vekija, thanks a ton for your help!! I added echo in front of all 4 of the lines in nav_menu.cpt. I was immediately able to see the style sheets kick in; however, when I look at page source, it still doesn't show those files in the page header and is not displaying correctly. Am I using the ?php e($scripts_for_layout); ? correctly? Does it have to go before/after a certain point in the header? Thanks again, Dima On Jun 7, 4:10 pm, vekija vedran.konto...@gmail.com wrote: you have to echo those :) echo $javascript-link('mootools-for-dropdown', false); On Jun 7, 8:43 pm, Dima dmitriy.pind...@gmail.com wrote: I'm pretty new to CakePHP so it is likely that my issue is rather simple to fix. I have a custom element which I created called nav_menu.cpt. I call this element from default.cpt using: ?php echo $this-element('nav_menu'); ? For my element to work properly, I need to import 3x .js files and 1x .css file; I have placed these files in /webroot/js/ and /webroot/ css/ respectively and am attempting to call them inside the element like so: ?php $javascript-link('mootools-for-dropdown', false); $javascript-link('UvumiDropdown-compressed', false); $javascript-link('nav_menu', false); $html-css('uvumi-dropdown'); ? However, when the page loads and I check page source, it doesn't include these files in the header. I've also tried calling this following line in default.cpt with no success: ?php e($scripts_for_layout); ? What am I doing wrong?? Thanks, Dima Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Using Javascript-link Inside An Element
You only use echo when you're linking them inline. So you would never have something like: echo $javascript-link($scriptname, false); It would either be: echo $javascript-link($scriptname); or: $javascript-link($scriptname, false); Unfortunately, you can't use the $scripts_for_layout variable in the layout or elements included from the layout because usually by that point the variable has already been printed out. Your best bet would be to just place inline link calls in the header section of the layout. On Jun 7, 2:51 pm, Dima dmitriy.pind...@gmail.com wrote: vekija, thanks a ton for your help!! I added echo in front of all 4 of the lines in nav_menu.cpt. I was immediately able to see the style sheets kick in; however, when I look at page source, it still doesn't show those files in the page header and is not displaying correctly. Am I using the ?php e($scripts_for_layout); ? correctly? Does it have to go before/after a certain point in the header? Thanks again, Dima On Jun 7, 4:10 pm, vekija vedran.konto...@gmail.com wrote: you have to echo those :) echo $javascript-link('mootools-for-dropdown', false); On Jun 7, 8:43 pm, Dima dmitriy.pind...@gmail.com wrote: I'm pretty new to CakePHP so it is likely that my issue is rather simple to fix. I have a custom element which I created called nav_menu.cpt. I call this element from default.cpt using: ?php echo $this-element('nav_menu'); ? For my element to work properly, I need to import 3x .js files and 1x .css file; I have placed these files in /webroot/js/ and /webroot/ css/ respectively and am attempting to call them inside the element like so: ?php $javascript-link('mootools-for-dropdown', false); $javascript-link('UvumiDropdown-compressed', false); $javascript-link('nav_menu', false); $html-css('uvumi-dropdown'); ? However, when the page loads and I check page source, it doesn't include these files in the header. I've also tried calling this following line in default.cpt with no success: ?php e($scripts_for_layout); ? What am I doing wrong?? Thanks, Dima Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Query question(s)
I don't think you need buildStatement() in this case as your query, although long, shouldn't actually be that complex, even if you end up with both OR and AND conditions. You just need to take a look at how OR/AND conditions are constructed in find() and then use them to build custom pagination queries: http://book.cakephp.org/view/249/Custom-Query-Pagination Also, I did a test on GET forms using cake, and it should still create URLs like: /search?var1[]=0var1[]=1... How are you creating the checkboxes? A good way to do it is: echo $this-Form-input('type', array( 'type' = 'select', 'multiple' = 'checkbox', 'options' = array( '1' = 'Video', '2' = 'Audio', '4' = 'Photo', '8' = 'Text', ) )); Also, notice that I use multiples of 2 for the option values. This allows you to perform bitwise operations when querying the database. When you save, you just call array_sum() and turn the array into an integer, and save to a tinyint field. And when you do a search, you can just create a simple query like: array( 'or' = array( 'Model.type | '.$orOptions, 'Model.type '.$andOptions ) ); This circumvents the problem of building long queries using LIKE. I would strongly advise against hand-building the SQL, especially in this case as your search query isn't so complex that you can't have Cake build it for you. On Jun 7, 12:14 pm, Ed Propsner crotchf...@gmail.com wrote: @John: [quote] Can you explain why you have not separated/normalized the SomeCol.contents? And do you have other such columns in your database? [/quote] No, that is the only column in the db that stores multiple values in one field (that aren't for display only). At one point in time the data in that column wasn't searchable and it never presented an issue. A little hard to explain but even though there are separate values, with the exception of the recently added query they get treated as a whole within the app. I figured that if the app ever changes down the road and needs to handle the values individually it would be easy enough to explode the data. So to answer your question of why? To be honest ... I thought I had good enough reasons but in the end I suppose I didn't think it through well enough or far enough ahead. If need be a restructuring of the db is not out of the question I just assumed it wouldn't be a real stretch to come up with a creative solution which ultimately ended up being the case. Just for the record, I do recognize that a 'creative' solution is not always the best solution 8-). �...@calvin: About the queries ... there was a basic and an advanced. The basic is done and working. With the advanced search since I don't know fields elements are being submitted for the search I would normally concatenate the query itself. [example] $query= SELECT something FROM somewhere WHERE etc. etc. etc. ; if (isset($_GET['some_value']) $_GET['some_value'] != '' ) { $value = $_GET['some_value']; $query .= AND something = '.addslashes($value).'; } if (isset($_GET['some_other_value']) $_GET['some_other_value'] != '' ) { $value = $_GET['some_other_value']; $query .= AND something = '.addslashes($value).'; } $query .= WHERE some_col = some_criteria mysql_query($query); [/example] This worked well enough in the past. I agree that if the conditions were all 'OR' I would be good to go, unfortunately they all need to be 'AND'. The closest example I can find in the book (http://book.cakephp.org/view/1030/Complex-Find-Conditions) that seems even remotely close would be $dbo-buildStatement but to be brutally honest I have no clue how I would implement that (or something similar) in this case. Cake will accept the query whichever way I present it but the real problem lies in 'paginate' and 'containable', both of which I need. I suppose both could be written manually but then I would be well off the beaten path as far as Cake conventions and given my track record it would undoubtedly create some unforeseen problem somewhere down the line. As far as URL-encoded array data goes I just set the form method to GET and let Cake do it's thing. In the controller I pull the data from the URL using $this-params['url']['something']. If you are saying I can configure the routes to convert it over to named params I'll play around with it some more. The furthest I experimenting I've done with routes is to change from mySite/thisIsMyPage to my-site/this-is-my-page. - Ed On Mon, Jun 7, 2010 at 11:55 AM, calvin cal...@rottenrecords.com wrote: If all of your search options are OR conditions, then you could theoretically do something like this: SELECT ... WHERE contents REGEXP '(opt1|opt2|opt3|opt4|opt5|opt6)'; http://dev.mysql.com/doc/refman/5.0/en/regexp.html#operator_regexp On Jun 6, 1:24 pm, Ed Propsner crotchf...@gmail.com
Re: Query question(s)
(My earlier post was inaccurate so I removed it. Let's try this again...) I don't think you need buildStatement() in this case as your query, although long, shouldn't actually be that complex, even if you end up with both OR and AND conditions. You just need to take a look at how OR/AND conditions are constructed in find() and then use them to build custom pagination queries: http://book.cakephp.org/view/249/Custom-Query-Pagination Also, I did a test on GET forms using cake, and it should still create URLs like: /search?var1[]=0var1[]=1... How are you creating the checkboxes? A good way to do it is: echo $this-Form-input('type', array( 'type' = 'select', 'multiple' = 'checkbox', 'options' = array( '1' = 'Video', '2' = 'Audio', '4' = 'Photo', '8' = 'Text', ) )); Also, notice that I use multiples of 2 for the option values. This allows you to perform bitwise operations when querying the database. When you save, you just call array_sum() and turn the array into an integer, and save to a tinyint field. And when you do a search, you can just create a simple query like: array( 'and' = array( Model.type $orOptions 0, Model.type $andOptions = $andOptions ) ); --where $orOptions is just an array_sum() of the OR options and $andOptions is the array_sum() of the AND options. So if the user wants to find a directory that has Videos AND Photos OR Text, then $orOptions would be 8 and $andOptions would be 5 (1 + 4). This circumvents the problem of building long queries using LIKE and multiple ANDs and ORs. I would strongly advise against hand-building the SQL, especially in this case as your search query isn't so complex that you can't have Cake build it for you. On Jun 7, 12:14 pm, Ed Propsner crotchf...@gmail.com wrote: @John: [quote] Can you explain why you have not separated/normalized the SomeCol.contents? And do you have other such columns in your database? [/quote] No, that is the only column in the db that stores multiple values in one field (that aren't for display only). At one point in time the data in that column wasn't searchable and it never presented an issue. A little hard to explain but even though there are separate values, with the exception of the recently added query they get treated as a whole within the app. I figured that if the app ever changes down the road and needs to handle the values individually it would be easy enough to explode the data. So to answer your question of why? To be honest ... I thought I had good enough reasons but in the end I suppose I didn't think it through well enough or far enough ahead. If need be a restructuring of the db is not out of the question I just assumed it wouldn't be a real stretch to come up with a creative solution which ultimately ended up being the case. Just for the record, I do recognize that a 'creative' solution is not always the best solution 8-). @Calvin: About the queries ... there was a basic and an advanced. The basic is done and working. With the advanced search since I don't know fields elements are being submitted for the search I would normally concatenate the query itself. [example] $query= SELECT something FROM somewhere WHERE etc. etc. etc. ; if (isset($_GET['some_value']) $_GET['some_value'] != '' ) { $value = $_GET['some_value']; $query .= AND something = '.addslashes($value).'; } if (isset($_GET['some_other_value']) $_GET['some_other_value'] != '' ) { $value = $_GET['some_other_value']; $query .= AND something = '.addslashes($value).'; } $query .= WHERE some_col = some_criteria mysql_query($query); [/example] This worked well enough in the past. I agree that if the conditions were all 'OR' I would be good to go, unfortunately they all need to be 'AND'. The closest example I can find in the book (http://book.cakephp.org/view/1030/Complex-Find-Conditions) that seems even remotely close would be $dbo-buildStatement but to be brutally honest I have no clue how I would implement that (or something similar) in this case. Cake will accept the query whichever way I present it but the real problem lies in 'paginate' and 'containable', both of which I need. I suppose both could be written manually but then I would be well off the beaten path as far as Cake conventions and given my track record it would undoubtedly create some unforeseen problem somewhere down the line. As far as URL-encoded array data goes I just set the form method to GET and let Cake do it's thing. In the controller I pull the data from the URL using $this-params['url']['something']. If you are saying I can configure the routes to convert it over to named params I'll play around with it some more. The furthest I experimenting I've done with routes is to change from mySite/thisIsMyPage to my-site/this-is-my-page. - Ed On Mon, Jun
Re: Query question(s)
Ack, that example wasn't very good either, so let's try _one_ more time... Say you want to do a search for records that conform to these conditions: -must be of _both_ type Video AND Photo -must also be _either_ type Audio OR Text then $andOptions would be 5; $orOptions would be 10. On Jun 7, 7:38 pm, calvin cal...@rottenrecords.com wrote: (My earlier post was inaccurate so I removed it. Let's try this again...) I don't think you need buildStatement() in this case as your query, although long, shouldn't actually be that complex, even if you end up with both OR and AND conditions. You just need to take a look at how OR/AND conditions are constructed in find() and then use them to build custom pagination queries:http://book.cakephp.org/view/249/Custom-Query-Pagination Also, I did a test on GET forms using cake, and it should still create URLs like: /search?var1[]=0var1[]=1... How are you creating the checkboxes? A good way to do it is: echo $this-Form-input('type', array( 'type' = 'select', 'multiple' = 'checkbox', 'options' = array( '1' = 'Video', '2' = 'Audio', '4' = 'Photo', '8' = 'Text', ) )); Also, notice that I use multiples of 2 for the option values. This allows you to perform bitwise operations when querying the database. When you save, you just call array_sum() and turn the array into an integer, and save to a tinyint field. And when you do a search, you can just create a simple query like: array( 'and' = array( Model.type $orOptions 0, Model.type $andOptions = $andOptions ) ); --where $orOptions is just an array_sum() of the OR options and $andOptions is the array_sum() of the AND options. So if the user wants to find a directory that has Videos AND Photos OR Text, then $orOptions would be 8 and $andOptions would be 5 (1 + 4). This circumvents the problem of building long queries using LIKE and multiple ANDs and ORs. I would strongly advise against hand-building the SQL, especially in this case as your search query isn't so complex that you can't have Cake build it for you. On Jun 7, 12:14 pm, Ed Propsner crotchf...@gmail.com wrote: @John: [quote] Can you explain why you have not separated/normalized the SomeCol.contents? And do you have other such columns in your database? [/quote] No, that is the only column in the db that stores multiple values in one field (that aren't for display only). At one point in time the data in that column wasn't searchable and it never presented an issue. A little hard to explain but even though there are separate values, with the exception of the recently added query they get treated as a whole within the app. I figured that if the app ever changes down the road and needs to handle the values individually it would be easy enough to explode the data. So to answer your question of why? To be honest ... I thought I had good enough reasons but in the end I suppose I didn't think it through well enough or far enough ahead. If need be a restructuring of the db is not out of the question I just assumed it wouldn't be a real stretch to come up with a creative solution which ultimately ended up being the case. Just for the record, I do recognize that a 'creative' solution is not always the best solution 8-). �...@calvin: About the queries ... there was a basic and an advanced. The basic is done and working. With the advanced search since I don't know fields elements are being submitted for the search I would normally concatenate the query itself. [example] $query= SELECT something FROM somewhere WHERE etc. etc. etc. ; if (isset($_GET['some_value']) $_GET['some_value'] != '' ) { $value = $_GET['some_value']; $query .= AND something = '.addslashes($value).'; } if (isset($_GET['some_other_value']) $_GET['some_other_value'] != '' ) { $value = $_GET['some_other_value']; $query .= AND something = '.addslashes($value).'; } $query .= WHERE some_col = some_criteria mysql_query($query); [/example] This worked well enough in the past. I agree that if the conditions were all 'OR' I would be good to go, unfortunately they all need to be 'AND'. The closest example I can find in the book (http://book.cakephp.org/view/1030/Complex-Find-Conditions) that seems even remotely close would be $dbo-buildStatement but to be brutally honest I have no clue how I would implement that (or something similar) in this case. Cake will accept the query whichever way I present it but the real problem lies in 'paginate' and 'containable', both of which I need. I suppose both could be written manually but then I would be well off the beaten path as far as Cake conventions and given my track record it would undoubtedly create some unforeseen problem somewhere down the line. As far
Need help: Plugin model issue
Hi, I hope someone can give me some assistance with Plugin models. Cake Version: 1.3.2 == Problem: Query result does not build model joins when using a plugin == Location: Model files are in app/plugin/Myplugin/models Plugin Name: Myplugin Model A: -- class Client extends AppModel { var $name = 'Client'; } Model B: --- class Account extends AppModel { var $name = 'Account'; var $belongsTo = 'Myplugin.Client'; } Call: --- $data = $this-Account-find('all'); Query output from cake/libs/models/model.php (line 2086): Array ( [conditions] = Array ( ) [fields] = [joins] = Array ( ) [limit] = [offset] = [order] = Array ( [0] = ) [page] = 1 [group] = [callbacks] = 1 ) Result: - Array ( [0] = Array ( [Account] = Array ( [id] = 85 [client_id] = 1 ) ) [1] = Array ( [Account] = Array ( [id] = 86 [client_id] = 2 ) ) ) Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en