Re: Run a cron job in cakephp
Hi, that cake method you call from within the worker, is it written as a shell? Or how do you do it? I'm not familiar with gearman, but I think I'm gonna need it soon. thanks atenciosamente, Werner Petry Moraes werne...@gmail.com On Fri, Nov 4, 2011 at 06:16, Eric Blanpied wrote: > I think the best way to do it is with a queue. After doing several > websites in which cron jobs were used for various not-so-cron things > (cron job to wake up periodically and check for needed tasks? why not > just spawn the tasks?), I came to the conclusion that a job queue was > a much smarter answer. > > Accordingly, I've just woven Gearman (http://gearman.org/) into one of > our cake projects, with a very simple component wrapping the gearman > client. The workers are pure php, with no knowledge of the app or > database, reducing dependencies as well as possible. The client passes > the workers json-encoded parameters, and the workers call a cake > method when done, again with json-encoded return data, and cake makes > any database updates as appropriate. Now we can do all sorts of things > outside of the user's browser session, and in the future could move > these things off to a different server if we wished. > > Of course, if your other tasks were very much cake-related, and you > wanted them to use the framework, I see no reason why you couldn't > write your workers within the framework. > > There are other queue/messaging systems out there (beanstalk's got a > good following), but in my research I liked what gearman had to offer > best. There's also Persson's cakephp Queue plugin, but I wanted a > lighter system, with no cake dependencies on the worker side. > > -e > > On Fri, Nov 4, 2011 at 8:12 AM, flo.kl...@googlemail.com > wrote: > > What about using javascript. It would only work while the user is on the > > site, but it would be able to call a function (also ajax if you want to > > trigger a php method) very x seconds. > > > > -flosky > > > > > > > > Ryan Schmidt schrieb: > >> > >> On Nov 4, 2011, at 00:17, zuha wrote: > >> > >> > is there anyway to run a process separate from the page load. I would > >> > love to run a pseudo cronjob on each page load if it could be done > without > >> > negatively effecting performance in a serious way. (I was thinking > curl, > >> > and ajax, but they didn't really seem to fit the bill) Any experts > out > >> > there know how to start a cron task outside of the page load, but > triggered > >> > by a page load? > >> > >> cron is a program that schedules things to run at particular times of > the > >> day. "start a cron task ... triggered by a page load" therefore doesn't > make > >> sense. > >> > >> What kind of task do you want to start? The solution might be different > >> depending on the task. > >> > >> > >> -- > >> Our newest site for the community: CakePHP Video Tutorials > >> http://tv.cakephp.org > >> Check out the new CakePHP Questions site http://ask.cakephp.org and > help > >> others with their CakePHP related questions. > >> > >> > >> To unsubscribe from this group, send email to > >> cake-php+unsubscr...@googlegroups.com For more options, visit this > group > >> at http://groups.google.com/group/cake-php > > > > -- > > Our newest site for the community: CakePHP Video Tutorials > > http://tv.cakephp.org > > Check out the new CakePHP Questions site http://ask.cakephp.org and help > > others with their CakePHP related questions. > > > > > > To unsubscribe from this group, send email to > > cake-php+unsubscr...@googlegroups.com For more options, visit this > group at > > http://groups.google.com/group/cake-php > > > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group > at http://groups.google.com/group/cake-php > -- 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: CakePHP2.0.1 - Problem with saving HABTM
I've had some similar trouble with 2.0 turned out the fields in the DB were not the same type. id on one table was a bigint and the foreign key on the relationship table was a regular integer. atenciosamente, Werner Petry Moraes werne...@gmail.com On Wed, Nov 2, 2011 at 07:52, Mattia Manzati wrote: > Hi all! Thanks in advance for replys! :P > I have the following model: > > class EpisodeRelease extends AppModel{ >> public $cacheQueries = true; >> public $name = 'EpisodeRelease'; >> public $primaryKey = 'id'; >> public $table = 'episode_releases'; >> public $hasMany = array( >> 'EpisodeReleaseMirror' => array ( >> 'className' => 'EpisodeReleaseMirror', >> 'foreignKey' => 'episode_release_id', >> 'conditions' => array('EpisodeReleaseMirror.approved_by >' => >> 0), >> 'order' => 'EpisodeReleaseMirror.download_count DESC' >> ) >> ); >> public $belongsTo = array( >> 'User' => array( >> 'className' => 'User', >> 'foreignKey' => 'user_id' >> ), >> 'EpisodeType' => array( >> 'className' => 'EpisodeType', >> 'foreignKey' => 'episode_type_id' >> ), >> 'Anime' => array( >> 'className' => 'Anime', >> 'foreignKey' => 'anime_id' >> ), >> 'Language' => array( >> 'className' => 'Language', >> 'foreignKey' => 'language_id' >> ) >> ); >> public $hasAndBelongsToMany = array( >> 'Fansub' => array( >> 'className' => 'Fansub', >> 'joinTable' => 'Fansub2EpisodeRelease', >> 'foreignKey' => 'episode_release_id', >> 'associationForeignKey' => 'fansub_id', >> 'unique' => false >> ), >> 'VideoCodec' => array( >> 'className' => 'VideoCodec', >> 'joinTable' => 'VideoCodec2EpisodeRelease', >> 'foreignKey' => 'episode_release_id', >> 'associationForeignKey' => 'video_codec_id', >> 'order' => 'VideoCodec.order DESC', >> 'unique' => false >> ) >> ); >> } >> ?> >> >> and the following code in the controller... > >> function add(){ >> if($this->_canAdd()){ >> $this->set('animes', >> $this->EpisodeRelease->Anime->find('list',array('fields'=>'name'))); >> $this->set('languages', >> $this->EpisodeRelease->Language->find('list',array('fields'=>'name'))); >> $this->set('episodeTypes', >> $this->EpisodeRelease->EpisodeType->find('list',array('fields'=>'name'))); >> $this->set('fansubs', >> $this->EpisodeRelease->Fansub->find('list',array('fields'=>'name','order'=>'Fansub.name >> ASC'))); >> $this->set('videoCodecs', >> $this->EpisodeRelease->VideoCodec->find('list',array('fields'=>'name','order' >> => 'VideoCodec.order DESC'))); >> >> if($this->request->is('post')){ >> $this->request->data['EpisodeRelease']['user_id'] = >> $this->Auth->User('user_id'); >> $this->EpisodeRelease->set($this->request->data); >> if($this->EpisodeRelease->saveAll($this->request->data)){ >> $this->Session->setFlash('Release aggiunta con >> successo. Sarà visualizzabile non appena un amministratore lo avrà >> approvato.'); >> //$this->redirect(array('
Re: Fatal Error
Hey, You don't have the mysql extension installed. Check out http://www.php.net/manual/en/mysql.installation.php atenciosamente, Werner Petry Moraes werne...@gmail.com On Mon, Aug 22, 2011 at 09:37, Shervin kapil wrote: > Hi, >when running my source code following Fatal error is displaying. > > > Fatal error: Call to undefined function mysql_query() in D: > \nasoindiadev\tradev2\cake\libs\model\datasources\dbo\dbo_mysql.php on > line 600 > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group > at http://groups.google.com/group/cake-php > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Table Relations ERROR
Hi, i think your controller should be called PostReplies, or you can add this line to call the right model. var $uses = 'PostReply'; atenciosamente, Werner Petry Moraes werne...@gmail.com On Mon, Aug 22, 2011 at 15:25, Almacenamiento Almacenamiento < almacenamien...@gmail.com> wrote: > I'm trying to relate the table and Posts_Replies Posts, but I have some > problems .. > Check several times tables, file names and code, but I see no objection > to that. > Search internet, but I can not fixearlo U.u > Even in the inflector.php adds 'post_reply' => 'posts_replies' x just in > case > > Q I hope I can help, I'm going crazy! > > Undefined property: PostsRepliesController::$PostReply > [APP\controllers\posts_replies_controller.php, line 18] > Trying to get property of non-object > [APP\controllers\posts_replies_controller.php, line 18] > > Fatal error: Call to a member function find() on a non-object in > G:\xampp\htdocs\cake\miforo\app\controllers\posts_replies_controller.php on > line 18 > > Table: > *Posts > *Posts_Replies > > Controller PostsReplies > class PostsRepliesController extends AppController > { > var $name="PostsReplies"; > var $helpers=array("Html", "Form"); > //var $scaffold; > > function add($id=null) > { > if(!empty($this->data)) > { > $this->PostReply->create(); > if($this->PostReply->save()) > { > $this->Session->setFlash('Respuesta Salvada'); > } > } > $posts = $this->PostReply->Post->find('list', > array( > 'fields'=>'Post.titulo', > 'conditions'=>array('Post.id'=>$id) > ) > ); > $this->set('posts', $posts); > } > > } > ?> > > Model PostReply > class PostReply extends AppModel > { > var $name="PostReply"; > var $belongsTo="Post"; > } > ?> > > Model Post > class Post extends AppModel{ > var $name="Post"; > var $hasMany="PostReply"; > } > ?> > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group > at http://groups.google.com/group/cake-php > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Self referencing in belongsTo
Hey, I think what you want to show is $role['ParentRole']['name'] instead of $role['Role']['name'] atenciosamente, Werner Petry Moraes werne...@gmail.com On Mon, Aug 22, 2011 at 21:54, Rodrigo Vronscki Ricardo wrote: > Hi there, > > I'm new to Cakephp and I'm trying to build a small system wich Users have > Roles and Roles MAY have a parent Role > > So I tried to change the name of the model to parentRole like below: > > var $belongsTo = array( > 'parentRole' => array( > 'className' => 'Role', > 'foreignKey' => 'role_id' > > In database, everything is ok, showing a Manager has a parent Superadmin, > but it doesn't seem to fetch the correct name for the parentRole in > roles/index. > > I also tried changing: > Html->link($role['Role']['name'], array('controller' => > 'roles', 'action' => 'view', $role['Role']['id'])); ?> > To: > Html->link($role['Role']['name'], array('controller' => > 'roles', 'action' => 'view', $role['Role']['role_id'])); ?> > But made no difference. > > I know it should be something simple, but can't find a solution. > Is there anything to change in controller? Anyone could help me? > > Regards, > > Rodrigo > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group > at http://groups.google.com/group/cake-php > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Join a table to Itself with a join table
> True but if I have employee Bob who is a supervisor. Bob supervises > Tina, and Pete but Bob also has a supervisor, Sam. > > In this scenario wouldn't Bob have to exist in both the Employee and > Supervisor tables? That would be duplicate data which is bad. Right, a supervisor may have a supervisor himself. You can use the same model for both and put the following relationship: var $hasAndBelongsToMany = array( 'Supervisor' => array('className' => 'Employee', 'joinTable' => 'employees_supervisors', 'foreignKey' => 'employee_id', 'associationForeignKey' => 'supervisor_id', 'unique' => true 'conditions' => array('Supervisor.is_supervisor' => true), // don't know if you declare this condition using the relationship name or the model name. if this doesn't work, try changing Supervisor for Employee ) ); Werner Petry Moraes http://werner.inf.br/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Join a table to Itself with a join table
Hey, > Thanks for the response. I want to avoid adding a Supervisor model as > a supervisor is just another employee. The > EmployeesSupervisor.supervisor_id is a foreign key to Employees.id. Well, the supervisor has different behavior (Employee.is_supervisor = true), so, I'd see it as another entity and model. But, you can put this condition in the relationship declaration and use the same model. > I did initial try to set this up as HABTM but after reading other post > that suggested otherwise I switched to the current method. Your situation surely looks like a HABTM. I don't know if that previous solution would work for you. Werner Petry Moraes http://werner.inf.br/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Join a table to Itself with a join table
Oh, i didn't read that condition: array('Employee.is_supervisor'=>true) You might want to add another model for the supervisors too, and change that relationship to call it. Then put another HABTM in the supervisors model pointing to the employees. Werner Petry Moraes http://werner.inf.br/ On Mon, Sep 22, 2008 at 3:40 PM, Werner Petry Moraes <[EMAIL PROTECTED]> wrote: > Hi, > > This is a HABTM relationship. > > Take all that off and use only this. > >var $hasAndBelongsToMany = array( >'Supervisor' => array('className' => 'Employee', >'joinTable' => > 'employees_supervisors', >'foreignKey' => 'employee_id', >'associationForeignKey' => > 'supervisor_id', >'unique' => true >) >); > >> My problem right now is that when the joins occur it joins >> "Employee"."id" = "Supervisor"."id" when what I want is >> "Employee"."id" = "Supervisor"."employee_id" and/or "Employee"."id" = >> "Supervisor"."supervisor_id". >> >> I tried the associationForeignKey but I think that only works with >> HABTM relationships. > > > Werner Petry Moraes > http://werner.inf.br/ > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Join a table to Itself with a join table
Hi, This is a HABTM relationship. Take all that off and use only this. var $hasAndBelongsToMany = array( 'Supervisor' => array('className' => 'Employee', 'joinTable' => 'employees_supervisors', 'foreignKey' => 'employee_id', 'associationForeignKey' => 'supervisor_id', 'unique' => true ) ); > My problem right now is that when the joins occur it joins > "Employee"."id" = "Supervisor"."id" when what I want is > "Employee"."id" = "Supervisor"."employee_id" and/or "Employee"."id" = > "Supervisor"."supervisor_id". > > I tried the associationForeignKey but I think that only works with > HABTM relationships. Werner Petry Moraes http://werner.inf.br/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: License issues
Hey, http://www.opensource.org/licenses/mit-license.php ... Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. ... That means yes, you can. > Cakephp is released under MIT lincense. Can we use cakephp to develop > commercial applications or only those applications that should be > released under an MIT license or an opensource? > Thanks a lot for ur guidance. -- Werner Petry Moraes [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Dynamic Javascript hasMany
Hi all, I am a starter in CakePHP and I'm having trouble doing something like this below. http://www.bitnetbrasil.com.br/logustec_desenv/php/Admin_Pessoa.php?pagina=2 (Scroll down and click in "Endereços: adicionar"). This is a form for customers with many addresses. For you who can't open, it is like the many attachments in Gmail's compose message (Javascript add/remove file input) - but with more fields and some select boxes. The problems are: - If I do the address sub-form using javascript, I can't use the form helper and, when I edit the record, I will have to create all the addresses on the form with javascript; - I could use Ajax to create the sub-form, using an addresses view (one request for each address) but this would take too long to load. (And it's not just addresses on people, I'm gonna use it to manage orders and items too) Does anyone have some tactics for me to follow? Or any example, that would be nice. Thanks to all -- Werner Petry Moraes http://werner.inf.br/ ICQ: 71759171 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---