Re: Pagination Problem
Try something like: $this->paginate = array( 'conditions' => array(Project.id => $ProjectIdArray), 'limit' => 20 ); $projects = $this->paginate('Project'); // debugging in controller ;-) // print_r($projects); $this->set(compact('projects')); then add the paginator links in the view (http://book.cakephp.org/view/1233/Pagination-in-Views) Andras Kende http://www.kende.com On Aug 12, 2010, at 12:24 AM, arif hossen wrote: > Dear All, > > I need pagination below query : > > $projectTable = $this->Project->findAllById($ProjectIdArray); > > Please give me suggestion.. > > -- > Regards, > Mohammad Arif Hossen > Software Enginner at > Epsilon Consulting and Development Services(ECDS) > www.ecds-tech.com > www.arifhossen.wordpress.com > Cell: +88 01714355911 > > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to cake-php@googlegroups.com > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Performance Problems using remote database
Check the database without the application, if you can, by issuing queries from the application server to the db server. Use myphpadmin or console, if its still slow you should leave cake aside and concentrate only in the database server. On Thu, Aug 12, 2010 at 7:34 AM, O.J. Tibi wrote: > Hi Thiago, > > I'll be thinking out loud here, I know you may or may not agree with > me as you're probably more experienced, but I'll still write them down > so you can hopefully get some ideas. > > 1) Caching - Have you tried turning the cache on? Or maybe one caching > engine doesn't work well with your infrastructure and you might want > to change to another engine? > > 2) Table indexes - You mentioned that before you have a 2 ~ 3,5 > response time from the app, it might be possible that you forgot to > add or change indexes in your tables? Data grows exponentially and > your indexes might no longer be relevent. A fast query from the early > days of your database may not be as fast when you have a lot of rows > inserted. > > 3) Column types and joins - The database server takes an additional > toll casting column types of foreign keys included in a join. Try to > check if your key columns are uniform. > > 4) Pulling as much data as practical - While CakePHP's caching is > superb, it can only cache views out-of-the-box. If you want to cache > your queries, pull from the database as much as practical for your > application and store it using the caching engine. If that's not > possible at the moment, set this data to the view before the view is > cached. Doing this, you will be able to do manipulations on your data > set in the view, even after the cache is generated. Remember, *only* > pull out as much data as practically possible. > > 5) Use Containable, if much is too much - More often than not, using > CakePHP's associations and how it pulls records out of a find() will > also get you the associated data with the primary model you're working > on. This may cause a lot unused data being sent over the network, > congesting it and may make your application sluggish. If you're not > using the models associated with your primary model, make sure to mark > them with the Containable behavior and flag the 'contain' key in your > find() and $this->paginate arrays accordingly. > > HTH, > OJ > > 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.comFor > more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > -- Regards, Zaky Katalan-Ezra QA Administrator www.IGeneriX.com Sites.IGeneriX.com 054-7762312 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: Performance Problems using remote database
Hi Thiago, I'll be thinking out loud here, I know you may or may not agree with me as you're probably more experienced, but I'll still write them down so you can hopefully get some ideas. 1) Caching - Have you tried turning the cache on? Or maybe one caching engine doesn't work well with your infrastructure and you might want to change to another engine? 2) Table indexes - You mentioned that before you have a 2 ~ 3,5 response time from the app, it might be possible that you forgot to add or change indexes in your tables? Data grows exponentially and your indexes might no longer be relevent. A fast query from the early days of your database may not be as fast when you have a lot of rows inserted. 3) Column types and joins - The database server takes an additional toll casting column types of foreign keys included in a join. Try to check if your key columns are uniform. 4) Pulling as much data as practical - While CakePHP's caching is superb, it can only cache views out-of-the-box. If you want to cache your queries, pull from the database as much as practical for your application and store it using the caching engine. If that's not possible at the moment, set this data to the view before the view is cached. Doing this, you will be able to do manipulations on your data set in the view, even after the cache is generated. Remember, *only* pull out as much data as practically possible. 5) Use Containable, if much is too much - More often than not, using CakePHP's associations and how it pulls records out of a find() will also get you the associated data with the primary model you're working on. This may cause a lot unused data being sent over the network, congesting it and may make your application sluggish. If you're not using the models associated with your primary model, make sure to mark them with the Containable behavior and flag the 'contain' key in your find() and $this->paginate arrays accordingly. HTH, OJ 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
Pagination Problem
Dear All, I need pagination below query : $projectTable = $this->Project->findAllById($ProjectIdArray); Please give me suggestion.. -- Regards, Mohammad Arif Hossen Software Enginner at Epsilon Consulting and Development Services(ECDS) www.ecds-tech.com www.arifhossen.wordpress.com Cell: +88 01714355911 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: Performance Problems using remote database
Thanks for the answer, Cricket. Well. I'm not using Debugger class, neither Debug > 0.(I've used to find out where the problem was happening, but I've disabled them). I've suspected of connection problems, but it's strange, because the other cakePHP Apps (using the same core) are really fast. I think I'll have to create another test environment to re-create the problem in another place to see if the poor performance will be the same. Any other ideas ?! Thanks a lot for all the help. Thiago Elias. 2010/8/11 cricket > On Wed, Aug 11, 2010 at 9:29 PM, Thiago Elias > wrote: > > Hi All, > > > > Since two or three months ago (more or less), I'm experiencing some > problems > > involving CakePHP. > > > > In the past, our application was using a local database connection, and > > performance was really nice and acceptable. Some months ago, we had to > > migrate the application to another server, separating the Data and the > Apps. > > > > After this change, I've lost performance in my cake App. Each request > takes > > around 10 ~ 15 seconds, and before, was 2 ~ 3,5 secs. > > The interesting thing is: The other legacy PHP Apps are 100% fast, and > even > > other cakeAPPs are fast too, but the difference is: My main cake app (the > > one that lost performance) have 80 innoDB Tables and 20 views. (used to > link > > to another databases). > > > > I'm using CakePHP 1.2.7, PHP 5.2. And in the Database Server, MySQL > Server > > 5.1. > > Our network infrastructure is really fast, and ping response between > servers > > is really nice. > > > > Does anyone knows why I'm losing performance just in this App when > connected > > to a remote server ?! > > Have you looked into whether the remote connection is the issue? I > mean, aside from Cake. I'd guess that you have a connection problem. > > >I'm using CakePHP Debug, and ~85% of the time spent in > > the request is lost in the CORE, and not in the app. (The core is the > same > > of the other cakeApps..) > > Having debug > 0 or using the Debugger class is *guaranteed* to slow > your app down. > > 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.comFor > more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Performance Problems using remote database
On Wed, Aug 11, 2010 at 9:29 PM, Thiago Elias wrote: > Hi All, > > Since two or three months ago (more or less), I'm experiencing some problems > involving CakePHP. > > In the past, our application was using a local database connection, and > performance was really nice and acceptable. Some months ago, we had to > migrate the application to another server, separating the Data and the Apps. > > After this change, I've lost performance in my cake App. Each request takes > around 10 ~ 15 seconds, and before, was 2 ~ 3,5 secs. > The interesting thing is: The other legacy PHP Apps are 100% fast, and even > other cakeAPPs are fast too, but the difference is: My main cake app (the > one that lost performance) have 80 innoDB Tables and 20 views. (used to link > to another databases). > > I'm using CakePHP 1.2.7, PHP 5.2. And in the Database Server, MySQL Server > 5.1. > Our network infrastructure is really fast, and ping response between servers > is really nice. > > Does anyone knows why I'm losing performance just in this App when connected > to a remote server ?! Have you looked into whether the remote connection is the issue? I mean, aside from Cake. I'd guess that you have a connection problem. >I'm using CakePHP Debug, and ~85% of the time spent in > the request is lost in the CORE, and not in the app. (The core is the same > of the other cakeApps..) Having debug > 0 or using the Debugger class is *guaranteed* to slow your app down. 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: coding a loop in cake?
On Wed, Aug 11, 2010 at 4:45 PM, McBuck DGAF wrote: > This whole process strikes me as very inefficient. There is no > mechanism to prevent your do-while loop from checking the same value > an infinite number of times (unless you log each random value and > check the next random value against the log AND the db). > > I don't know what the purpose of the random value is in your app, but > I would suggest an entirely different approach. If you need random > values in the range of "min" through "max," you could generate a table > ahead of time consisting of the fields id and random_number, with max- > min+1 rows. (There are many random number generator sites available, > and you might be able to access one of their APIs as needed.) > > It seems to me that it would be easier to generate these unique values > in some random order ahead of time, and then just associate the > random_numbers table with your current table through a 1-1 > relationship. This process would make it easy to identify the next > random number to be assigned, and when the random numbers have been > exhausted. > > Just a thought. What McBuck said. I've given you a solution but you're implementing it in a very strange way. FWIW, this: while ($eyed = $this->Linkable->validateEyed($lkbl_eyed) == "taken"); is always going to return true. Why are you assigning a value to $eyed, which is never used, in any case? That assignment is what is screwing things up. 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
Performance Problems using remote database
Hi All, Since two or three months ago (more or less), I'm experiencing some problems involving CakePHP. In the past, our application was using a local database connection, and performance was really nice and acceptable. Some months ago, we had to migrate the application to another server, separating the Data and the Apps. After this change, I've lost performance in my cake App. Each request takes around 10 ~ 15 seconds, and before, was 2 ~ 3,5 secs. The interesting thing is: The other legacy PHP Apps are 100% fast, and even other cakeAPPs are fast too, but the difference is: My main cake app (the one that lost performance) have 80 innoDB Tables and 20 views. (used to link to another databases). I'm using CakePHP 1.2.7, PHP 5.2. And in the Database Server, MySQL Server 5.1. Our network infrastructure is really fast, and ping response between servers is really nice. Does anyone knows why I'm losing performance just in this App when connected to a remote server ?! I'm using CakePHP Debug, and ~85% of the time spent in the request is lost in the CORE, and not in the app. (The core is the same of the other cakeApps..) Please help-me (and sorry for my bad english). Thiago Elias 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: Login
check $this->Auth->allow... you have enter here actions whitch dont need login W dniu 2010-08-11 22:43, alexsandro andre pisze: Good afternoon everyone! I'm having doubts about the Auth Component. My question is this when I drive to the system at address www.var.com it provides me the login screen and then redirects to the index system. Thank you all. Atenciosamente, Alexsandro André Joinville - SC 47-8825-0133 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 -- z poważaniem Marek Wojciech Urbanowicz 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: sending multiple email
i dont know how to implement it at my application. do you have some tutorial so i can implement it at my application? On Aug 5, 11:15 pm, LunarDraco wrote: > This is a working solution, however you will eventually run into > problems with this solution. The first may be browser timeout. > > Many ISP's have limits on how many emails per hour, and how much data > per hour can be sent out before you are black listed. Whats missing > from your solution is called throttling. So you don't flood the > server. > > I would suggest you use the queue pluginhttp://github.com/MSeven/cakephp_queue > to first background this work so your browser isn't waiting for it to > finish. > Once you have the work running in the background now you can take the > appropriate amount of time to process your loop and stager the emails > being sent so the email server doesn't flag you as flooding. > > On Aug 4, 1:12 am, fadhli wrote: > > > > > i found the answer. this is my code to send mail to all client. > > > function sendall() { > > $this->Client->recursive = 0; > > $this->set('clients', $this->Client->find('all')); > > foreach ($clients as $client) { > > $this->Email->reset(); > > $this->Email->to = $client['Client']['email']; > > $this->Email->subject = 'update request'; > > $this->Email->replyTo = 'no-re...@x.com'; > > $this->Email->from = 'xx '; > > $this->Email->template = 'simple_message'; > > $this->Email->sendAs = 'html'; > > $this->set('client', $client); > > $this->Email->send(); > > } > > if ( $this->Email->send() ) { > > $this->Session->setFlash('email been sent'); > > } else { > > $this->Session->setFlash('email not sent'); > > } > > $this->redirect(array('action'=>'index')); > > } > > > On Wed, Aug 4, 2010 at 12:59 AM, fadhli wrote: > > > hi everyone. > > > > i want to send email to all my client, the email contains client data, so > > > the email different between the client. how to send email to all client at > > > ones? i have read > > >http://book.cakephp.org/view/1285/Sending-Multiple-Emails-in-a-loopbuti > > > don't know how to repeat sending email in my controller. can you give me > > > an > > > example? thanks. > > > > This is my code for sending an email to one client > > > > function _sendmail($id) { > > > >> $client = $this->Client->read(null, $id); > > > >> $this->Email->to = $client['Client']['email']; > > > >> $this->Email->subject = 'update request'; > > > >> $this->Email->replyTo = 'no-re...@x.com'; > > > >> $this->Email->from = 'X '; > > > >> $this->Email->template = 'simple_message'; > > > >> $this->Email->sendAs = 'html'; > > > >> $this->set('client', $client); > > > >> $this->Email->send(); > > > >> } > > > >>> function send($id) { > > > >> if (!$id) { > > > >> $this->Session->setFlash(sprintf(__('Invalid %s', true), 'client')); > > > >> $this->redirect(array('action' => 'index')); > > > >> } > > > >> $this->_sendmail($this->Client->id); > > > >> $this->Session->setFlash(sprintf(__('The %s email update > > >>> request has been send', true), 'client')); > > > >> $this->redirect(array('action' => 'index')); > > > >> } 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: coding a loop in cake?
This whole process strikes me as very inefficient. There is no mechanism to prevent your do-while loop from checking the same value an infinite number of times (unless you log each random value and check the next random value against the log AND the db). I don't know what the purpose of the random value is in your app, but I would suggest an entirely different approach. If you need random values in the range of "min" through "max," you could generate a table ahead of time consisting of the fields id and random_number, with max- min+1 rows. (There are many random number generator sites available, and you might be able to access one of their APIs as needed.) It seems to me that it would be easier to generate these unique values in some random order ahead of time, and then just associate the random_numbers table with your current table through a 1-1 relationship. This process would make it easy to identify the next random number to be assigned, and when the random numbers have been exhausted. Just a thought. On Aug 11, 2:57 pm, Tomfox Wiranata wrote: > nabil you are right...i realized it too and returned a string "taken" > or "free"...it works now.. i am saying: > > $eyed = $this->find(array('eyed' => $data), array('eyed')); > if(empty($eyed) == true){ > return "free"; > }else{ > return "taken"; > > and in my controller > > do{ > $lkbl_eyed=rand(1,5); > } > while ($eyed = $this->Linkable->validateEyed($lkbl_eyed) == > "taken"); > return $lkbl_eyed; > } > > now its finebut an endless loop is created when all numbers are > taken.he is not ending the loop then...any idea how i can cake to > take a break if all numbers are taken? > > thx 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
Login
Good afternoon everyone! I'm having doubts about the Auth Component. My question is this when I drive to the system at address www.var.com it provides me the login screen and then redirects to the index system. Thank you all. Atenciosamente, Alexsandro André Joinville - SC 47-8825-0133 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: coding a loop in cake?
nabil you are right...i realized it too and returned a string "taken" or "free"...it works now.. i am saying: $eyed = $this->find(array('eyed' => $data), array('eyed')); if(empty($eyed) == true){ return "free"; }else{ return "taken"; and in my controller do{ $lkbl_eyed=rand(1,5); } while ($eyed = $this->Linkable->validateEyed($lkbl_eyed) == "taken"); return $lkbl_eyed; } now its finebut an endless loop is created when all numbers are taken.he is not ending the loop then...any idea how i can cake to take a break if all numbers are taken? thx On 11 Aug., 17:28, Nabil Alsharif wrote: > On Wed, Aug 11, 2010 at 4:18 AM, Tomfox Wiranata > > > > wrote: > > ok i tried your solution and somehow cake does not care if it writes > > the same number over and over in my database. maybe you see what's > > wrong here :) > > > my function in my model "abc" that finds and compares the number. my > > logic: when no entry is found here $eyed is empty. > > > function validateEyed($data) > > { > > $eyed = $this->find(array('eyed' => $data), array('eyed')); > > if(empty($eyed) == true) > > return $eyed['abc']; > > return false; > > } > > This part is trippin me up... You are checking that $eyed is empty and > if it is you are returning an element from it? Is that right or are my > eyes just seeing thigs? > > > > > I am calling this function from my controller > > > function __createEyed() > > { > > > do{ > > $test=rand(1,2); > > } > > while ($eyed = $this->abc->validateEyed($test) == true); > > return $test; > > } > > > cakes writes those rand numbers "1" or "2" multiple times in my table. > > so where is the mistake?? > > > thx :) > > > On 10 Aug., 18:39, cricket wrote: > >> On Tue, Aug 10, 2010 at 12:30 PM, Tomfox Wiranata > > >> wrote: > >> > thx to both.. > >> > :) > > >> > @cricket: > > >> > am i getting it right? you are writing all numers from the database > >> > into an array and compare both? is it possible that at a certain point > >> > it will get to big or too much data? cause my range starts at > >> > 1 and ends at 9 > > >> > if there are 50million in the table they all get saved in an array > > >> Yes, that's correct. I should have pointed that out. You could cache > >> the results, of course, but perhaps a better way would be to pass > >> $new_number to a protected method (that does a find() and comparison) > >> inside the while section. You'd have to have the separate method > >> because while() isn't a block, where you can have several lines of > >> code. Something like: > > >> public function getNewNumber() > >> { > >> do > >> { > >> $new_number = rand(10,10); > >> } > >> while ($this->_testNewNumber($new_number)); > > >> return $new_number; > > >> } > > >> protected function _testNewNumber($x) > >> { > >> // return $x exists in DB > > >> } > > > 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.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: Re: Update view data after validation failed
> $this->set('data', $this->Model->data); > > You're setting a View variable $data, which is different than the > controller's $this->data. Try: > > $this->data = $this->Model->data; Nope, that doesn't do it. It seems like the data the Form helper is using persists between submissions. Jon ps: resent to the list -- jon bennett - www.jben.net - blog.jben.net 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: hasMany Problem
Hi, ich bin mir nicht sicher, ob ich das alles richtig verstehe, kannst du vielleicht den Code deiner Models (den ganzen hasOne, hasMany, belongsTo Kram) schicken? Da du dich scheinbar auch nicht so richtig an die Namenskonventionen hältst, ist das übersichtlicher. :) Weil z.B. eine "Friend" Relation ja typischerweise User HABTM User Relation ist. Ich denke, wenn die ganzen Relationen ordentlich definiert sind, sollte das mit dem richtigen Rekursionslevel out of the box funktionieren. Und wenn du hier auf englisch fragst, sind die Chancen eine gute Antwort zu erhalten wesentlich höher. ;) Gruß Max Am 11.08.2010 10:30, schrieb JuMiFi: Hallo liebe Community, ich habe eine Frage bzgl. hasMany... Ich habe ein Model "User" (users), welches via hasOne u.a. auf "Account" (users_accounts) und "File" (users_files) zugreift. Ausserdem kann es via hasMany auf "Friends" (friends) zugreifen. users_files beinhaltet die Uploads eines Users (Profilepic etc...). Jetzt würde ich gerne mit $this->User->findById() nicht nur User, Account, File und Friends bekommen, sondern für die Friends wiederum ausserdem File aus users_files und Account aus users_account... Verknüpfungen laufen natürlich jeweils über user(s)_id bzw. friend_id Strukturell also so: User User[Account] User[File] User[Friends] User[Friends][Account] User[Friends][File] Danke für eure Hilfe! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Session call from other app
Hi, how i can use sessions in cake. My problem is i have two different apps on my webserver runing. With the one the user can registrate and login. And this one crates an session. Now the other app an chat would call with popup. My problem here is how to call the session which is seted by the other weblogin. I need now to know which session is set for the user to use it for my chatapp, how i call the session from other webapp. 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: coding a loop in cake?
On Wed, Aug 11, 2010 at 4:18 AM, Tomfox Wiranata wrote: > ok i tried your solution and somehow cake does not care if it writes > the same number over and over in my database. maybe you see what's > wrong here :) > > my function in my model "abc" that finds and compares the number. my > logic: when no entry is found here $eyed is empty. > > function validateEyed($data) > { > $eyed = $this->find(array('eyed' => $data), array('eyed')); > if(empty($eyed) == true) > return $eyed['abc']; > return false; > } > This part is trippin me up... You are checking that $eyed is empty and if it is you are returning an element from it? Is that right or are my eyes just seeing thigs? > > I am calling this function from my controller > > function __createEyed() > { > > do{ > $test=rand(1,2); > } > while ($eyed = $this->abc->validateEyed($test) == true); > return $test; > } > > > cakes writes those rand numbers "1" or "2" multiple times in my table. > so where is the mistake?? > > thx :) > > > On 10 Aug., 18:39, cricket wrote: >> On Tue, Aug 10, 2010 at 12:30 PM, Tomfox Wiranata >> >> wrote: >> > thx to both.. >> > :) >> >> > @cricket: >> >> > am i getting it right? you are writing all numers from the database >> > into an array and compare both? is it possible that at a certain point >> > it will get to big or too much data? cause my range starts at >> > 1 and ends at 9 >> >> > if there are 50million in the table they all get saved in an array >> >> Yes, that's correct. I should have pointed that out. You could cache >> the results, of course, but perhaps a better way would be to pass >> $new_number to a protected method (that does a find() and comparison) >> inside the while section. You'd have to have the separate method >> because while() isn't a block, where you can have several lines of >> code. Something like: >> >> public function getNewNumber() >> { >> do >> { >> $new_number = rand(10,10); >> } >> while ($this->_testNewNumber($new_number)); >> >> return $new_number; >> >> } >> >> protected function _testNewNumber($x) >> { >> // return $x exists in DB >> >> } > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to cake-php@googlegroups.com > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
database results navigation
hello.. i want navigate the resultset fetched by the model..not by pagination...but when i clik the next/previous buttons the controller should fetch the next/previous records accordingly... how to implement this Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Model as interface? Factory pattern
Hi, I'm fairly new to CakePHP, trying to grasp the concepts and all. Ok, so I've listed my problem, here goes: What I have. A system to handle error reports on products for a specific company. Products are specific for the company. Products are related to a manufacturer. Manufacturers are listed in a db-table. How it works The error reporter selects manufacturer from a list and enters a product name and error description. Pretty simple. What I want. Be able to use the system on another company with different products, hence different manufacturers. Manufacturer-db-table of another company might have a different setup/ convention (non-cake) located in a different database. What I think As far as I understand I think this could be achieved, without regard to CakePHP, by applying a factory method pattern. Let's assume a Manufacturer model interface with different implementations depending on the company where the app is used. Now my real question is if there's a CakePHP-way of doing something like this? What are the possibilities to apply a factory pattern to a Cake-model? Hope my thoughts make sense. Any hints or ideas on this would be 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
hasMany Problem
Hallo liebe Community, ich habe eine Frage bzgl. hasMany... Ich habe ein Model "User" (users), welches via hasOne u.a. auf "Account" (users_accounts) und "File" (users_files) zugreift. Ausserdem kann es via hasMany auf "Friends" (friends) zugreifen. users_files beinhaltet die Uploads eines Users (Profilepic etc...). Jetzt würde ich gerne mit $this->User->findById() nicht nur User, Account, File und Friends bekommen, sondern für die Friends wiederum ausserdem File aus users_files und Account aus users_account... Verknüpfungen laufen natürlich jeweils über user(s)_id bzw. friend_id Strukturell also so: User User[Account] User[File] User[Friends] User[Friends][Account] User[Friends][File] Danke für eure Hilfe! 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: Contador en cake
Hola: Primero en este foro se habla ingles. Por favor, para el proximo correo, escribe en el idioma predeterminado de esta lista de correos. Segundo, lamentablemente no conozco una función de conteo propia de cake. Intentalo con una funcion nativa de tu base de datos. First, this mail list speaks in english. Please, for the next mail, you must to write in the predetermined language of this list. Second, Unfortunately i don't know about that posibilitiy of cakephp. Yo can try with a native funtion of your database. Regards. 2010/8/9 Jonathan Calderon Roa > Buenas, cake tiene algun contador para los campos de la db ? > > -- > Jonathan Andrés Calderón Roa > > 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.comFor > more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > -- Estefanía Paz Tejos Araya Estudiante de Ingeniería de Ejecución en Computación e Informática Universidad de Santiago de Chile 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 find Methods in Behavior
Hey, I heard of this cool method of writing custom find methods in tehtreags's bakery post (http://bakery.cakephp.org/articles/view/model-repletion) and now tried to use it in a Behavior, but failed. Im using cake 1.3.0 The Code: http://pastebin.com/92753BmZ The Problem: - I have an article Model which acts as Featurable - In the Featurable behavior setup method I set the models _findMethods['featured'] as true. and define a function _findFeatured($state, $query, $results=array()) - When I do an Article->find('featured'), it seems to look for the right find function, but cannot find it, which results in a SQL error, because the query is "_findFeatured" - When I define the _findFeatured(...) method in the actual Article Model, it works I think it has something to do with the _findFeatured function being protected. Am I right? Is there any way to add custom find methods in a behavior? Thanks Max 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
Cake and subquery
I have to create this query: SELECT * FROM books AS b LEFT JOIN ( SELECT bu.book_id, bu.user_id FROM books_users AS bu WHERE bu.user_id = 5 ) AS bud ON a.id = bud.book_id ORDER BY b.owners DESC LIMIT 2 reading doc I have do this: $dbo = $this->Book->BooksUser->getDataSource(); $conditionsSubQuery['bu.user_id'] = 5; $subQuery = $dbo->buildStatement( array( 'fields' => array('bu.book_id', 'bu.user_id'), 'table' => 'books_users', 'alias' => 'bu', 'conditions' => $conditionsSubQuery, 'order' => null, 'limit' => null, 'group' => null, ), $this->Book->BooksUser ); $subQuery2 = 'SELECT * FROM books AS b LEFT JOIN ('.$subQuery.') AS bu ON b.id = bu.book_id ORDER BY b.owners DESC LIMIT 2'; $subQueryExpression = $dbo->expression($subQuery2); In the end subQueryExpression contain SQL but now I have two questions: 1) I have write the subquery in cake style. How can avoid to write pure SQL (see $subQuery2) and rewrite main query in "cake style"??? 2) subQueryExpression is just an SQL string so it need query() function to execute, how avoid this? Regards Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: making record of logged in user
On Wed, August 11, 2010 12:08 pm, james wrote: > Is it possible when submitting a form to grab the id of the user that > has entered the data? > > I would guess you would grab Auth.User.username but then how would you > enter that into the field thats to be saved? just grab $this->Auth->user('id'); and save that as $this->data['Model']['user_id'] = $this->Auth->user('id'); easy peasy. -- Mike Karthauser Managing Director - Brightstorm Ltd Email: mi...@brightstorm.co.uk Web: http://www.brightstorm.co.uk Tel: 07939 252144 (mobile) Fax: 0870 1320560 Address: 1 Brewery Court, North Street, Bristol, BS3 1JS 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
making record of logged in user
Is it possible when submitting a form to grab the id of the user that has entered the data? I would guess you would grab Auth.User.username but then how would you enter that into the field thats to be saved? 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: Update view data after validation failed
> I see what I would expect from the 2 calls to debug above in the > browser, but the form fields are always the same as they were posted. > Is there some hidden data somewhere I need to reset, perhaps in the > Form helper? For the time-being I've placed this code in the controller, but it feels a little dirty doing so. thanks, J -- jon bennett - www.jben.net - blog.jben.net 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: coding a loop in cake?
just the structure of UUIDs with 32 byte is nout suited for my purpose...but thx anyway :) so my hope is still that someone is identifiying my mistake from the code a wrote, i guess.. On 11 Aug., 12:14, Jeremy Burns | Class Outfit wrote: > Check the Cake section on UUIDs first to see if it is a possible solution for > you - it might not be, of course. They are usually used when the field is an > auto incrementing primary key - I am not sure if they are flexible enough to > work as non primary keys. > > http://book.cakephp.org/view/1016/Using-UUIDs-as-Primary-Keys > > Jeremy Burns > Class Outfit > > jeremybu...@classoutfit.comhttp://www.classoutfit.com > > On 11 Aug 2010, at 11:05, Tomfox Wiranata wrote: > > > thx for your reply jeremy. > > > i dont have an unique index for that field. at least i didnt remember > > doing that.. > > > how do i create this UUID in xampp and what do I have to change in my > > code? > > > thx :) > > > On 11 Aug., 11:50, Jeremy Burns | Class Outfit > > wrote: > >> Do you have a unique index on the field? If you haven't and you really do > >> want it to be unique, I'd stick on on. Then you could work on the basis > >> that you *probably* aren't going to run into the same number that often > >> (at least it is far more likely that your number is unique than it is a > >> duplicate), generate a random number, save it and only create another one > >> of the save fails (then rinse and repeat). > > >> Would a UUID work for you? That would save you some effort. > > >> Jeremy Burns > >> Class Outfit > > >> jeremybu...@classoutfit.comhttp://www.classoutfit.com > > >> On 11 Aug 2010, at 10:18, Tomfox Wiranata wrote: > > >>> ok i tried your solution and somehow cake does not care if it writes > >>> the same number over and over in my database. maybe you see what's > >>> wrong here :) > > >>> my function in my model "abc" that finds and compares the number. my > >>> logic: when no entry is found here $eyed is empty. > > >>> function validateEyed($data) > >>> { > >>> $eyed = $this->find(array('eyed' => $data), array('eyed')); > >>> if(empty($eyed) == true) > >>> return $eyed['abc']; > >>> return false; > >>> } > > >>> I am calling this function from my controller > > >>> function __createEyed() > >>> { > > >>> do{ > >>> $test=rand(1,2); > >>> } > >>> while ($eyed = $this->abc->validateEyed($test) == true); > >>> return $test; > >>> } > > >>> cakes writes those rand numbers "1" or "2" multiple times in my table. > >>> so where is the mistake?? > > >>> thx :) > > >>> On 10 Aug., 18:39, cricket wrote: > On Tue, Aug 10, 2010 at 12:30 PM, Tomfox Wiranata > > wrote: > > thx to both.. > > :) > > > @cricket: > > > am i getting it right? you are writing all numers from the database > > into an array and compare both? is it possible that at a certain point > > it will get to big or too much data? cause my range starts at > > 1 and ends at 9 > > > if there are 50million in the table they all get saved in an array > > Yes, that's correct. I should have pointed that out. You could cache > the results, of course, but perhaps a better way would be to pass > $new_number to a protected method (that does a find() and comparison) > inside the while section. You'd have to have the separate method > because while() isn't a block, where you can have several lines of > code. Something like: > > public function getNewNumber() > { > do > { > $new_number = rand(10,10); > } > while ($this->_testNewNumber($new_number)); > > return $new_number; > > } > > protected function _testNewNumber($x) > { > // return $x exists in DB > > } > > >>> 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 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.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 q
Update view data after validation failed
I'd like to change the data in my form when a certain validation rule changes, but no matter what the original value remains. Here's what happens: 1. Form is submitted 2. Data is passed to model 3. Model validates, if it fails I alter the value of that field in the validation method and return false, eg: public function isNotMeh() { if ($a != $b) { debug($this->data); $this->data[$this->alias]['a'] = 'meh'; debug($this->data); return false; } return true; } 4. In my controller I manually set the data to the view, eg if (!$this->Model->saveAll($this->data)) { $this->set('data', $this->Model->data); } I see what I would expect from the 2 calls to debug above in the browser, but the form fields are always the same as they were posted. Is there some hidden data somewhere I need to reset, perhaps in the Form helper? Cheers, Jon -- jon bennett - www.jben.net - blog.jben.net 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: coding a loop in cake?
Check the Cake section on UUIDs first to see if it is a possible solution for you - it might not be, of course. They are usually used when the field is an auto incrementing primary key - I am not sure if they are flexible enough to work as non primary keys. http://book.cakephp.org/view/1016/Using-UUIDs-as-Primary-Keys Jeremy Burns Class Outfit jeremybu...@classoutfit.com http://www.classoutfit.com On 11 Aug 2010, at 11:05, Tomfox Wiranata wrote: > thx for your reply jeremy. > > i dont have an unique index for that field. at least i didnt remember > doing that.. > > how do i create this UUID in xampp and what do I have to change in my > code? > > thx :) > > On 11 Aug., 11:50, Jeremy Burns | Class Outfit > wrote: >> Do you have a unique index on the field? If you haven't and you really do >> want it to be unique, I'd stick on on. Then you could work on the basis that >> you *probably* aren't going to run into the same number that often (at least >> it is far more likely that your number is unique than it is a duplicate), >> generate a random number, save it and only create another one of the save >> fails (then rinse and repeat). >> >> Would a UUID work for you? That would save you some effort. >> >> Jeremy Burns >> Class Outfit >> >> jeremybu...@classoutfit.comhttp://www.classoutfit.com >> >> On 11 Aug 2010, at 10:18, Tomfox Wiranata wrote: >> >>> ok i tried your solution and somehow cake does not care if it writes >>> the same number over and over in my database. maybe you see what's >>> wrong here :) >> >>> my function in my model "abc" that finds and compares the number. my >>> logic: when no entry is found here $eyed is empty. >> >>>function validateEyed($data) >>>{ >>>$eyed = $this->find(array('eyed' => $data), array('eyed')); >>>if(empty($eyed) == true) >>>return $eyed['abc']; >>>return false; >>>} >> >>> I am calling this function from my controller >> >>>function __createEyed() >>>{ >> >>>do{ >>>$test=rand(1,2); >>>} >>>while ($eyed = $this->abc->validateEyed($test) == true); >>>return $test; >>>} >> >>> cakes writes those rand numbers "1" or "2" multiple times in my table. >>> so where is the mistake?? >> >>> thx :) >> >>> On 10 Aug., 18:39, cricket wrote: On Tue, Aug 10, 2010 at 12:30 PM, Tomfox Wiranata >> wrote: > thx to both.. > :) >> > @cricket: >> > am i getting it right? you are writing all numers from the database > into an array and compare both? is it possible that at a certain point > it will get to big or too much data? cause my range starts at > 1 and ends at 9 >> > if there are 50million in the table they all get saved in an array >> Yes, that's correct. I should have pointed that out. You could cache the results, of course, but perhaps a better way would be to pass $new_number to a protected method (that does a find() and comparison) inside the while section. You'd have to have the separate method because while() isn't a block, where you can have several lines of code. Something like: >> public function getNewNumber() { do { $new_number = rand(10,10); } while ($this->_testNewNumber($new_number)); >> return $new_number; >> } >> protected function _testNewNumber($x) { // return $x exists in DB >> } >> >>> 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.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 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: coding a loop in cake?
thx for your reply jeremy. i dont have an unique index for that field. at least i didnt remember doing that.. how do i create this UUID in xampp and what do I have to change in my code? thx :) On 11 Aug., 11:50, Jeremy Burns | Class Outfit wrote: > Do you have a unique index on the field? If you haven't and you really do > want it to be unique, I'd stick on on. Then you could work on the basis that > you *probably* aren't going to run into the same number that often (at least > it is far more likely that your number is unique than it is a duplicate), > generate a random number, save it and only create another one of the save > fails (then rinse and repeat). > > Would a UUID work for you? That would save you some effort. > > Jeremy Burns > Class Outfit > > jeremybu...@classoutfit.comhttp://www.classoutfit.com > > On 11 Aug 2010, at 10:18, Tomfox Wiranata wrote: > > > ok i tried your solution and somehow cake does not care if it writes > > the same number over and over in my database. maybe you see what's > > wrong here :) > > > my function in my model "abc" that finds and compares the number. my > > logic: when no entry is found here $eyed is empty. > > > function validateEyed($data) > > { > > $eyed = $this->find(array('eyed' => $data), array('eyed')); > > if(empty($eyed) == true) > > return $eyed['abc']; > > return false; > > } > > > I am calling this function from my controller > > > function __createEyed() > > { > > > do{ > > $test=rand(1,2); > > } > > while ($eyed = $this->abc->validateEyed($test) == true); > > return $test; > > } > > > cakes writes those rand numbers "1" or "2" multiple times in my table. > > so where is the mistake?? > > > thx :) > > > On 10 Aug., 18:39, cricket wrote: > >> On Tue, Aug 10, 2010 at 12:30 PM, Tomfox Wiranata > > >> wrote: > >>> thx to both.. > >>> :) > > >>> @cricket: > > >>> am i getting it right? you are writing all numers from the database > >>> into an array and compare both? is it possible that at a certain point > >>> it will get to big or too much data? cause my range starts at > >>> 1 and ends at 9 > > >>> if there are 50million in the table they all get saved in an array > > >> Yes, that's correct. I should have pointed that out. You could cache > >> the results, of course, but perhaps a better way would be to pass > >> $new_number to a protected method (that does a find() and comparison) > >> inside the while section. You'd have to have the separate method > >> because while() isn't a block, where you can have several lines of > >> code. Something like: > > >> public function getNewNumber() > >> { > >> do > >> { > >> $new_number = rand(10,10); > >> } > >> while ($this->_testNewNumber($new_number)); > > >> return $new_number; > > >> } > > >> protected function _testNewNumber($x) > >> { > >> // return $x exists in DB > > >> } > > > 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.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: coding a loop in cake?
Do you have a unique index on the field? If you haven't and you really do want it to be unique, I'd stick on on. Then you could work on the basis that you *probably* aren't going to run into the same number that often (at least it is far more likely that your number is unique than it is a duplicate), generate a random number, save it and only create another one of the save fails (then rinse and repeat). Would a UUID work for you? That would save you some effort. Jeremy Burns Class Outfit jeremybu...@classoutfit.com http://www.classoutfit.com On 11 Aug 2010, at 10:18, Tomfox Wiranata wrote: > ok i tried your solution and somehow cake does not care if it writes > the same number over and over in my database. maybe you see what's > wrong here :) > > my function in my model "abc" that finds and compares the number. my > logic: when no entry is found here $eyed is empty. > >function validateEyed($data) >{ >$eyed = $this->find(array('eyed' => $data), array('eyed')); >if(empty($eyed) == true) >return $eyed['abc']; >return false; >} > > > I am calling this function from my controller > >function __createEyed() >{ > > do{ > $test=rand(1,2); > } > while ($eyed = $this->abc->validateEyed($test) == true); > return $test; >} > > > cakes writes those rand numbers "1" or "2" multiple times in my table. > so where is the mistake?? > > thx :) > > > On 10 Aug., 18:39, cricket wrote: >> On Tue, Aug 10, 2010 at 12:30 PM, Tomfox Wiranata >> >> wrote: >>> thx to both.. >>> :) >> >>> @cricket: >> >>> am i getting it right? you are writing all numers from the database >>> into an array and compare both? is it possible that at a certain point >>> it will get to big or too much data? cause my range starts at >>> 1 and ends at 9 >> >>> if there are 50million in the table they all get saved in an array >> >> Yes, that's correct. I should have pointed that out. You could cache >> the results, of course, but perhaps a better way would be to pass >> $new_number to a protected method (that does a find() and comparison) >> inside the while section. You'd have to have the separate method >> because while() isn't a block, where you can have several lines of >> code. Something like: >> >> public function getNewNumber() >> { >> do >> { >> $new_number = rand(10,10); >> } >> while ($this->_testNewNumber($new_number)); >> >> return $new_number; >> >> } >> >> protected function _testNewNumber($x) >> { >> // return $x exists in DB >> >> } > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to cake-php@googlegroups.com > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: passing values from javascript to cakes controller function
yes its jquery hmm..ok... so i tried OK to pass the form to the function refreshtitle...but then? how do i submit the form in JS.. sorry for being so dense :) On 10 Aug., 19:12, cricket wrote: > On Tue, Aug 10, 2010 at 7:54 AM, Tomfox Wiranata > > > > wrote: > > hi everyone, > > > sth is bugging me. > > > i have a div "title". is a user clicks on that div, a css popup opens > > with a textarea for entering information. after the user entered the > > information it is passed to a function in my controller "processtitle" > > so it can be rendered in the div "title" with ajax. > > > so the information will be shown without loading the whole page. but i > > am having problem passing the entered information to my function: this > > is my code > > > my view: > > > this is the css popup with the textarea: > > > > > > charset="utf-8"> > > > > Titel > > > > style="width: > > 105%" > > > > > type="button">OK > > > echo $form->end(); > > ?> > > > > > > > > > > > so i iam calling the JS function refreshtitle() > > > function refreshtitle(){ > > > $ > > ('#title_content').fadeOut('slow').load('processtitle').fadeIn('slow'); > > $('#fade , .popup_block').fadeOut(function() { > > $('#fade, a.close').remove(); //fade them both out > > }); > > > } > > > and i am calling my controller funtion processtitle > > > function processtitle() > > { > > $input_title = $this->data['abc']['notes']; > > $this->Session->write('abc.title', $input_title); > > $this->set('abc_title', strip_tags($this->Session- > >>read('abc.title'))); > > $this->render('render_title','ajax'); > > } > > > now i am thinking the problem is, that $input_title has no data in > > here, since "data['Linkable']['notes']" is not passed. > > > if i simply put an echo "test" in the rendered view "render_title" > > this string is shown. so that tells me the process is working. but its > > not showing echo $abc_title, the variable i set. > > > so how can I pass the value from my textarea over javascipt to my > > controller? > > > thx so much :) > > You're not submitting anything to the server. You need to submit the > form in the refreshtitle() function. Include the correct form action > attribute and (it looks to me like you're using JQuery) have the JS > submit the form using AJAX. 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: coding a loop in cake?
ok i tried your solution and somehow cake does not care if it writes the same number over and over in my database. maybe you see what's wrong here :) my function in my model "abc" that finds and compares the number. my logic: when no entry is found here $eyed is empty. function validateEyed($data) { $eyed = $this->find(array('eyed' => $data), array('eyed')); if(empty($eyed) == true) return $eyed['abc']; return false; } I am calling this function from my controller function __createEyed() { do{ $test=rand(1,2); } while ($eyed = $this->abc->validateEyed($test) == true); return $test; } cakes writes those rand numbers "1" or "2" multiple times in my table. so where is the mistake?? thx :) On 10 Aug., 18:39, cricket wrote: > On Tue, Aug 10, 2010 at 12:30 PM, Tomfox Wiranata > > wrote: > > thx to both.. > > :) > > > @cricket: > > > am i getting it right? you are writing all numers from the database > > into an array and compare both? is it possible that at a certain point > > it will get to big or too much data? cause my range starts at > > 1 and ends at 9 > > > if there are 50million in the table they all get saved in an array > > Yes, that's correct. I should have pointed that out. You could cache > the results, of course, but perhaps a better way would be to pass > $new_number to a protected method (that does a find() and comparison) > inside the while section. You'd have to have the separate method > because while() isn't a block, where you can have several lines of > code. Something like: > > public function getNewNumber() > { > do > { > $new_number = rand(10,10); > } > while ($this->_testNewNumber($new_number)); > > return $new_number; > > } > > protected function _testNewNumber($x) > { > // return $x exists in DB > > } 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: Adding special characters to link text
Thanks everyone. That's good to know! Sharon 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