Load models without model files
Hi, I have tables that are created on the fly and I'd like to access it thru Model. Since those tables are dynamically created, I don't have the model .php files for them. The tables are created conforming to Cake's naming convention. I tried to use loadModel() to load them but Cake still complains that the tables are missing. Is there a solution for it? Thank you. -- 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: apostrophe in URl and view cache
Thanks but I should have made it clear that I do urlencode the URL. I just didn't show the encoded URL here. On Mar 17, 4:46 pm, Ryan Schmidt wrote: > On Mar 17, 2011, at 13:24, qua...@gmail.com wrote: > > > I am having a problem with cache if the URL has apostrophe in it. > > > For example: > >www.example.com/controller/action/What'sMy Name > > > On first load when cache isn't there, it loads fine. However, once the > > cache is created, the subsequent load of the page causes PHP syntax > > error because in the cache file there is a line: > > > $controller->here = $this->here = '/controller/action/What's My > > Name?'; > > > Note the apostrophe isn't escaped and hence the PHP syntax error. > > > How can I fix this? Is this considered a bug in Cake? > > I don't know... does the problem still happen if you properly escape the > URLs? Spaces and apostrophes, among others, are not valid characters in URLs, > so your URL would properly be written: > > http://www.example.com/controller/action/What%27s%20My%20Name > > Or, if you're trying to make slugs, then you might want it to look like: > > http://www.example.com/controller/action/whats-my-name -- 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
apostrophe in URl and view cache
Guys, I am having a problem with cache if the URL has apostrophe in it. For example: www.example.com/controller/action/What's My Name On first load when cache isn't there, it loads fine. However, once the cache is created, the subsequent load of the page causes PHP syntax error because in the cache file there is a line: $controller->here = $this->here = '/controller/action/What's My Name?'; Note the apostrophe isn't escaped and hence the PHP syntax error. How can I fix this? Is this considered a bug in Cake? Thanks. -- 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: Problem running shell in cronjob
Thanks! You are absolutely right. I didn't realize I did have another php in /usr/bin/ and that was the one cron used. Problem solved. Again, thank you very much. On Dec 7, 11:48 am, Ryan Schmidt wrote: > You have more than one copy of PHP installed on your computer, and they have > different capabilities. It sounds like the one you want (which has MySQL > support) is in /usr/local/bin, and it sounds like your PATH variable includes > the path /usr/local/bin before the location where your second copy of PHP is > installed (perhaps /usr/bin?). So everything works on your console. > > Cron has its own PATH, however. Perhaps cron's PATH does not include > /usr/local/bin, or perhaps it does, but it's after the location where the > other PHP is, so that the other PHP (which apparently doesn't have MySQL > support) is found, and you get an error about undefined MySQL functions. > > Figure out how to change cron's PATH. Or specify the PATH yourself before > running the cake console, e.g.: > > PATH=/usr/local/bin:/usr/bin:/bin /path/to/cake/console/cake > > Or if you're doing it as in the book page you linked to, and you already have > a wrapper script around the cake console, set the PATH within that wrapper > script. > > On Dec 7, 2010, at 13:23, qua...@gmail.com wrote: > > > I found out that I can fix the problem by calling php with its > > absolute path in cake/console/cake: > > > From: > > exec php -q ${LIB}cake.php -working "${APP}" "$@" > > > To: > > exec /usr/local/bin/php -q ${LIB}cake.php -working "${APP}" "$@" > > > However, I do not like that solution because it changes Cake core. > > > Anyone any clue? Thanks! > > > On Dec 6, 11:01 pm, "qua...@gmail.com" wrote: > > >> I followed the instructions > >> onhttp://book.cakephp.org/view/1110/Running-Shells-as-cronjobs > >> and I still ran into a strange problem while running my shell in > >> cronjob. > > >> I am getting error when I try to use model in the shell: > > >> Fatal error: Call to undefined function mysql_query() in /home/ > >> cake1.3.6/cake/libs/model/datasources/dbo/dbo_mysql.php on line 600 > > >> The shell runs fine if I just fire it up manually. What can't PHP see > >> mysql_query() when it's done in a shell via cronjob? 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 running shell in cronjob
I found out that I can fix the problem by calling php with its absolute path in cake/console/cake: From: exec php -q ${LIB}cake.php -working "${APP}" "$@" To: exec /usr/local/bin/php -q ${LIB}cake.php -working "${APP}" "$@" However, I do not like that solution because it changes Cake core. Anyone any clue? Thanks! On Dec 6, 11:01 pm, "qua...@gmail.com" wrote: > Hi all, > > I followed the instructions > onhttp://book.cakephp.org/view/1110/Running-Shells-as-cronjobs > and I still ran into a strange problem while running my shell in > cronjob. > > I am getting error when I try to use model in the shell: > > Fatal error: Call to undefined function mysql_query() in /home/ > cake1.3.6/cake/libs/model/datasources/dbo/dbo_mysql.php on line 600 > > The shell runs fine if I just fire it up manually. What can't PHP see > mysql_query() when it's done in a shell via cronjob? > > Thank you. 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->find('first', ...) returns false on error or empty result
Again, find('first') does not return empty array. It's always false on error and empty set. On Dec 7, 10:17 am, euromark wrote: > "empty($records) check will return true for both cases of not found > and > for SQL error too. Same as simple $records check" > > exactly > > but i never saw it return an empty array before for "first" (only for > list and all) > > On 7 Dez., 18:34, "Dr. Loboto" wrote: > > > Sometimes find returns false for not found records and sometimes it > > returns empty array. At least I saw this in Cake 1.2 > > empty($records) check will return true for both cases of not found and > > for SQL error too. Same as simple $records check. > > > On 7 дек, 19:08, euromark wrote: > > > > i saw your ticket :) > > > and i agree - it would be more constant if id behaved the same > > > > you could still check on if ($record = $this->find(...)) or $record > > > = ...; if (!empty($record)) etc > > > so the code wouldnt change at all for most people > > > as long as nobody used strict comparison yet, anyway. > > > > On 7 Dez., 08:04, "qua...@gmail.com" wrote: > > > > > I see...however, I do feel find('first'..) should behave like > > > > find('all') where it returns false on error and empty array on empty > > > > result... > > > > > On Dec 6, 8:00 pm, euromark wrote: > > > > > > usually there shouldnt be any errors :) > > > > > > but you could put this in your app_model.php: > > > > > > /** > > > > > * @return string Error message with error number > > > > > */ > > > > > public function lastError() { > > > > > $db = $this->getDataSource(); > > > > > return $db->lastError(); > > > > > } > > > > > > if its not empty there was an error > > > > > > On 7 Dez., 02:10, "qua...@gmail.com" wrote: > > > > > > > Hi all, > > > > > > > It appears Model->find('first', ...) returns false in both cases: > > > > > > > 1) SQL error > > > > > > 2) Empty result > > > > > > > How am I supposed to know which is which if it behaves this way? > > > > > > > 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->find('first', ...) returns false on error or empty result
I see...however, I do feel find('first'..) should behave like find('all') where it returns false on error and empty array on empty result... On Dec 6, 8:00 pm, euromark wrote: > usually there shouldnt be any errors :) > > but you could put this in your app_model.php: > > /** > * @return string Error message with error number > */ > public function lastError() { > $db = $this->getDataSource(); > return $db->lastError(); > } > > if its not empty there was an error > > On 7 Dez., 02:10, "qua...@gmail.com" wrote: > > > Hi all, > > > It appears Model->find('first', ...) returns false in both cases: > > > 1) SQL error > > 2) Empty result > > > How am I supposed to know which is which if it behaves this way? > > > 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
Problem running shell in cronjob
Hi all, I followed the instructions on http://book.cakephp.org/view/1110/Running-Shells-as-cronjobs and I still ran into a strange problem while running my shell in cronjob. I am getting error when I try to use model in the shell: Fatal error: Call to undefined function mysql_query() in /home/ cake1.3.6/cake/libs/model/datasources/dbo/dbo_mysql.php on line 600 The shell runs fine if I just fire it up manually. What can't PHP see mysql_query() when it's done in a shell via cronjob? Thank you. 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->find('first', ...) returns false on error or empty result
Hi all, It appears Model->find('first', ...) returns false in both cases: 1) SQL error 2) Empty result How am I supposed to know which is which if it behaves this way? 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: Custom helper in PagesController
I get this error in log: Undefined property: View::$Fxpage in [...] On Dec 2, 12:29 pm, "qua...@gmail.com" wrote: > Hi all, > > I have a custom helper and like to use it in Pages Controller. > > I copied pages_controller.php to my app and have this line in it: > > var $helpers = array('Html', 'Session', 'Fxpage'); > > However, the output of the pages stops at the call to any $this->Fxpage in > the layout file. It just seems as if Pages can't see my > > helper. > > I have been stuck at this for hours now. Any advice is greatly > appreciated. > > 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
Custom helper in PagesController
Hi all, I have a custom helper and like to use it in Pages Controller. I copied pages_controller.php to my app and have this line in it: var $helpers = array('Html', 'Session', 'Fxpage'); However, the output of the pages stops at the call to any $this- >Fxpage in the layout file. It just seems as if Pages can't see my helper. I have been stuck at this for hours now. Any advice is greatly appreciated. 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: CakePHP Model uses the wrong fields in SQL statements!
Just a little update from myself...ever since I converted the code to use custom query (model->query()), I have been processing millions of records like a knife cutting through butter. I do still want to hunt down this bug in any way I can. I will try to create a small test case if it is even possible. Thanks. On Nov 26, 3:10 am, keymaster wrote: > John Steele, > > Rather than continuing on this thread, where you'll probably get (in > my opinion) unnecessarily get heckled, why not create a lighthouse > ticket and attach a small, reproduceable testcase that has the > problem, the db and as concise a slice of your app as possible. > > Cake is solid, very solid, but it does not mean no bugs will ever be > found for the rest of time. > > You would be doing everyone a service if you found a bug and properly > documented it. > > I imagine a bug like this (if indeed it's a bug) would receive due > attention and be fixed in the next maintenance release, probably > patched sooner. > > All the best. > > On Nov 25, 10:06 pm, Jeremy Burns | Class Outfit > > wrote: > > Amusing. > > > Jeremy Burns > > Class Outfit > > > jeremybu...@classoutfit.comhttp://www.classoutfit.com > > > On 25 Nov 2010, at 19:44, AD7six wrote: > > > > On Nov 25, 8:40 pm, John Steele wrote: > > > FWIW/For info I've (as I'm sure have many) run many batch processes > > > inserting hundreds of thousands or millions of rows at a time. > > > As have I, and I have not noticed a bug while doing so. > > > >>> So, if only some of your shells generate this error, and some don't - > > >>> what conclusion can you draw about that? <- rhetorical > > > >> TL;DR: It seems to affect Model->find('first') with multiple > > >> conditions. > > > >> Nowhere in there did I say "It seems to affect Model->save()..." > > > > Then why are you quoting sql which includes inserts? > > > "INSERT INTO `foos` (`bar`, `baz`) VALUES (128921, 128922)" > > > > and I > > >> didn't say that because I have never encountered a problem "inserting > > >> hundreds of thousands or millions of rows at a time." > > >> I do however consistently encounter the problem I have described while > > >> READING hundreds of thousands or millions of rows at a time. If you > > >> are going to continue to not read what I have written, then it is not > > >> worth my time to write it. I have work to do. > > > > I bet if you investigate you're going to find the QUERY cache is > > > getting collisions. > > > >> Good day, Sir. > > > > I'll take my tie off then ;) > > > > 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: CakePHP Model uses the wrong fields in SQL statements!
I did try that once and still same problem by commenting out HABTM while keeping HM. I can try again if you really think that is what confused Cake. Thanks. On Nov 22, 3:53 pm, euromark wrote: > i am pretty certain your model setup is faulty! > why are you declaring HABTM and HM to the same relationship tables? > this is causing your trouble > stick to one and you will be fine > > On 22 Nov., 22:08, Jeremy Burns | Class Outfit > > wrote: > > Varying data sort of makes it difficult to pin point exactly what is going > > wrong though, doesn't it? Wouldn't it be better to get a consistent set of > > data and run your code consistently against it - else how are you going to > > know for sure if you have isolated the root cause? > > > Jeremy Burns > > Class Outfit > > > jeremybu...@classoutfit.comhttp://www.classoutfit.com > > > On 22 Nov 2010, at 21:04, qua...@gmail.com wrote: > > > > Ok I will try to uncomment in core.php and give it another shot. > > > > persistModel only applies to controllers? I am running a Shell/Task > > > here. > > > > The data is different actually. I am going through millions of data > > > and whenever it errors out, I just pick up from where it left off. > > > > I don't know if the fact that the loop is done in a shell but the > > > majority of the operations occur in a task have anything to do with > > > it: > > > > Shell code (ImportMine is a task): > > > foreach ($mine_data as $mine) > > > { > > > .. > > > $this->ImportMine->import($name, $artist, $album, $genre, > > > $mine['Mine']['id']); > > > .. > > > } > > > > Thanks. > > > > On Nov 22, 12:47 pm, Jeremy Burns | Class Outfit > > > wrote: > > >> I would go one further and uncomment line 94 in /app/config/core.php: > > > >> Configure::write('Cache.disable', true); > > > >> Have you got persistModel set to true? If so, set that to false. > > > >> If the code is still breaking (I am assuming that you are always testing > > >> with exactly the same data?) but at a different place each time, I'd > > >> find it difficult to pin it down to code which at the end of the day is > > >> plain old hard logic and then ought to be repeatable. What else have you > > >> got either in your code or elsewhere in your environment that is > > >> variable? > > > >> Jeremy Burns > > >> Class Outfit > > > >> jeremybu...@classoutfit.comhttp://www.classoutfit.com > > > >> On 22 Nov 2010, at 20:39, qua...@gmail.com wrote: > > > >>> Empty cache yes, Disable cache? I do set cacheQueries to false if that > > >>> is what you meant. Thanks. > > > >>> On Nov 22, 12:26 pm, Jeremy Burns | Class Outfit > > >>> wrote: > > >>>> And did you empty the cache, disable the cache, etc etc as suggested > > >>>> earlier? > > > >>>> Jeremy Burns > > >>>> Class Outfit > > > >>>> jeremybu...@classoutfit.comhttp://www.classoutfit.com > > > >>>> On 22 Nov 2010, at 20:18, qua...@gmail.com wrote: > > > >>>>> Here is all the code: > > >>>>> $this->out("this->Album->field('Album.library_count')"); > > >>>>> $this->Album->id = $album_id; > > >>>>> $library_count = $this->Album->field('Album.library_count'); > > >>>>> $this->out('Get Album library count and it is: ' . $library_count); > > > >>>>> The final out statement produced only "Get Album library count and it > > >>>>> is: " as I think $library_count is false or null at that point. > > > >>>>> Here is full SQL warning message: > > >>>>> Warning: SQL Error: 1054: Unknown column 'Song.artist_id' in 'where > > >>>>> clause' in /svr/web/cake1.3.6/cake/libs/model/datasources/ > > >>>>> dbo_source.php on line 684 > > >>>>> Query: SELECT `Album`.`library_count` FROM `albums` AS `Album` WHERE > > >>>>> `Song`.`artist_id` = 7590 AND `Song`.`name` = 'One Thing Leads to > > >>>>> Another' LIMIT 1 > > > >>>>> Thanks. > > > >>>>> On Nov 22, 12:10 pm, Jeremy Burns | Class Outfit &
Re: CakePHP Model uses the wrong fields in SQL statements!
Disabling cache didn't help. It is probably a memory issue. Flakiness like this usually points to memory problems. PHP might be the culprit here for all I know. For now I am going to convert to code to use custom query and see how that goes. I agree with having a stale data set to run against but I am under the gun here so maybe I will try that later. Thanks for your help. I really appreciate it. On Nov 22, 1:08 pm, Jeremy Burns | Class Outfit wrote: > Varying data sort of makes it difficult to pin point exactly what is going > wrong though, doesn't it? Wouldn't it be better to get a consistent set of > data and run your code consistently against it - else how are you going to > know for sure if you have isolated the root cause? > > Jeremy Burns > Class Outfit > > jeremybu...@classoutfit.comhttp://www.classoutfit.com > > On 22 Nov 2010, at 21:04, qua...@gmail.com wrote: > > > Ok I will try to uncomment in core.php and give it another shot. > > > persistModel only applies to controllers? I am running a Shell/Task > > here. > > > The data is different actually. I am going through millions of data > > and whenever it errors out, I just pick up from where it left off. > > > I don't know if the fact that the loop is done in a shell but the > > majority of the operations occur in a task have anything to do with > > it: > > > Shell code (ImportMine is a task): > > foreach ($mine_data as $mine) > > { > > .. > > $this->ImportMine->import($name, $artist, $album, $genre, > > $mine['Mine']['id']); > > .. > > } > > > Thanks. > > > On Nov 22, 12:47 pm, Jeremy Burns | Class Outfit > > wrote: > >> I would go one further and uncomment line 94 in /app/config/core.php: > > >> Configure::write('Cache.disable', true); > > >> Have you got persistModel set to true? If so, set that to false. > > >> If the code is still breaking (I am assuming that you are always testing > >> with exactly the same data?) but at a different place each time, I'd find > >> it difficult to pin it down to code which at the end of the day is plain > >> old hard logic and then ought to be repeatable. What else have you got > >> either in your code or elsewhere in your environment that is variable? > > >> Jeremy Burns > >> Class Outfit > > >> jeremybu...@classoutfit.comhttp://www.classoutfit.com > > >> On 22 Nov 2010, at 20:39, qua...@gmail.com wrote: > > >>> Empty cache yes, Disable cache? I do set cacheQueries to false if that > >>> is what you meant. Thanks. > > >>> On Nov 22, 12:26 pm, Jeremy Burns | Class Outfit > >>> wrote: > >>>> And did you empty the cache, disable the cache, etc etc as suggested > >>>> earlier? > > >>>> Jeremy Burns > >>>> Class Outfit > > >>>> jeremybu...@classoutfit.comhttp://www.classoutfit.com > > >>>> On 22 Nov 2010, at 20:18, qua...@gmail.com wrote: > > >>>>> Here is all the code: > >>>>> $this->out("this->Album->field('Album.library_count')"); > >>>>> $this->Album->id = $album_id; > >>>>> $library_count = $this->Album->field('Album.library_count'); > >>>>> $this->out('Get Album library count and it is: ' . $library_count); > > >>>>> The final out statement produced only "Get Album library count and it > >>>>> is: " as I think $library_count is false or null at that point. > > >>>>> Here is full SQL warning message: > >>>>> Warning: SQL Error: 1054: Unknown column 'Song.artist_id' in 'where > >>>>> clause' in /svr/web/cake1.3.6/cake/libs/model/datasources/ > >>>>> dbo_source.php on line 684 > >>>>> Query: SELECT `Album`.`library_count` FROM `albums` AS `Album` WHERE > >>>>> `Song`.`artist_id` = 7590 AND `Song`.`name` = 'One Thing Leads to > >>>>> Another' LIMIT 1 > > >>>>> Thanks. > > >>>>> On Nov 22, 12:10 pm, Jeremy Burns | Class Outfit > >>>>> wrote: > >>>>>> Is this ALL of the SQL being produced or just an extract? > > >>>>>> What happens if you do: > > >>>>>> echo $this->Album->field('Album.library_count'); > >>>>>> or > >>>>>> $variab
Re: CakePHP Model uses the wrong fields in SQL statements!
Ok I will try to uncomment in core.php and give it another shot. persistModel only applies to controllers? I am running a Shell/Task here. The data is different actually. I am going through millions of data and whenever it errors out, I just pick up from where it left off. I don't know if the fact that the loop is done in a shell but the majority of the operations occur in a task have anything to do with it: Shell code (ImportMine is a task): foreach ($mine_data as $mine) { .. $this->ImportMine->import($name, $artist, $album, $genre, $mine['Mine']['id']); .. } Thanks. On Nov 22, 12:47 pm, Jeremy Burns | Class Outfit wrote: > I would go one further and uncomment line 94 in /app/config/core.php: > > Configure::write('Cache.disable', true); > > Have you got persistModel set to true? If so, set that to false. > > If the code is still breaking (I am assuming that you are always testing with > exactly the same data?) but at a different place each time, I'd find it > difficult to pin it down to code which at the end of the day is plain old > hard logic and then ought to be repeatable. What else have you got either in > your code or elsewhere in your environment that is variable? > > Jeremy Burns > Class Outfit > > jeremybu...@classoutfit.comhttp://www.classoutfit.com > > On 22 Nov 2010, at 20:39, qua...@gmail.com wrote: > > > Empty cache yes, Disable cache? I do set cacheQueries to false if that > > is what you meant. Thanks. > > > On Nov 22, 12:26 pm, Jeremy Burns | Class Outfit > > wrote: > >> And did you empty the cache, disable the cache, etc etc as suggested > >> earlier? > > >> Jeremy Burns > >> Class Outfit > > >> jeremybu...@classoutfit.comhttp://www.classoutfit.com > > >> On 22 Nov 2010, at 20:18, qua...@gmail.com wrote: > > >>> Here is all the code: > >>> $this->out("this->Album->field('Album.library_count')"); > >>> $this->Album->id = $album_id; > >>> $library_count = $this->Album->field('Album.library_count'); > >>> $this->out('Get Album library count and it is: ' . $library_count); > > >>> The final out statement produced only "Get Album library count and it > >>> is: " as I think $library_count is false or null at that point. > > >>> Here is full SQL warning message: > >>> Warning: SQL Error: 1054: Unknown column 'Song.artist_id' in 'where > >>> clause' in /svr/web/cake1.3.6/cake/libs/model/datasources/ > >>> dbo_source.php on line 684 > >>> Query: SELECT `Album`.`library_count` FROM `albums` AS `Album` WHERE > >>> `Song`.`artist_id` = 7590 AND `Song`.`name` = 'One Thing Leads to > >>> Another' LIMIT 1 > > >>> Thanks. > > >>> On Nov 22, 12:10 pm, Jeremy Burns | Class Outfit > >>> wrote: > >>>> Is this ALL of the SQL being produced or just an extract? > > >>>> What happens if you do: > > >>>> echo $this->Album->field('Album.library_count'); > >>>> or > >>>> $variable = $this->Album->field('Album.library_count'); > > >>>> ...instead of: > >>>> $this->Album->field('Album.library_count'); > > >>>> (or is this code just an extraction?) > > >>>> Jeremy Burns > >>>> Class Outfit > > >>>> jeremybu...@classoutfit.comhttp://www.classoutfit.com > > >>>> On 22 Nov 2010, at 20:05, qua...@gmail.com wrote: > > >>>>> As I said before, I WANT this to be my problem; I want to know I made > >>>>> the right choice picking Cake as the framework. I want to know that I > >>>>> screw up and not Cake. > > >>>>> The problem is repeatable in the sense that it will always happen...it > >>>>> may happen 20 minuses into the loop or as long as an hour before it > >>>>> hits the snag. And it doesn't just occur in a specific portion of the > >>>>> loop; it is all over the places. > > >>>>> In the loop, I do bunch of Find and Save operations. I have tons of > >>>>> debug statements and that is how I can tell you guys what code > >>>>> generated what erroneous SQL. > > >>>>> I posted model associations as well and it is simple really. > > >>>>> Let's look at my last error again. > > >&
Re: CakePHP Model uses the wrong fields in SQL statements!
Empty cache yes, Disable cache? I do set cacheQueries to false if that is what you meant. Thanks. On Nov 22, 12:26 pm, Jeremy Burns | Class Outfit wrote: > And did you empty the cache, disable the cache, etc etc as suggested earlier? > > Jeremy Burns > Class Outfit > > jeremybu...@classoutfit.comhttp://www.classoutfit.com > > On 22 Nov 2010, at 20:18, qua...@gmail.com wrote: > > > Here is all the code: > > $this->out("this->Album->field('Album.library_count')"); > > $this->Album->id = $album_id; > > $library_count = $this->Album->field('Album.library_count'); > > $this->out('Get Album library count and it is: ' . $library_count); > > > The final out statement produced only "Get Album library count and it > > is: " as I think $library_count is false or null at that point. > > > Here is full SQL warning message: > > Warning: SQL Error: 1054: Unknown column 'Song.artist_id' in 'where > > clause' in /svr/web/cake1.3.6/cake/libs/model/datasources/ > > dbo_source.php on line 684 > > Query: SELECT `Album`.`library_count` FROM `albums` AS `Album` WHERE > > `Song`.`artist_id` = 7590 AND `Song`.`name` = 'One Thing Leads to > > Another' LIMIT 1 > > > Thanks. > > > On Nov 22, 12:10 pm, Jeremy Burns | Class Outfit > > wrote: > >> Is this ALL of the SQL being produced or just an extract? > > >> What happens if you do: > > >> echo $this->Album->field('Album.library_count'); > >> or > >> $variable = $this->Album->field('Album.library_count'); > > >> ...instead of: > >> $this->Album->field('Album.library_count'); > > >> (or is this code just an extraction?) > > >> Jeremy Burns > >> Class Outfit > > >> jeremybu...@classoutfit.comhttp://www.classoutfit.com > > >> On 22 Nov 2010, at 20:05, qua...@gmail.com wrote: > > >>> As I said before, I WANT this to be my problem; I want to know I made > >>> the right choice picking Cake as the framework. I want to know that I > >>> screw up and not Cake. > > >>> The problem is repeatable in the sense that it will always happen...it > >>> may happen 20 minuses into the loop or as long as an hour before it > >>> hits the snag. And it doesn't just occur in a specific portion of the > >>> loop; it is all over the places. > > >>> In the loop, I do bunch of Find and Save operations. I have tons of > >>> debug statements and that is how I can tell you guys what code > >>> generated what erroneous SQL. > > >>> I posted model associations as well and it is simple really. > > >>> Let's look at my last error again. > > >>> Code: > >>> $this->Album->id = $album_id; > >>> $this->Album->field('Album.library_count'); > > >>> SQL: > >>> SELECT `Album`.`library_count` FROM `albums` AS `Album` WHERE > >>> `Song`.`artist_id` = 7590 AND `Song`.`name` = 'One Thing Leads to > >>> Another' LIMIT 1 > > >>> I specify an ID and field() the model for the data. It really can't > >>> get simpler than that and yet it still produced wrong SQL. Cake is > >>> trying to be too smart there? > > >>> Thanks. > > >>> On Nov 22, 11:36 am, Jeremy Burns | Class Outfit > >>> wrote: > >>>> If this were a genuine problem there'd be lots of people complaining - > >>>> this is one of the fundamentals of any app. As much as you can't see it > >>>> now and don't want to hear it, the problem DOES lie in your code, > >>>> somewhere. > > >>>> Are the failures you have specified repeatable? In other words, does it > >>>> always fail at the same point(s)? Are you doing any data manipulation as > >>>> part of the loop? If so, are you taking account of the changed data for > >>>> the rest of the loop? What happens if you disable any data modifying > >>>> code? > > >>>> Here's what I'd do (some of this has already been suggested - not sure > >>>> if you followed them through): > >>>> - Clear all of my caches > >>>> - Turn caching off > >>>> - Download the latest version of Cake (or a clean copy of the version I > >>>> am using) and replace the contents of my Cake directory with the c
Re: CakePHP Model uses the wrong fields in SQL statements!
Here is all the code: $this->out("this->Album->field('Album.library_count')"); $this->Album->id = $album_id; $library_count = $this->Album->field('Album.library_count'); $this->out('Get Album library count and it is: ' . $library_count); The final out statement produced only "Get Album library count and it is: " as I think $library_count is false or null at that point. Here is full SQL warning message: Warning: SQL Error: 1054: Unknown column 'Song.artist_id' in 'where clause' in /svr/web/cake1.3.6/cake/libs/model/datasources/ dbo_source.php on line 684 Query: SELECT `Album`.`library_count` FROM `albums` AS `Album` WHERE `Song`.`artist_id` = 7590 AND `Song`.`name` = 'One Thing Leads to Another'LIMIT 1 Thanks. On Nov 22, 12:10 pm, Jeremy Burns | Class Outfit wrote: > Is this ALL of the SQL being produced or just an extract? > > What happens if you do: > > echo $this->Album->field('Album.library_count'); > or > $variable = $this->Album->field('Album.library_count'); > > ...instead of: > $this->Album->field('Album.library_count'); > > (or is this code just an extraction?) > > Jeremy Burns > Class Outfit > > jeremybu...@classoutfit.comhttp://www.classoutfit.com > > On 22 Nov 2010, at 20:05, qua...@gmail.com wrote: > > > As I said before, I WANT this to be my problem; I want to know I made > > the right choice picking Cake as the framework. I want to know that I > > screw up and not Cake. > > > The problem is repeatable in the sense that it will always happen...it > > may happen 20 minuses into the loop or as long as an hour before it > > hits the snag. And it doesn't just occur in a specific portion of the > > loop; it is all over the places. > > > In the loop, I do bunch of Find and Save operations. I have tons of > > debug statements and that is how I can tell you guys what code > > generated what erroneous SQL. > > > I posted model associations as well and it is simple really. > > > Let's look at my last error again. > > > Code: > > $this->Album->id = $album_id; > > $this->Album->field('Album.library_count'); > > > SQL: > > SELECT `Album`.`library_count` FROM `albums` AS `Album` WHERE > > `Song`.`artist_id` = 7590 AND `Song`.`name` = 'One Thing Leads to > > Another' LIMIT 1 > > > I specify an ID and field() the model for the data. It really can't > > get simpler than that and yet it still produced wrong SQL. Cake is > > trying to be too smart there? > > > Thanks. > > > On Nov 22, 11:36 am, Jeremy Burns | Class Outfit > > wrote: > >> If this were a genuine problem there'd be lots of people complaining - > >> this is one of the fundamentals of any app. As much as you can't see it > >> now and don't want to hear it, the problem DOES lie in your code, > >> somewhere. > > >> Are the failures you have specified repeatable? In other words, does it > >> always fail at the same point(s)? Are you doing any data manipulation as > >> part of the loop? If so, are you taking account of the changed data for > >> the rest of the loop? What happens if you disable any data modifying code? > > >> Here's what I'd do (some of this has already been suggested - not sure if > >> you followed them through): > >> - Clear all of my caches > >> - Turn caching off > >> - Download the latest version of Cake (or a clean copy of the version I am > >> using) and replace the contents of my Cake directory with the clean, > >> fresh, untouched one > >> - Check my model associations; do I have belongsTo and hasMany the wrong > >> way around - it can happen, and even one instance could be enough to trip > >> it up > >> - Check that I don't have any joins of routes or queries - anything - hard > >> coded that could be causing this > >> - Examine my looping code using debug statements > >> - Strip the code down to the bone and gradually build back up until it > >> breaks > > >> Jeremy Burns > >> Class Outfit > > >> jeremybu...@classoutfit.comhttp://www.classoutfit.com > > >> On 22 Nov 2010, at 19:20, qua...@gmail.com wrote: > > >>> Ran into another stop. > > >>> Code: > >>> $this->Album->id = $album_id; > >>> $this->Album->field('Album.library_count'); > > >>> SQL: > >>> SELECT `Album`.`library_count`
Re: CakePHP Model uses the wrong fields in SQL statements!
As I said before, I WANT this to be my problem; I want to know I made the right choice picking Cake as the framework. I want to know that I screw up and not Cake. The problem is repeatable in the sense that it will always happen...it may happen 20 minuses into the loop or as long as an hour before it hits the snag. And it doesn't just occur in a specific portion of the loop; it is all over the places. In the loop, I do bunch of Find and Save operations. I have tons of debug statements and that is how I can tell you guys what code generated what erroneous SQL. I posted model associations as well and it is simple really. Let's look at my last error again. Code: $this->Album->id = $album_id; $this->Album->field('Album.library_count'); SQL: SELECT `Album`.`library_count` FROM `albums` AS `Album` WHERE `Song`.`artist_id` = 7590 AND `Song`.`name` = 'One Thing Leads to Another'LIMIT 1 I specify an ID and field() the model for the data. It really can't get simpler than that and yet it still produced wrong SQL. Cake is trying to be too smart there? Thanks. On Nov 22, 11:36 am, Jeremy Burns | Class Outfit wrote: > If this were a genuine problem there'd be lots of people complaining - this > is one of the fundamentals of any app. As much as you can't see it now and > don't want to hear it, the problem DOES lie in your code, somewhere. > > Are the failures you have specified repeatable? In other words, does it > always fail at the same point(s)? Are you doing any data manipulation as part > of the loop? If so, are you taking account of the changed data for the rest > of the loop? What happens if you disable any data modifying code? > > Here's what I'd do (some of this has already been suggested - not sure if you > followed them through): > - Clear all of my caches > - Turn caching off > - Download the latest version of Cake (or a clean copy of the version I am > using) and replace the contents of my Cake directory with the clean, fresh, > untouched one > - Check my model associations; do I have belongsTo and hasMany the wrong way > around - it can happen, and even one instance could be enough to trip it up > - Check that I don't have any joins of routes or queries - anything - hard > coded that could be causing this > - Examine my looping code using debug statements > - Strip the code down to the bone and gradually build back up until it breaks > > Jeremy Burns > Class Outfit > > jeremybu...@classoutfit.comhttp://www.classoutfit.com > > On 22 Nov 2010, at 19:20, qua...@gmail.com wrote: > > > Ran into another stop. > > > Code: > > $this->Album->id = $album_id; > > $this->Album->field('Album.library_count'); > > > SQL: > > SELECT `Album`.`library_count` FROM `albums` AS `Album` WHERE > > `Song`.`artist_id` = 7590 AND `Song`.`name` = 'One Thing Leads to > > Another' LIMIT 1 > > > I probably will need to write custom queries myself instead of relying > > on Cake to do the right thing for me. > > > On Nov 22, 10:35 am, "qua...@gmail.com" wrote: > >> I am gong to try with recursive = -1. > > >> Thanks. > > >> On Nov 22, 9:35 am, John Andersen wrote: > > >>> Have recreated a test environment with your tables and models in > >>> accordance with your specified model associations. Added some very few > >>> test data and executed some of your find statements, to see if I could > >>> make it produce the same (erroneous) SQL statements. > > >>> Testing using the code below: > >>> [code] > >>> $this->Song->recursive = -1; > >>> for($i = 0; $i < 3500; $i++){ > >>> $this->Song->find( > >>> 'first', array( > >>> 'conditions' => array( > >>> 'Song.artist_id' => rand(1,2), > >>> 'Song.name' => 'Song number '.rand(1,7) > >>> ), > >>> 'fields' => array('Song.id', 'Song.name') > >>> ) > >>> );} > > >>> [/code] > > >>> After having executed more than 2 find statements, I still could > >>> not see any erroneous SQL statement. All created statements looks like > >>> this: > >>> [code] > >>> SELECT `Song`.`id`, `Song`.`name` FROM `songs` AS `Song` WHERE > >>> `Song`.`artist_id` = 2 AND `Song`.`name` = 'Song number 5' LIMIT 1 > >>> [/code] > > >>> Testing using the code below (from Song co
Re: CakePHP Model uses the wrong fields in SQL statements!
Ran into another stop. Code: $this->Album->id = $album_id; $this->Album->field('Album.library_count'); SQL: SELECT `Album`.`library_count` FROM `albums` AS `Album` WHERE `Song`.`artist_id` = 7590 AND `Song`.`name` = 'One Thing Leads to Another'LIMIT 1 I probably will need to write custom queries myself instead of relying on Cake to do the right thing for me. On Nov 22, 10:35 am, "qua...@gmail.com" wrote: > I am gong to try with recursive = -1. > > Thanks. > > On Nov 22, 9:35 am, John Andersen wrote: > > > Have recreated a test environment with your tables and models in > > accordance with your specified model associations. Added some very few > > test data and executed some of your find statements, to see if I could > > make it produce the same (erroneous) SQL statements. > > > Testing using the code below: > > [code] > > $this->Song->recursive = -1; > > for($i = 0; $i < 3500; $i++){ > > $this->Song->find( > > 'first', array( > > 'conditions' => array( > > 'Song.artist_id' => rand(1,2), > > 'Song.name' => 'Song number '.rand(1,7) > > ), > > 'fields' => array('Song.id', 'Song.name') > > ) > > );} > > > [/code] > > > After having executed more than 2 find statements, I still could > > not see any erroneous SQL statement. All created statements looks like > > this: > > [code] > > SELECT `Song`.`id`, `Song`.`name` FROM `songs` AS `Song` WHERE > > `Song`.`artist_id` = 2 AND `Song`.`name` = 'Song number 5' LIMIT 1 > > [/code] > > > Testing using the code below (from Song controller): > > [code] > > $this->Song->AlbumSong->recursive = -1; > > for($i = 0; $i < 3500; $i++){ > > $this->Song->AlbumSong->find( > > 'count', array( > > 'conditions' => array( > > 'AlbumSong.album_id' => rand(1,3), > > 'AlbumSong.song_id' => rand(1,7) > > ) > > ) > > );} > > > [/code] > > > After having executed more than 2 find statements, I still could > > not see any erroneous SQL statement. All created statements looks like > > this: > > [code] > > SELECT COUNT(*) AS `count` FROM `albums_songs` AS `AlbumSong` WHERE > > `AlbumSong`.`album_id` = 3 AND `AlbumSong`.`song_id` = 4 > > [/code] > > > My environment: > > Apache/2.2.14 > > PHP 5.3.1 > > MySQL 5.0.5 > > CakePHP 1.3.2 > > > Enjoy, > > John > > > On 21 Nov., 19:51, "qua...@gmail.com" wrote: > > > > Here are model setup: > > > > models/album.php > > > > > > class Album extends AppModel { > > > var $name = 'Album'; > > > var $belongsTo = array( > > > 'Artist' => array( > > > 'className' => 'Artist', > > > 'foreignKey' => 'artist_id', > > > 'conditions' => '', > > > 'fields' => '', > > > 'order' => '' > > > ) > > > ); > > > > var $hasAndBelongsToMany = array( > > > 'Song' => array( > > > 'className' => 'Song', > > > 'joinTable' => 'albums_songs', > > > 'foreignKey' => 'album_id', > > > 'associationForeignKey' => 'song_id', > > > 'unique' => true, > > > 'conditions' => '', > > > 'fields' => '', > > > 'order' => '', > > > 'limit' => '', > > > 'offset' => '', > > > 'finderQuery' => '', > > > 'deleteQuery' => '', > > > 'inser
Re: CakePHP Model uses the wrong fields in SQL statements!
I am gong to try with recursive = -1. Thanks. On Nov 22, 9:35 am, John Andersen wrote: > Have recreated a test environment with your tables and models in > accordance with your specified model associations. Added some very few > test data and executed some of your find statements, to see if I could > make it produce the same (erroneous) SQL statements. > > Testing using the code below: > [code] > $this->Song->recursive = -1; > for($i = 0; $i < 3500; $i++){ > $this->Song->find( > 'first', array( > 'conditions' => array( > 'Song.artist_id' => rand(1,2), > 'Song.name' => 'Song number '.rand(1,7) > ), > 'fields' => array('Song.id', 'Song.name') > ) > );} > > [/code] > > After having executed more than 2 find statements, I still could > not see any erroneous SQL statement. All created statements looks like > this: > [code] > SELECT `Song`.`id`, `Song`.`name` FROM `songs` AS `Song` WHERE > `Song`.`artist_id` = 2 AND `Song`.`name` = 'Song number 5' LIMIT 1 > [/code] > > Testing using the code below (from Song controller): > [code] > $this->Song->AlbumSong->recursive = -1; > for($i = 0; $i < 3500; $i++){ > $this->Song->AlbumSong->find( > 'count', array( > 'conditions' => array( > 'AlbumSong.album_id' => rand(1,3), > 'AlbumSong.song_id' => rand(1,7) > ) > ) > );} > > [/code] > > After having executed more than 2 find statements, I still could > not see any erroneous SQL statement. All created statements looks like > this: > [code] > SELECT COUNT(*) AS `count` FROM `albums_songs` AS `AlbumSong` WHERE > `AlbumSong`.`album_id` = 3 AND `AlbumSong`.`song_id` = 4 > [/code] > > My environment: > Apache/2.2.14 > PHP 5.3.1 > MySQL 5.0.5 > CakePHP 1.3.2 > > Enjoy, > John > > On 21 Nov., 19:51, "qua...@gmail.com" wrote: > > > Here are model setup: > > > models/album.php > > > > class Album extends AppModel { > > var $name = 'Album'; > > var $belongsTo = array( > > 'Artist' => array( > > 'className' => 'Artist', > > 'foreignKey' => 'artist_id', > > 'conditions' => '', > > 'fields' => '', > > 'order' => '' > > ) > > ); > > > var $hasAndBelongsToMany = array( > > 'Song' => array( > > 'className' => 'Song', > > 'joinTable' => 'albums_songs', > > 'foreignKey' => 'album_id', > > 'associationForeignKey' => 'song_id', > > 'unique' => true, > > 'conditions' => '', > > 'fields' => '', > > 'order' => '', > > 'limit' => '', > > 'offset' => '', > > 'finderQuery' => '', > > 'deleteQuery' => '', > > 'insertQuery' => '' > > ) > > ); > > > var $hasMany = array( > > 'AlbumSong' => array( > > 'className' => 'AlbumSong', > > 'foreignKey' => 'album_id', > > 'dependent' => false, > > 'conditions' => '', > > 'fields' => '', > > 'order' => '', > > 'limit' => '', > > 'offset' => '', > > 'exclusive' => '', > >
Re: CakePHP Model uses the wrong fields in SQL statements!
By the way, it is looking like this bug: http://cakephp.lighthouseapp.com/projects/42648/tickets/1069-occasional-rare-hard-to-trace-bug-sql-with-wrong-column-names-generated On Nov 21, 10:51 am, "qua...@gmail.com" wrote: > Here are model setup: > > models/album.php > > class Album extends AppModel { > var $name = 'Album'; > var $belongsTo = array( > 'Artist' => array( > 'className' => 'Artist', > 'foreignKey' => 'artist_id', > 'conditions' => '', > 'fields' => '', > 'order' => '' > ) > ); > > var $hasAndBelongsToMany = array( > 'Song' => array( > 'className' => 'Song', > 'joinTable' => 'albums_songs', > 'foreignKey' => 'album_id', > 'associationForeignKey' => 'song_id', > 'unique' => true, > 'conditions' => '', > 'fields' => '', > 'order' => '', > 'limit' => '', > 'offset' => '', > 'finderQuery' => '', > 'deleteQuery' => '', > 'insertQuery' => '' > ) > ); > > var $hasMany = array( > 'AlbumSong' => array( > 'className' => 'AlbumSong', > 'foreignKey' => 'album_id', > 'dependent' => false, > 'conditions' => '', > 'fields' => '', > 'order' => '', > 'limit' => '', > 'offset' => '', > 'exclusive' => '', > 'finderQuery' => '', > 'counterQuery' => '' > ) > );} > > ?> > > models/album_song.php > > class AlbumSong extends AppModel { > var $name = 'AlbumSong'; > var $useTable = 'albums_songs'; > var $belongsTo = array( > 'Song' => array( > 'className' => 'Song', > 'foreignKey' => 'song_id', > 'conditions' => '', > 'fields' => '', > 'order' => '' > ), > 'Album' => array( > 'className' => 'Album', > 'foreignKey' => 'album_id', > 'conditions' => '', > 'fields' => '', > 'order' => '' > ) > );} > > ?> > > models/artist.php > class Artist extends AppModel { > var $name = 'Artist'; > var $hasMany = array( > 'Album' => array( > 'className' => 'Album', > 'foreignKey' => 'artist_id', > 'dependent' => false, > 'conditions' => '', > 'fields' => '', > 'order' => '', > 'limit' => '', > 'offset' => '', > 'exclusive' => '', > 'finderQuery' => '', > 'counte
Re: CakePHP Model uses the wrong fields in SQL statements!
27;, 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'exclusive' => '', 'finderQuery' => '', 'counterQuery' => '' ) ); } ?> models/artist_genre.php array( 'className' => 'Artist', 'foreignKey' => 'artist_id', 'conditions' => '', 'fields' => '', 'order' => '' ), 'Genre' => array( 'className' => 'Genre', 'foreignKey' => 'genre_id', 'conditions' => '', 'fields' => '', 'order' => '' ) ); } ?> models/genre.php array( 'className' => 'Artist', 'joinTable' => 'artists_genres', 'foreignKey' => 'genre_id', 'associationForeignKey' => 'artist_id', 'unique' => true, 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'finderQuery' => '', 'deleteQuery' => '', 'insertQuery' => '' ) ); var $hasMany = array( 'ArtistGenre' => array( 'className' => 'ArtistGenre', 'foreignKey' => 'genre_id', 'dependent' => false, 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'exclusive' => '', 'finderQuery' => '', 'counterQuery' => '' ) ); } ?> models/song.php array( 'className' => 'Artist', 'foreignKey' => 'artist_id', 'conditions' => '', 'fields' => '', 'order' => '' ) ); /* var $hasAndBelongsToMany = array( 'Album' => array( 'className' => 'Album', 'joinTable' => 'albums_songs', 'foreignKey' => 'song_id', 'associationForeignKey' => 'album_id', 'unique' => true, 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'finderQuery' => '', 'deleteQuery' => '', 'insertQuery' => '' ) ); */ var $hasMany = array( 'AlbumSong' => array( 'className' => 'AlbumSong', 'foreignKey' => 'song_id', 'dependent' => false, 'conditions' => '', 'fields' => '', 'order' => '', 'limit&
Re: CakePHP Model uses the wrong fields in SQL statements!
More "bad" example: Code is: $this->AlbumSong->find('count', array('conditions' => array('AlbumSong.album_id' => 48784, 'AlbumSong.song_id' => 846847))) Yet, the SQL is: SELECT COUNT(*) AS `count` FROM `albums_songs` AS `AlbumSong` WHERE `Song`.`name` = 'Garota de Ipanema' AND `Song`.`artist_id` = 5123 It makes no sense to me at all. I really want this to be MY mistake and not Cake's because I need to trust Cake in my projects. Please help. On Nov 19, 12:10 am, "qua...@gmail.com" wrote: > I am still having the same problem. I looked thruough the SQL > statements and even on good ones such as this one: > UPDATE `genres` SET `source_id` = 0, `id` = 273, `library_count` = > 556, `modified` = '2010-11-18 23:08:02' WHERE `genres`.`id` = 273 > > It still looks bad to me. Why would Cake set id to 273 when WHERE is > already saying it is updating Genre id 273? > > I also see statements like this 3 in a row: > SELECT COUNT(*) AS `count` FROM `genres` AS `Genre` WHERE > `Genre`.`id` = 273 > SELECT COUNT(*) AS `count` FROM `genres` AS `Genre` WHERE > `Genre`.`id` = 273 > SELECT COUNT(*) AS `count` FROM `genres` AS `Genre` WHERE > `Genre`.`id` = 273 > > Why? What would prompt Cake to execute that three 3 times in a row? > > I'm very frustrated at this point. I don't know how I can trust Cake > to deal with my data anymore... > > On Nov 17, 9:36 am, "qua...@gmail.com" wrote: > > > Thanks I will try them. > > > The weird thing is I can't reproduce it consistently...I mean it WILL > > happen eventually, but WHERE and WHEN it happens is never the same. > > > By the way, can models have both HABTM and hasMany-Thru relationships > > at same time? > > > On Nov 17, 8:49 am, keymaster wrote: > > > > Weird. > > > > Things I might try: > > > > 1. clear all cached files, models, cake core persistent files, and > > > session files in tmp/ then try again > > > 2. try with debug off, then turn it back on. > > > 3. do you have any weird, unusual inheritance going on in the app, > > > with models? > > > 4. check your associations > > > 5. check your $useTable > > > 6. check the schema var to see what cake things your tables look like. > > > 7. if you are passing field names to cake in variables, check the > > > contents of the variable to see it is not your code. > > > 8. Try to reproduce the problem as consistently as you can, then > > > simplify to the bone, cut models, associations, etc. to narrow down. > > > If you can produce a simple testcase that fails, open a ticket in > > > lighthouse. > > > > On Nov 16, 8:45 pm, cricket wrote: > > > > > On Tue, Nov 16, 2010 at 1:37 PM, qua...@gmail.com > > > > wrote: > > > > > I do call Create() before any Save operation. You think I need to do > > > > > that even for Read operation? > > > > > Possibly. Are you reading inside a loop? But I won't speculate without > > > > seeing more code. 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 Model uses the wrong fields in SQL statements!
I am still having the same problem. I looked thruough the SQL statements and even on good ones such as this one: UPDATE `genres` SET `source_id` = 0, `id` = 273, `library_count` = 556, `modified` = '2010-11-18 23:08:02' WHERE `genres`.`id` = 273 It still looks bad to me. Why would Cake set id to 273 when WHERE is already saying it is updating Genre id 273? I also see statements like this 3 in a row: SELECT COUNT(*) AS `count` FROM `genres` AS `Genre` WHERE `Genre`.`id` = 273 SELECT COUNT(*) AS `count` FROM `genres` AS `Genre` WHERE `Genre`.`id` = 273 SELECT COUNT(*) AS `count` FROM `genres` AS `Genre` WHERE `Genre`.`id` = 273 Why? What would prompt Cake to execute that three 3 times in a row? I'm very frustrated at this point. I don't know how I can trust Cake to deal with my data anymore... On Nov 17, 9:36 am, "qua...@gmail.com" wrote: > Thanks I will try them. > > The weird thing is I can't reproduce it consistently...I mean it WILL > happen eventually, but WHERE and WHEN it happens is never the same. > > By the way, can models have both HABTM and hasMany-Thru relationships > at same time? > > On Nov 17, 8:49 am, keymaster wrote: > > > Weird. > > > Things I might try: > > > 1. clear all cached files, models, cake core persistent files, and > > session files in tmp/ then try again > > 2. try with debug off, then turn it back on. > > 3. do you have any weird, unusual inheritance going on in the app, > > with models? > > 4. check your associations > > 5. check your $useTable > > 6. check the schema var to see what cake things your tables look like. > > 7. if you are passing field names to cake in variables, check the > > contents of the variable to see it is not your code. > > 8. Try to reproduce the problem as consistently as you can, then > > simplify to the bone, cut models, associations, etc. to narrow down. > > If you can produce a simple testcase that fails, open a ticket in > > lighthouse. > > > On Nov 16, 8:45 pm, cricket wrote: > > > > On Tue, Nov 16, 2010 at 1:37 PM, qua...@gmail.com > > > wrote: > > > > I do call Create() before any Save operation. You think I need to do > > > > that even for Read operation? > > > > Possibly. Are you reading inside a loop? But I won't speculate without > > > seeing more code. 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: Multiple REGEXP on same field in Find conditions
My conditions look like: array('Artist.name NOT REGEXP' => "^various"), array('Artist.name NOT REGEXP' => ".com$"), array('Artist.name NOT REGEXP' => "^unknown"), array('Artist.name NOT REGEXP' => "^$"), array('Artist.name NOT REGEXP' => "^Va$"), array('Artist.name NOT REGEXP' => "^No Artist"), array('Artist.name NOT REGEXP' => "^Varios"), array('Artist.name NOT REGEXP' => "^artist$") If they can be combined into one regexp then that would be great. It is simpler this way for me. On Nov 17, 2:16 pm, AD7six wrote: > On Nov 17, 10:22 pm, "qua...@gmail.com" wrote: > > > Thanks. Array of array works! > > Doesn't address the needless use of two regexs though - NOT REGEXP > '.com|Various' does the same thing. > > AD 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: Multiple REGEXP on same field in Find conditions
Thanks. Array of array works! On Nov 17, 12:50 pm, euromark wrote: > http://www.dereuromark.de/2010/10/07/cakephp-beginner-tips/ > "find conditions" > > On 17 Nov., 21:12, "qua...@gmail.com" wrote: > > > Hi all, > > > I need to filter the result based on a set of regular expressions. For > > example, I want to find a list of names that do not contain the word > > "various" and ".com". So I have: > > > $this->find('all', array('conditions' => array('Artist.name NOT > > REGEXP' => "Various", > > 'Artist.name > > NOT REGEXP' => ".com"))); > > > However, CakePHP only sees the second NOT REGEXP for ".com" only. I > > guess Cake sees the first one as duplicate and discard it. The > > resulted query is: > > > SELECT * FROM `artists` AS `Artist` WHERE `Artist`.`name` NOT REGEXP > > '.com' > > > Is there any way to accomplish what I want to do to get: > > > SELECT * FROM `artists` AS `Artist` WHERE `Artist`.`name` NOT REGEXP > > '.com' AND `Artist`.`name` NOT REGEXP 'Various' > > > 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
Multiple REGEXP on same field in Find conditions
Hi all, I need to filter the result based on a set of regular expressions. For example, I want to find a list of names that do not contain the word "various" and ".com". So I have: $this->find('all', array('conditions' => array('Artist.name NOT REGEXP' => "Various", 'Artist.name NOT REGEXP' => ".com"))); However, CakePHP only sees the second NOT REGEXP for ".com" only. I guess Cake sees the first one as duplicate and discard it. The resulted query is: SELECT * FROM `artists` AS `Artist` WHERE `Artist`.`name` NOT REGEXP '.com' Is there any way to accomplish what I want to do to get: SELECT * FROM `artists` AS `Artist` WHERE `Artist`.`name` NOT REGEXP '.com' AND `Artist`.`name` NOT REGEXP 'Various' 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: CakePHP Model uses the wrong fields in SQL statements!
Thanks I will try them. The weird thing is I can't reproduce it consistently...I mean it WILL happen eventually, but WHERE and WHEN it happens is never the same. By the way, can models have both HABTM and hasMany-Thru relationships at same time? On Nov 17, 8:49 am, keymaster wrote: > Weird. > > Things I might try: > > 1. clear all cached files, models, cake core persistent files, and > session files in tmp/ then try again > 2. try with debug off, then turn it back on. > 3. do you have any weird, unusual inheritance going on in the app, > with models? > 4. check your associations > 5. check your $useTable > 6. check the schema var to see what cake things your tables look like. > 7. if you are passing field names to cake in variables, check the > contents of the variable to see it is not your code. > 8. Try to reproduce the problem as consistently as you can, then > simplify to the bone, cut models, associations, etc. to narrow down. > If you can produce a simple testcase that fails, open a ticket in > lighthouse. > > On Nov 16, 8:45 pm, cricket wrote: > > > On Tue, Nov 16, 2010 at 1:37 PM, qua...@gmail.com wrote: > > > I do call Create() before any Save operation. You think I need to do > > > that even for Read operation? > > > Possibly. Are you reading inside a loop? But I won't speculate without > > seeing more code. 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 Model uses the wrong fields in SQL statements!
I do call Create() before any Save operation. You think I need to do that even for Read operation? Thanks. On Nov 16, 10:18 am, cricket wrote: > On Tue, Nov 16, 2010 at 12:50 PM, qua...@gmail.com wrote: > > Hi, > > > I have a bunch of models with various associations set up between them > > and seems like Cakephp at times executes incorrect SQL statement and > > cause MySQL to barf. > > > Please refer the the "EDIT" followed by this to see some examples of > > the problem. > > > It doesn't happen all the time but it eventually happens since I am > > doing everything in a tight loop. > > Difficult to say without seeing more code (and your model relations) > but my first guess is that you're not calling Model->create() during > each iteration. But I suppose this could be due to some incorrect > associations, also. 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 Model uses the wrong fields in SQL statements!
No, it doesn't happen to every calls. I start the loop, and eventually it will fail due to incorrect SQL statement executed. And it happens all over the places as you can see from my examples. Thanks. On Nov 16, 10:20 am, Bogdan Bursuc wrote: > I think there is an explanation to this. To me it seems just imposibile to > generate this. Something somewhere is certainly wrong. And I don't thing > cake is. Why not check the core ? > > For example try: recursive => -1 > See if happens again. > > Does this happens on every call ? > > > > On Tue, Nov 16, 2010 at 7:50 PM, qua...@gmail.com wrote: > > Hi, > > > I have a bunch of models with various associations set up between them > > and seems like Cakephp at times executes incorrect SQL statement and > > cause MySQL to barf. > > > Please refer the the "EDIT" followed by this to see some examples of > > the problem. > > > It doesn't happen all the time but it eventually happens since I am > > doing everything in a tight loop. > > > Please help. This really makes me question my decision to go with Cake > > since this sounds bad. > > > Thanks. > > > EDIT 1 I just ran into the problem and here is the faulty SQL: > > > SELECT COUNT(*) AS `count` FROM `albums_songs` AS `AlbumSong` WHERE > > `ArtistGenre`.`id` = 26482 > > > AlbumSong and ArtistGenre are two completely separate tables and they > > are not related at all. > > > EDIT 2 Just ran into another failure. The code is: > > > $this->Song->find('first', array('conditions' => > > array('Song.artist_id' => 30188, 'Song.name' => 'Pal Pal > > (By.Tarkhanz)'), 'fields' => array('Song.id'))) > > > While the generated SQL is: > > > SELECT `Song`.`id` FROM `songs` AS `Song` WHERE `Artist`.`name` = > > 'Annie Villeneuve' LIMIT 1 > > > As you can see no were in the conditions do I specify an Artist.name > > yet the SQL generated is looking at it. > > > EDIT 3 Another example failure. Call is as followed: > > > $this->Song->id = $song_id; > > $library_count = $this->Song->field('Song.library_count'); > > > Yet the SQL is: > > > SELECT `Song`.`library_count` FROM `songs` AS `Song` WHERE > > `Artist`.`name` = 'Mazikana_Ragheb_Allama' LIMIT 1 > > > where Artist.name is not a column of Song as it belongs to the Artist > > model. > > > Thanks. > > > 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.comFor > > more options, visit this group at > >http://groups.google.com/group/cake-php?hl=en > > -- > Thanks, > Bogdan Iulian Bursuc 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 Model uses the wrong fields in SQL statements!
Hi, I have a bunch of models with various associations set up between them and seems like Cakephp at times executes incorrect SQL statement and cause MySQL to barf. Please refer the the "EDIT" followed by this to see some examples of the problem. It doesn't happen all the time but it eventually happens since I am doing everything in a tight loop. Please help. This really makes me question my decision to go with Cake since this sounds bad. Thanks. EDIT 1 I just ran into the problem and here is the faulty SQL: SELECT COUNT(*) AS `count` FROM `albums_songs` AS `AlbumSong` WHERE `ArtistGenre`.`id` = 26482 AlbumSong and ArtistGenre are two completely separate tables and they are not related at all. EDIT 2 Just ran into another failure. The code is: $this->Song->find('first', array('conditions' => array('Song.artist_id' => 30188, 'Song.name' => 'Pal Pal (By.Tarkhanz)'), 'fields' => array('Song.id'))) While the generated SQL is: SELECT `Song`.`id` FROM `songs` AS `Song` WHERE `Artist`.`name` = 'Annie Villeneuve'LIMIT 1 As you can see no were in the conditions do I specify an Artist.name yet the SQL generated is looking at it. EDIT 3 Another example failure. Call is as followed: $this->Song->id = $song_id; $library_count = $this->Song->field('Song.library_count'); Yet the SQL is: SELECT `Song`.`library_count` FROM `songs` AS `Song` WHERE `Artist`.`name` = 'Mazikana_Ragheb_Allama'LIMIT 1 where Artist.name is not a column of Song as it belongs to the Artist model. 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