Re: debug level on ajax request
oops. it's not on boot strap only. my bad. On Thu, Aug 25, 2011 at 12:47 PM, stas kim wrote: > it's probably because of this line > https://github.com/cakephp/cakephp/blob/master/cake/libs/configure.php#L119 > which is executed on bootstrap. meaning even if you change debug level > later in your controller it will only effect Debugger class behavior > > > cheers > > On Wed, Aug 24, 2011 at 11:21 AM, Ben McClure wrote: >> Fixing warnings and notices is not the answer to his question--With debug >> mode off, he should not be getting such messages displayed. At worse, he >> should be seeing formatted Cake errors or simply a blank page if something >> is wrong. >> Perhaps the warnings/notices/errors are being thrown before you >> call Configure::write('debug', 0); ? If so, try calling it earlier in your >> code. >> Or perhaps something else is changing the value of debug back to 1 or >> greater? >> You could echo something from inside that if() block to make sure it is >> actually hitting the code which sets the debug value to 0. >> Beyond that, I don't know what else to have you try :) >> Ben >> >> -- >> Our newest site for the community: CakePHP Video Tutorials >> http://tv.cakephp.org >> Check out the new CakePHP Questions site http://ask.cakephp.org and help >> others with their CakePHP related questions. >> >> >> To unsubscribe from this group, send email to >> cake-php+unsubscr...@googlegroups.com For more options, visit this group at >> http://groups.google.com/group/cake-php >> > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: debug level on ajax request
it's probably because of this line https://github.com/cakephp/cakephp/blob/master/cake/libs/configure.php#L119 which is executed on bootstrap. meaning even if you change debug level later in your controller it will only effect Debugger class behavior cheers On Wed, Aug 24, 2011 at 11:21 AM, Ben McClure wrote: > Fixing warnings and notices is not the answer to his question--With debug > mode off, he should not be getting such messages displayed. At worse, he > should be seeing formatted Cake errors or simply a blank page if something > is wrong. > Perhaps the warnings/notices/errors are being thrown before you > call Configure::write('debug', 0); ? If so, try calling it earlier in your > code. > Or perhaps something else is changing the value of debug back to 1 or > greater? > You could echo something from inside that if() block to make sure it is > actually hitting the code which sets the debug value to 0. > Beyond that, I don't know what else to have you try :) > Ben > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Custom Find sending back strange results
i can tell where the errors come from in you __getComments you overwrite $query with actual dataset returned by Comment->find which is wrong because the $query var is passed to Model->find and it gets confused with your data what you need to do is build a proper contain $query['contain'] = array( 'Comment'=> array( 'User'=>array(), 'limit'=> 'order'=> 'field name desc' ) ) return $query That way you will get your Shows paginated containing comments->userinfo On Thu, Apr 28, 2011 at 9:07 PM, bradmaxs wrote: > All I want to do is have one find for my comments in each associated > model. I would love to do this in the Comment model and only have to > do it once but that wasn't working out. > > SHOW CONTROLLER > > $this->paginate = array('comments', 'id' => $show['Show']['id'], > 'model' => 'Show'); > $comments = $this->paginate(); > $this->set(compact('show', 'comments')); > > SHOW MODEL > > public $_findMethods = array('comments' => true); > > public function _findComments($state, $query, $results=array()) { > if ($state == "before") { > $query = $this->__getComments($query['id'], $query['model'], > $query); > return $query; > } else { > return $results; > } > } > > private function __getComments($id, $model, $query) { > $query = ClassRegistry::init('Comment')->find('all', array( > 'contain' => array( > 'User' => array( > 'fields' => array('id', 'username', > 'slug'), > 'Image' => array( > 'fields' => array('name') > ) > ) > ), > 'conditions' => array( > 'Comment.typeID' => $id, > 'Comment.model' => $model > ), > 'limit' => 5, > 'order' => array('Comment.created' => 'desc') > )); > return $query; > } > > RESULTS > > This is the one I want: > > SELECT `Comment`.`id`, `Comment`.`parent_id`, `Comment`.`user_id`, > `Comment`.`typeID`, `Comment`.`model`, `Comment`.`comment`, > `Comment`.`created`, `Comment`.`modified`, `User`.`id`, > `User`.`username`, `User`.`slug` FROM `comments` AS `Comment` LEFT > JOIN `users` AS `User` ON (`Comment`.`user_id` = `User`.`id`) WHERE > `Comment`.`typeID` = 2 AND `Comment`.`model` = 'Show' ORDER BY > `Comment`.`created` desc LIMIT 5 > > This is also on the sql log and it seems to be the one the view is > using: > > SELECT `Comment`.`id`, `Comment`.`parent_id`, `Comment`.`user_id`, > `Comment`.`typeID`, `Comment`.`model`, `Comment`.`comment`, > `Comment`.`created`, `Comment`.`modified` FROM `comments` AS `Comment` > WHERE `Comment`.`typeID` IN (2, 3) ORDER BY `Comment`.`created` DESC > > I don't even understand where it is coming from because I didn't > define it. > > And I get these errors: > > Notice (8): Undefined index: page [CORE/cake/libs/model/model.php, > line 2094] > Notice (8): Undefined index: order [CORE/cake/libs/model/model.php, > line 2100] > Notice (8): Undefined index: order [CORE/cake/libs/model/model.php, > line 2103] > Notice (8): Undefined index: callbacks [CORE/cake/libs/model/ > model.php, line 2105] > Notice (8): Undefined index: callbacks [CORE/cake/libs/model/ > model.php, line 2130] > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Query with conditions in HABTM models
Hello David, the solution you came up with is rally BAD!!! people burn in hell for code like that. seriously look at what you are doing 1. you select all records from your linking table (which is double the size of your posts table. assuming every post has 1-4 tags on average) in one query. insane right? 2. then you go through entire record set extracting post ids (lot's of duplicates because every post has 2-4 tags on average) 3. you do full index scan on your posts table (2-4 time for every post, because you didn't do distinct select in previous insane steps) excluding virtually every record except few latest uncategorized posts. in the long run those 3 lines of code will crush your server. perhaps you should look into habtm countercache. although it is not implemented for habtm as core feature. i've come across some articles with workarounds do that and it will come down to one indexed select on countercache field where countercache is zero Cheers On Fri, Apr 29, 2011 at 5:53 AM, davidhc wrote: > Ignore my previous message... > > I have solved it with this http://bin.cakephp.org/view/471586323 > > Thank you again, cricket :D > David. > > On 29 abr, 10:17, davidhc wrote: >> Only one more doubt... >> >> Could I use the native cakephp paginator with this model function? > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: should teacher and student stay together???
i believe the term your are looking for is 'self referential habtm' goole for it. there are plenty examples On Fri, Apr 29, 2011 at 1:53 PM, cricket wrote: > On Fri, Apr 29, 2011 at 11:28 AM, Tan Cheng wrote: >> Hi all, >> >> A very basic question, I naively believe that there's no dumb >> question... >> >> I'm creating a database, and the users are categorized into teachers >> and students, obviously, one student has and belongs to many teachers >> and vice versa, so there is a HABTM relationship between students and >> teachers. >> >> So in cake, which is the better approach? >> >> 1) Put them in the "users" table and use a field to distinguish >> students and teachers, but how do I describe the HABTM relationship >> between them? Do I need to create a "students_teachers" table? > > You could add 2 columns to your users table, model & foreign_key. The > students & teachers tables can also have a user_id column to associate > back the other way. > >> 2) Create three tables, "students", "teachers", and a >> "students_teachers" table. > > Yes, do that as well. These are not mutually exclusive. > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: set paginator last page as default?
FYI this is how cake tests the page if ($page === 'last' || $page >= $pageCount) { $options['page'] = $page = $pageCount; } elseif (intval($page) < 1) { $options['page'] = $page = 1; } so i would say 'last' is built in option On Mon, Apr 18, 2011 at 4:38 PM, lucas wrote: > Thanks stats kim, i already know about that solution. It seems there > is nothing built in at core level to achieve this. > It´s not an elegant solution but it works fine and it´s practical. > > For those who need something like this, before call the paginate > method, put this line $this->paginate['page'] = 9; or a bigger > number... > > Thanks for all the responses. > > > > On 18 abr, 17:23, stas kim > wrote: >> What you can do is set page parameter in your controller to 'last' >> or some huge number larger than projected page count. >> And it will miraculously bring you to the last page. whatever that >> last page's number is. >> That is the way Controller::paginate works in 1.3 >> >> >> >> >> >> >> >> On Mon, Apr 18, 2011 at 3:42 PM, lucas wrote: >> > I can´t do that because the data can´t be ordered. I need it in that >> > way... >> >> > On 18 abr, 16:37, Tilen Majerle wrote: >> >> yes...instead of order => "YourModel.field ASC" type "YourModel.field >> >> DESC" >> >> and you will have newest posts/whatever in top of pages >> >> -- >> >> Lep pozdrav, Tilen Majerlehttp://majerle.eu >> >> >> 2011/4/18 Jeremy Burns | Class Outfit >> >> >> > Sort the data in reverse order? >> >> >> > Jeremy Burns >> >> > Class Outfit >> >> >> > jeremybu...@classoutfit.com >> >> >http://www.classoutfit.com >> >> >> > On 18 Apr 2011, at 20:32, lucas wrote: >> >> >> > > Hi people, is it possible to set as default the last page of the >> >> > > paginated data from the controller? Is there an option available to do >> >> > > this? >> >> >> > > thanks in advance! >> >> >> > > -- >> >> > > Our newest site for the community: CakePHP Video Tutorials >> >> >http://tv.cakephp.org >> >> > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp >> >> > others with their CakePHP related questions. >> >> >> > > To unsubscribe from this group, send email to >> >> > > cake-php+unsubscr...@googlegroups.com For more options, visit this >> >> > > group >> >> > athttp://groups.google.com/group/cake-php >> >> >> > -- >> >> > Our newest site for the community: CakePHP Video Tutorials >> >> >http://tv.cakephp.org >> >> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp >> >> > others with their CakePHP related questions. >> >> >> > To unsubscribe from this group, send email to >> >> > cake-php+unsubscr...@googlegroups.com For more options, visit this group >> >> > athttp://groups.google.com/group/cake-php >> >> > -- >> > Our newest site for the community: CakePHP Video >> > Tutorialshttp://tv.cakephp.org >> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help >> > others with their CakePHP related questions. >> >> > To unsubscribe from this group, send email to >> > cake-php+unsubscr...@googlegroups.com For more options, visit this group >> > athttp://groups.google.com/group/cake-php > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Does pagination with custom urls really sucks?
i think you need to make your route greedy OR add another route with page param, you will need to keep both routes one for default location and one for paged On Mon, Apr 18, 2011 at 1:29 PM, huoxito wrote: > im not able to make route class and paginator helper work as i want too i > guess. > if i try to reach example.com/controller/slug1/slug2/page:2 cakephp tries to > find an action called slug1. Its like as if it ignores completely the route > i defined. > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Validation errors only working in Add form, but not in Edit form.
a) use http://bin.cakephp.org or other bin of preference to show your code b) Model::save() validation parameter defaults to true, no need to force it c) number of reasons why you don't see messages you may not print it in the view - compare your add and edit views or your validation rules 'on' options set to 'create' On Mon, Apr 18, 2011 at 1:57 PM, Krissy Masters wrote: > if ($this->Post->save($this->data)) { you not forcing validation check > > add true > > if ($this->Post->save($this->data, true)) { > > K > > -Original Message- > From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf > Of jackgoh > Sent: Monday, April 18, 2011 3:23 PM > To: CakePHP > Subject: Validation errors only working in Add form, but not in Edit form. > > Hi, > > > The validation message is working in Add Form, but not in the Edit > Form, can anyone help me? > Part of my code in the controller: > > function edit($id = null) { > $this->Post->id = $id; > $sectors = $this->Post->Sector->find('list', array( > > 'fields' => array('id','combined_name'), > > 'conditions' => array('status' => 'A') > > ) > ); > $this->set(compact('sectors')); > > if (empty($this->data)) { > $this->data = $this->Post->read(); > } else { > if ($this->Post->save($this->data)) { > $this->Session->setFlash('Your record has > been updated.'); > $this->redirect(array('action' => 'index')); > } else { > $this->Session- >>setFlash('Error.'); > } > } > } > > Thanks! > > Best regards. > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: set paginator last page as default?
What you can do is set page parameter in your controller to 'last' or some huge number larger than projected page count. And it will miraculously bring you to the last page. whatever that last page's number is. That is the way Controller::paginate works in 1.3 On Mon, Apr 18, 2011 at 3:42 PM, lucas wrote: > I can´t do that because the data can´t be ordered. I need it in that > way... > > > On 18 abr, 16:37, Tilen Majerle wrote: >> yes...instead of order => "YourModel.field ASC" type "YourModel.field DESC" >> and you will have newest posts/whatever in top of pages >> -- >> Lep pozdrav, Tilen Majerlehttp://majerle.eu >> >> 2011/4/18 Jeremy Burns | Class Outfit >> >> >> >> >> >> >> >> > Sort the data in reverse order? >> >> > Jeremy Burns >> > Class Outfit >> >> > jeremybu...@classoutfit.com >> >http://www.classoutfit.com >> >> > On 18 Apr 2011, at 20:32, lucas wrote: >> >> > > Hi people, is it possible to set as default the last page of the >> > > paginated data from the controller? Is there an option available to do >> > > this? >> >> > > thanks in advance! >> >> > > -- >> > > Our newest site for the community: CakePHP Video Tutorials >> >http://tv.cakephp.org >> > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help >> > others with their CakePHP related questions. >> >> > > To unsubscribe from this group, send email to >> > > cake-php+unsubscr...@googlegroups.com For more options, visit this group >> > athttp://groups.google.com/group/cake-php >> >> > -- >> > Our newest site for the community: CakePHP Video Tutorials >> >http://tv.cakephp.org >> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help >> > others with their CakePHP related questions. >> >> > To unsubscribe from this group, send email to >> > cake-php+unsubscr...@googlegroups.com For more options, visit this group >> > athttp://groups.google.com/group/cake-php > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: URL Case
This might help http://www.pseudocoder.com/Super_Awesome_Advanced_CakePHP_Tips.pdf search 'Case Insensitive' On Thu, Apr 14, 2011 at 3:00 PM, cricket wrote: > On Thu, Apr 14, 2011 at 2:08 PM, Krissy Masters > wrote: >> Thanks for the link. Its for Apache, I am on nginX but thanks all the same. > > Oops! Sorry, I did see that earlier. > >> I was just curious if there was a simple way to force the URLs. People don't >> normally type out URLs I was just curious if there was a simple way to >> ensure that if someone did type something in it would ensure lowercase if >> not convert to lower then attempt the URL. Everything on the site is 100% >> lowercase, I was just curious more so that actually caring :) If you get a >> 404 because your typing the url then that's just your problem, that's why we >> put links there so you don't have to type them :) >> >> Just seems like more work for the .1% who might. > > You could create a custom 404 page where you test whether the > requested URL has any uppercase chars. If so, suggest the lowercase > version. > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php