child model that is deleted via dependent=true in 1 parent model does not update counterCache of 2nd parent
i have a model called Link it belongs to Webpage and LinkList LinkList has a counterCache of Link. It works whenever i delete or add a new Link. I have also set Webpage hasMany Link where dependent = true and exclusive = false. so whenever i delete a Webpage, all the associated Links are deleted as well. However the issue is that the counterCache are not updated that way. i will be coding a afterDelete either in Webpage or Link, however, I just want to confirm whether I need to do so for cakephp 1.3.9 if I need to code a afterDelete to update the countercache, please indicate whether it is better to do so in Webpage or in Link, i am leaning towards Webpage, since when I delete Link, it will definitely update the countercache for LinkList 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: 1st party lib object class triggered Class __PHP_Incomplete_Class has no unserializer - how to resolve?
Anyone can help? I think this has more to do with unserialize issues handled by cakephp than have to do with Twig. On Jul 7, 4:02 pm, Zeu5 wrote: > using cake 1.3.9 > > I wrote a library class that i placed inside app/libs > > this class IteratorForTwig basically extends the ArrayObject class > > http://bin.cakephp.org/view/2007912078 > > I need it because I am using Twig to make building themes as designer- > friendly as possible. > > I did > > $this->set('some_object', $some_object); at the controllers > > where the $some_object is an instance of the class IteratorForTwig. > > Now the code works, but I keep getting warning messages in error.log > > Warning: Warning (2): unserialize() [http://php.net/ > function.unserialize]: Function spl_autoload_call() hasn't defined the > class it was called for in [/var/www/wp/cake/libs/cache/file.php, line > 176] > Warning: Warning (2): Class __PHP_Incomplete_Class has no unserializer > in [/var/www/wp/cake/libs/cache/file.php, line 176] > > What can I do to resolve these warnings? -- 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
redirect for css rendering
Hi i am using Twig for views in my cakephp application. Reason is I want to do something that allows designers to contribute different themes. Twig is already well integrated using a plugin so in my controller actions, i just use $this->render('template_name'); and $this->set to setup the variables for use in the Twig Template files. I need to allow Twig to be used in css files as well. http://groups.google.com/group/twig-users/browse_thread/thread/e0a141f029cca5ba/1e888a002eb355b6 Somebody in Twig Group suggested this solution about using Apache to do redirect. http://groups.google.com/group/twig-users/msg/1e888a002eb355b6 So how do i do this in cakephp? Use the pages controller and create a brand new action called parse_css? Please advise. 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
1st party lib object class triggered Class __PHP_Incomplete_Class has no unserializer - how to resolve?
using cake 1.3.9 I wrote a library class that i placed inside app/libs this class IteratorForTwig basically extends the ArrayObject class http://bin.cakephp.org/view/2007912078 I need it because I am using Twig to make building themes as designer- friendly as possible. I did $this->set('some_object', $some_object); at the controllers where the $some_object is an instance of the class IteratorForTwig. Now the code works, but I keep getting warning messages in error.log Warning: Warning (2): unserialize() [http://php.net/ function.unserialize]: Function spl_autoload_call() hasn't defined the class it was called for in [/var/www/wp/cake/libs/cache/file.php, line 176] Warning: Warning (2): Class __PHP_Incomplete_Class has no unserializer in [/var/www/wp/cake/libs/cache/file.php, line 176] What can I do to resolve these warnings? -- 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: separate class that prepares an IteratorAggregate object for View layer - where to place this?
Thank you. It worked. I have made a note to myself about not ever using numbers in class names for vendor and lib files. On Jul 6, 3:19 pm, Thomas Ploch wrote: > Hi, > > What is the filename in the 'lib' directory? Try > 'app/lib/array_to_iterator_aggregate.php' as filename and use > 'App::import("Lib", "ArrayToIteratorAggregate")' > > Am Dienstag, den 05.07.2011, 14:56 -0700 schrieb Zeu5: > > > > > > > > > Hi Thomas, > > > this is my code for the beforeRender. I got a Class not found error. > > > Fatal error: Class 'Array2IteratorAggregate' not found. > > > > function beforeRender() { > > App::import('Lib', 'Array2IteratorAggregate'); > > > $iterators = empty($this->viewVars['TwigObjects'] > > ['IteratorAggregate']) ? > > array() : > > $this->viewVars['TwigObjects']['IteratorAggregate']; > > > foreach($iterators as $alias) { > > $array = empty($this->viewVars[$alias]) ? > > array() : $this->viewVars[$alias]; > > if (is_array($array) AND !empty($array)) { > > $this->viewVars[$alias] = > > Array2IteratorAggregate::a2ia($array); > > > $items = $this->viewVars[$alias]; > > > if( !is_array( $items ) && !$items instanceof > > Traversable ) { > > $this->log('not working'); > > } else { > > $this->log(' working'); > > } > > $this->log($array); > > } > > } > > } > > ?> > > >http://bin.cakephp.org/view/1692840979in case you prefer paste. > > > my file in app/libs is array_2_iterator_aggregate.php > > the code inside that file is found > > here.http://bin.cakephp.org/view/1592385093 > > > On Jul 5, 8:18 pm, Thomas Ploch wrote: > > > Hello, > > > > well, I would set the Arrays that should be converted to the Itearator > > > objects to a special viewVar, i.e.: > > > > In your Controller action > > > > > $iterators = array(); > > > $cars = $this->Car->find('all'); > > > $trucks = $this->Truck->find('all'); > > > > $iterators = Set::merge($iterators, $cars, $trucks); > > > $this->set(compact('iterators')); > > > ?> > > > > In AppController::beforeRender(), this way you can use this everywhere > > > if you add to the iterators viewVar > > > > > $iterators = empty($this->viewVars['iterators']) ? array() : > > > $this->viewVars['iterators']; > > > foreach($iterators as $alias => $data) { > > > $iterators[$alias] = > > > ArrayConverter::createAggregator($data); > > > } > > > $this->viewVars['iterators'] = $iterators; > > > ?> > > > > ArrayConverter is a library class in 'app/lib/array_converter.php' that > > > you can load with App::import(). > > > > Regards, > > > Thomas > > > > Am Dienstag, den 05.07.2011, 04:20 -0700 schrieb Zeu5: > > > > > Hi Thomas, > > > > > let me state my concerns here. Perhaps you can tell me if your > > > > suggested answer is still good for the scenario. > > > > > I have various models and controllers. > > > > > Cars, Trucks, Tables, Chairs, Users, Passengers, etc. > > > > > I have admin actions: Admin_view, admin_edit, admin_add, > > > > Actions for public are view, edit, add, etc. > > > > > I will use Twig for Themes on views that are for public consumption. > > > > > And i will not expose all the data models for designers to manipulate. > > > > Just to be clear, i will expose only cars, trucks and passengers in > > > > their respective index page. > > > > > 1) Having said this, the IteratorAggregate class should still be in > > > > app lib? > > > > > 2) the Controller::beforeRender you would mean in cars, trucks and > > > > passengers controllers only right? > > > > > 3) so far your idea soun
Re: separate class that prepares an IteratorAggregate object for View layer - where to place this?
Hi Thomas, this is my code for the beforeRender. I got a Class not found error. Fatal error: Class 'Array2IteratorAggregate' not found. viewVars['TwigObjects'] ['IteratorAggregate']) ? array() : $this->viewVars['TwigObjects']['IteratorAggregate']; foreach($iterators as $alias) { $array = empty($this->viewVars[$alias]) ? array() : $this->viewVars[$alias]; if (is_array($array) AND !empty($array)) { $this->viewVars[$alias] = Array2IteratorAggregate::a2ia($array); $items = $this->viewVars[$alias]; if( !is_array( $items ) && !$items instanceof Traversable ) { $this->log('not working'); } else { $this->log(' working'); } $this->log($array); } } } ?> http://bin.cakephp.org/view/1692840979 in case you prefer paste. my file in app/libs is array_2_iterator_aggregate.php the code inside that file is found here. http://bin.cakephp.org/view/1592385093 On Jul 5, 8:18 pm, Thomas Ploch wrote: > Hello, > > well, I would set the Arrays that should be converted to the Itearator > objects to a special viewVar, i.e.: > > In your Controller action > $iterators = array(); > $cars = $this->Car->find('all'); > $trucks = $this->Truck->find('all'); > > $iterators = Set::merge($iterators, $cars, $trucks); > $this->set(compact('iterators')); > ?> > > In AppController::beforeRender(), this way you can use this everywhere > if you add to the iterators viewVar > $iterators = empty($this->viewVars['iterators']) ? array() : > $this->viewVars['iterators']; > foreach($iterators as $alias => $data) { > $iterators[$alias] = ArrayConverter::createAggregator($data); > } > $this->viewVars['iterators'] = $iterators; > ?> > > ArrayConverter is a library class in 'app/lib/array_converter.php' that > you can load with App::import(). > > Regards, > Thomas > > Am Dienstag, den 05.07.2011, 04:20 -0700 schrieb Zeu5: > > > > > > > > > Hi Thomas, > > > let me state my concerns here. Perhaps you can tell me if your > > suggested answer is still good for the scenario. > > > I have various models and controllers. > > > Cars, Trucks, Tables, Chairs, Users, Passengers, etc. > > > I have admin actions: Admin_view, admin_edit, admin_add, > > Actions for public are view, edit, add, etc. > > > I will use Twig for Themes on views that are for public consumption. > > > And i will not expose all the data models for designers to manipulate. > > Just to be clear, i will expose only cars, trucks and passengers in > > their respective index page. > > > 1) Having said this, the IteratorAggregate class should still be in > > app lib? > > > 2) the Controller::beforeRender you would mean in cars, trucks and > > passengers controllers only right? > > > 3) so far your idea sounds good as i typed this response. I am liking > > it. > > > On Jul 5, 6:53 pm, Thomas Ploch wrote: > > > Well, you would not do it on the Behavior itself, since you want to pass > > > the object to the view. > > > > Probably a static method as in your example that converts the find array > > > into an object that implements IteratorAggregate (probably 'app/lib' is > > > the best place for this). > > > > Then in Controller::beforeRender you could iterate over the viewVars and > > > convert the arrays accordingly. > > > > Regards, > > > Thomas > > > > Am Dienstag, den 05.07.2011, 02:41 -0700 schrieb Zeu5: > > > > > Hi there, > > > > > i think you mean a Model Behavior? > > > > > If so, do i still need to create a separate class which implements the > > > > IteratorAggregate? > > > > > If so, is it done in the same file as the Behavior? > > > > > Thank you. > > > > > On Jul 5, 5:28 pm, euromark wrote: > > > > > i see > > > > > you would probably need a global app controller behavior which > > > > > translates everything right away > &g
advice on refactoring beforeFilter in app_controller
Hi there, the beforeFilter function in my app_controller over time has grown into a monstrous 300 line code. in that beforeFilter, i do things like $this->set for non admin pages $this->Cookie->write $this->Auth->fields = array('username' => 'email', 'password' => 'password'); $this->Auth->authorize = 'actions'; and many others. Can i break up the code in beforeFilter into several private functions inside app_controller? Is there a better way? 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: separate class that prepares an IteratorAggregate object for View layer - where to place this?
Hi Thomas, let me state my concerns here. Perhaps you can tell me if your suggested answer is still good for the scenario. I have various models and controllers. Cars, Trucks, Tables, Chairs, Users, Passengers, etc. I have admin actions: Admin_view, admin_edit, admin_add, Actions for public are view, edit, add, etc. I will use Twig for Themes on views that are for public consumption. And i will not expose all the data models for designers to manipulate. Just to be clear, i will expose only cars, trucks and passengers in their respective index page. 1) Having said this, the IteratorAggregate class should still be in app lib? 2) the Controller::beforeRender you would mean in cars, trucks and passengers controllers only right? 3) so far your idea sounds good as i typed this response. I am liking it. On Jul 5, 6:53 pm, Thomas Ploch wrote: > Well, you would not do it on the Behavior itself, since you want to pass > the object to the view. > > Probably a static method as in your example that converts the find array > into an object that implements IteratorAggregate (probably 'app/lib' is > the best place for this). > > Then in Controller::beforeRender you could iterate over the viewVars and > convert the arrays accordingly. > > Regards, > Thomas > > Am Dienstag, den 05.07.2011, 02:41 -0700 schrieb Zeu5: > > > > > > > > > Hi there, > > > i think you mean a Model Behavior? > > > If so, do i still need to create a separate class which implements the > > IteratorAggregate? > > > If so, is it done in the same file as the Behavior? > > > Thank you. > > > On Jul 5, 5:28 pm, euromark wrote: > > > i see > > > you would probably need a global app controller behavior which > > > translates everything right away > > > > php doesnt have the attributes itself > > > but you can acomplish that by using: > > > $size = count($cars); > > > $first = array_shift($cars); > > > $last = array_pop($cars); > > > and may others > > > etc > > > > On 5 Jul., 02:38, Zeu5 wrote: > > > > > I am using Twig so that I can make it as easy for designers to design > > > > themes as possible without knowing php. > > > > > Currently, Twig evaluates the strings, arrays, objects like > > > > thishttp://www.twig-project.org/doc/templates.html#variables > > > > > i want to keep things as simple and as brief as possible. > > > > > Hence I want to make it such that designers need only use > > > > {{ cars.size }} , {{ cars.first }} and {{ cars.last }} > > > > > So i guessed that cars cannot be usual php arrays, but objects with > > > > attributes for size, first and last. > > > > > If my understanding is wrong about php arrays, i apologise. > > > > > Please educate me on how usual php arrays can possibly have these > > > > attributes as well. > > > > > On Jul 5, 7:17 am, euromark wrote: > > > > > > why are the normal 1.3 arrays not working for you? > > > > > they also have all those functions built in (in plain php functions > > > > > then of course) > > > > > > On 5 Jul., 01:06, Zeu5 wrote: > > > > > > > I have cars controller, Car model and views for cars. > > > > > > > I am using Twig > > > > > > 1.0,http://www.twig-project.org/doc/templates.html#list-of-control-struct... > > > > > > Cake 1.3 > > > > > > > I want to do the following in the controller: > > > > > > > function index() { > > > > > > > ... > > > > > > > $carData = $this->Car->find('all'); > > > > > > > $cars = Car::prepareForView($carData); > > > > > > > $this->set('cars', $cars); > > > > > > > } > > > > > > > the prepareForView will turn the car data into an object that > > > > > > implements the > > > > > > IteratorAggregatehttp://php.net/manual/en/class.iteratoraggregate.php > > > > > > > the reason is because i want to be able to do the following in the > > > > > > view using Twig. > > > > > > > {{ cars.size }} // returns me the size > > > > > > {{ cars.first }} // returns me the first element of the array > > > > > > {{ cars.last }} // returns me the last element of the array > > > > > > > Am i right in wanting to prepare the array as an IteratorAggregate? > > > > > > If i do this for Car and other models, how should i do it? > > > > > > > Advice, please. 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: separate class that prepares an IteratorAggregate object for View layer - where to place this?
Hi there, i think you mean a Model Behavior? If so, do i still need to create a separate class which implements the IteratorAggregate? If so, is it done in the same file as the Behavior? Thank you. On Jul 5, 5:28 pm, euromark wrote: > i see > you would probably need a global app controller behavior which > translates everything right away > > php doesnt have the attributes itself > but you can acomplish that by using: > $size = count($cars); > $first = array_shift($cars); > $last = array_pop($cars); > and may others > etc > > On 5 Jul., 02:38, Zeu5 wrote: > > > > > > > > > I am using Twig so that I can make it as easy for designers to design > > themes as possible without knowing php. > > > Currently, Twig evaluates the strings, arrays, objects like > > thishttp://www.twig-project.org/doc/templates.html#variables > > > i want to keep things as simple and as brief as possible. > > > Hence I want to make it such that designers need only use > > {{ cars.size }} , {{ cars.first }} and {{ cars.last }} > > > So i guessed that cars cannot be usual php arrays, but objects with > > attributes for size, first and last. > > > If my understanding is wrong about php arrays, i apologise. > > > Please educate me on how usual php arrays can possibly have these > > attributes as well. > > > On Jul 5, 7:17 am, euromark wrote: > > > > why are the normal 1.3 arrays not working for you? > > > they also have all those functions built in (in plain php functions > > > then of course) > > > > On 5 Jul., 01:06, Zeu5 wrote: > > > > > I have cars controller, Car model and views for cars. > > > > > I am using Twig > > > > 1.0,http://www.twig-project.org/doc/templates.html#list-of-control-struct... > > > > Cake 1.3 > > > > > I want to do the following in the controller: > > > > > function index() { > > > > > ... > > > > > $carData = $this->Car->find('all'); > > > > > $cars = Car::prepareForView($carData); > > > > > $this->set('cars', $cars); > > > > > } > > > > > the prepareForView will turn the car data into an object that > > > > implements the > > > > IteratorAggregatehttp://php.net/manual/en/class.iteratoraggregate.php > > > > > the reason is because i want to be able to do the following in the > > > > view using Twig. > > > > > {{ cars.size }} // returns me the size > > > > {{ cars.first }} // returns me the first element of the array > > > > {{ cars.last }} // returns me the last element of the array > > > > > Am i right in wanting to prepare the array as an IteratorAggregate? > > > > If i do this for Car and other models, how should i do it? > > > > > Advice, please. 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: separate class that prepares an IteratorAggregate object for View layer - where to place this?
I am using Twig so that I can make it as easy for designers to design themes as possible without knowing php. Currently, Twig evaluates the strings, arrays, objects like this http://www.twig-project.org/doc/templates.html#variables i want to keep things as simple and as brief as possible. Hence I want to make it such that designers need only use {{ cars.size }} , {{ cars.first }} and {{ cars.last }} So i guessed that cars cannot be usual php arrays, but objects with attributes for size, first and last. If my understanding is wrong about php arrays, i apologise. Please educate me on how usual php arrays can possibly have these attributes as well. On Jul 5, 7:17 am, euromark wrote: > why are the normal 1.3 arrays not working for you? > they also have all those functions built in (in plain php functions > then of course) > > On 5 Jul., 01:06, Zeu5 wrote: > > > > > > > > > I have cars controller, Car model and views for cars. > > > I am using Twig > > 1.0,http://www.twig-project.org/doc/templates.html#list-of-control-struct... > > Cake 1.3 > > > I want to do the following in the controller: > > > function index() { > > > ... > > > $carData = $this->Car->find('all'); > > > $cars = Car::prepareForView($carData); > > > $this->set('cars', $cars); > > > } > > > the prepareForView will turn the car data into an object that > > implements the > > IteratorAggregatehttp://php.net/manual/en/class.iteratoraggregate.php > > > the reason is because i want to be able to do the following in the > > view using Twig. > > > {{ cars.size }} // returns me the size > > {{ cars.first }} // returns me the first element of the array > > {{ cars.last }} // returns me the last element of the array > > > Am i right in wanting to prepare the array as an IteratorAggregate? > > If i do this for Car and other models, how should i do it? > > > Advice, please. 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
separate class that prepares an IteratorAggregate object for View layer - where to place this?
I have cars controller, Car model and views for cars. I am using Twig 1.0, http://www.twig-project.org/doc/templates.html#list-of-control-structures Cake 1.3 I want to do the following in the controller: function index() { ... $carData = $this->Car->find('all'); $cars = Car::prepareForView($carData); $this->set('cars', $cars); } the prepareForView will turn the car data into an object that implements the IteratorAggregate http://php.net/manual/en/class.iteratoraggregate.php the reason is because i want to be able to do the following in the view using Twig. {{ cars.size }} // returns me the size {{ cars.first }} // returns me the first element of the array {{ cars.last }} // returns me the last element of the array Am i right in wanting to prepare the array as an IteratorAggregate? If i do this for Car and other models, how should i do it? Advice, please. 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: how to use counterquery in cakephp
I found what works at the Wheel model use the counterscope http://book.cakephp.org/view/816/counterCache-Cache-your-count 'counterScope' => array('Wheel.status' => 'active') // only count if "Wheel" is active Please double ensure that the child counter field has no plural like wheel_count instead of wheels_count. On Mar 25, 8:14 pm, Jeremy Burns | Class Outfit wrote: > By the way - have a go and come back if you can't get it to work. > > Jeremy Burns > Class Outfit > > jeremybu...@classoutfit.comhttp://www.classoutfit.com > > On 25 Mar 2011, at 12:10, Zeu5 wrote: > > > > > > > > > Thank you Jeremy. > > > Would you give me a bit more details? > > > some example code perhaps? > > > On Mar 25, 8:06 pm, Jeremy Burns | Class Outfit > > wrote: > >> I think you'll need to write your own custom function for that and put in > >> the afterSave callback of the 'Wheel' model. > > >> Jeremy Burns > >> Class Outfit > > >> jeremybu...@classoutfit.comhttp://www.classoutfit.com > > >> On 25 Mar 2011, at 11:39, Zeu5 wrote: > > >>> Hi > > >>> i need help understanding counterquery > > >>> i know right now cakephp allows me to store children count in parent > >>> table > > >>> eg a Car hasMany Wheel > > >>> so in cars table, there is a wheels_count column. > > >>> but i only want to store the wheel associated with a particular car > >>> AND has a status as 'active'. > > >>> Meaning, if 5 Wheel records belong to a Car with id = 17, but of these > >>> 5 only 3 of them have a Wheel.status = 'active', then the > >>> Car.wheels_count for id 17 is 3. > > >>> so apparently counterquery helps me to do this? > > >>> Please enlighten me. > > >>> Thank you. > > >>> -- > >>> Our newest site for the community: CakePHP Video > >>> Tutorialshttp://tv.cakephp.org > >>> Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp > >>> others with their CakePHP related questions. > > >>> To unsubscribe from this group, send email to > >>> cake-php+unsubscr...@googlegroups.com For more options, visit this group > >>> athttp://groups.google.com/group/cake-php > > > -- > > Our newest site for the community: CakePHP Video > > Tutorialshttp://tv.cakephp.org > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help > > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > > cake-php+unsubscr...@googlegroups.com For more options, visit this group > > athttp://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: how to use counterquery in cakephp
Thank you Jeremy. Would you give me a bit more details? some example code perhaps? On Mar 25, 8:06 pm, Jeremy Burns | Class Outfit wrote: > I think you'll need to write your own custom function for that and put in the > afterSave callback of the 'Wheel' model. > > Jeremy Burns > Class Outfit > > jeremybu...@classoutfit.comhttp://www.classoutfit.com > > On 25 Mar 2011, at 11:39, Zeu5 wrote: > > > > > > > > > Hi > > > i need help understanding counterquery > > > i know right now cakephp allows me to store children count in parent > > table > > > eg a Car hasMany Wheel > > > so in cars table, there is a wheels_count column. > > > but i only want to store the wheel associated with a particular car > > AND has a status as 'active'. > > > Meaning, if 5 Wheel records belong to a Car with id = 17, but of these > > 5 only 3 of them have a Wheel.status = 'active', then the > > Car.wheels_count for id 17 is 3. > > > so apparently counterquery helps me to do this? > > > Please enlighten me. > > > Thank you. > > > -- > > Our newest site for the community: CakePHP Video > > Tutorialshttp://tv.cakephp.org > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help > > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > > cake-php+unsubscr...@googlegroups.com For more options, visit this group > > athttp://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
how to use counterquery in cakephp
Hi i need help understanding counterquery i know right now cakephp allows me to store children count in parent table eg a Car hasMany Wheel so in cars table, there is a wheels_count column. but i only want to store the wheel associated with a particular car AND has a status as 'active'. Meaning, if 5 Wheel records belong to a Car with id = 17, but of these 5 only 3 of them have a Wheel.status = 'active', then the Car.wheels_count for id 17 is 3. so apparently counterquery helps me to do this? Please enlighten me. 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
how do i customize a error404 for themes?
Hi, i am currently using http://github.com/m3nt0r/cakephp-twig-view plugin for theming issues. Long story short, instead of using CakePHP CTP views, this plugin allows me to use Twig a templating language like Smarty. It works great. All I need is to do a $this->render('filename'); it will render the proper .tpl file in the proper theme folder. Question now is: I cannot do it for error404 pages. no matter what i do, the displayed view is always the one in app/views/ errors i want the one inside app/views/themed/theme_name/errors/ to show up. Please advise. -- 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
is there a way to render views that are NOT in a controller folder under themed?
Hi there, I want to make it as easy as I can for my users to customize their own themes. I want to know if there is a way I can render views onto actions in this manner. under app/views/themed/some_theme_name/products/view.ctp, i am rendering this view for products view action. is there a way i can use app/views/themed/some_theme_name/product.ctp as the view for the same action? 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: array formatting for pagination
Paginated array Array ( [0] => Array ( [Product] => Array ( [id] => 8 [shop_id] => 2 [title] => test [code] => [description] => test [price] => 1. [created] => 2011-03-03 09:51:41 [modified] => 2011-03-03 09:51:41 [status] => 1 [weight] => 1. [currency] => SGD [weight_unit] => kg [shipping_required] => 1 ) [ProductImage] => Array ( [id] => 5 [filename] => wal_mart_t_shirt_for_web-1.jpg [dir] => uploads/products [product_id] => 8 [cover] => 1 [created] => 2011-03-03 09:51:41 [modified] => 2011-03-03 09:51:41 [mimetype] => image/jpeg [filesize] => 14479 ) ) [1] => Array ( [Product] => Array ( [id] => 7 [shop_id] => 2 [title] => test [code] => [description] => test [price] => 0. [created] => 2011-03-03 08:42:16 [modified] => 2011-03-03 08:42:17 [status] => 1 [weight] => 0. [currency] => SGD [weight_unit] => kg [shipping_required] => 1 ) [ProductImage] => Array ( [id] => 4 [filename] => wal_mart_t_shirt_for_web-0.jpg [dir] => uploads/products [product_id] => 7 [cover] => 1 [created] => 2011-03-03 08:42:17 [modified] => 2011-03-03 08:42:17 [mimetype] => image/jpeg [filesize] => 14479 ) ) and more Desired array Array ( [0] => Array ( [id] => 8 [shop_id] => 2 [title] => test [description] => test [price] => 1. [created] => 2011-03-03 09:51:41 [modified] => 2011-03-03 09:51:41 [status] => 1 [weight] => 1. [currency] => SGD [weight_unit] => kg [shipping_required] => 1 [image] => wal_mart_t_shirt_for_web-1.jpg ) and more -- 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: array formatting for pagination
Hi all, i got what I need, but only after some pretty ugly code. would appreciate if someone tells me a better way of doing it. $this->paginate = array( 'fields'=>array('Product.*', 'ProductImage.id', 'ProductImage.filename', 'ProductImage.dir'), 'conditions' => array('OR' => array ( array('ProductImage.cover'=>true), array('ProductImage.cover'=>null), ), ), 'link'=>array('ProductImage'), 'order'=> array('Product.created DESC') ); $this->paginate['conditions']['AND'] = array('Product.shop_id' => Shop::get('Shop.id')); $products = $this->paginate('Product'); /* here starts the ugly code */ $images = Set::combine($products, '{n}.ProductImage.product_id', '{n}.ProductImage.filename'); $products = Set::extract('{n}.Product', $products); foreach($realProducts as $key=>$product) { foreach($images as $product_id => $image) { if ($product['id'] == $product_id) { $realProducts[$key]['image'] = $image; unset($images[$product_id]); break; } } } /* $realProducts is the result I want */ On Mar 21, 6:44 am, Zeu5 wrote: > Hi all, > > my pagination code in controller looks like this > > $this->paginate = array( > 'conditions' => array('OR' => > array ( > array('ProductImage.cover'=>true), > array('ProductImage.cover'=>null), > ), > ), > 'link'=>array('ProductImage'), > 'fields'=>array('Product.*', 'ProductImage.id', > 'ProductImage.filename', 'ProductImage.dir'), > 'order'=> array('Product.created DESC') > ); > > $this->paginate['conditions']['AND'] = array('Product.shop_id' > => Shop::get('Shop.id')); > > I do not wish to change the conditions whatsoever. I have the > following as the result of the pagination. > > Array > ( > [0] => Array > ( > [Product] => Array > ( > [id] => 8 > [shop_id] => 2 > [title] => test > [code] => > [description] => test > [price] => 1. > [created] => 2011-03-03 09:51:41 > [modified] => 2011-03-03 09:51:41 > [status] => 1 > [weight] => 1. > [currency] => SGD > [weight_unit] => kg > [shipping_required] => 1 > ) > > [ProductImage] => Array > ( > [id] => 5 > [filename] => wal_mart_t_shirt_for_web-1.jpg > [dir] => uploads/products > [product_id] => 8 > [cover] => 1 > [created] => 2011-03-03 09:51:41 > [modified] => 2011-03-03 09:51:41 > [mimetype] => image/jpeg > [filesize] => 14479 > ) > > ) > > [1] => Array > ( > [Product] => Array > ( > [id] => 7 > [shop_id] => 2 > [title] => test > [code] => > [description] => test > [price] => 0. > [created] => 20
array formatting for pagination
Hi all, my pagination code in controller looks like this $this->paginate = array( 'conditions' => array('OR' => array ( array('ProductImage.cover'=>true), array('ProductImage.cover'=>null), ), ), 'link'=>array('ProductImage'), 'fields'=>array('Product.*', 'ProductImage.id', 'ProductImage.filename', 'ProductImage.dir'), 'order'=> array('Product.created DESC') ); $this->paginate['conditions']['AND'] = array('Product.shop_id' => Shop::get('Shop.id')); I do not wish to change the conditions whatsoever. I have the following as the result of the pagination. Array ( [0] => Array ( [Product] => Array ( [id] => 8 [shop_id] => 2 [title] => test [code] => [description] => test [price] => 1. [created] => 2011-03-03 09:51:41 [modified] => 2011-03-03 09:51:41 [status] => 1 [weight] => 1. [currency] => SGD [weight_unit] => kg [shipping_required] => 1 ) [ProductImage] => Array ( [id] => 5 [filename] => wal_mart_t_shirt_for_web-1.jpg [dir] => uploads/products [product_id] => 8 [cover] => 1 [created] => 2011-03-03 09:51:41 [modified] => 2011-03-03 09:51:41 [mimetype] => image/jpeg [filesize] => 14479 ) ) [1] => Array ( [Product] => Array ( [id] => 7 [shop_id] => 2 [title] => test [code] => [description] => test [price] => 0. [created] => 2011-03-03 08:42:16 [modified] => 2011-03-03 08:42:17 [status] => 1 [weight] => 0. [currency] => SGD [weight_unit] => kg [shipping_required] => 1 ) [ProductImage] => Array ( [id] => 4 [filename] => wal_mart_t_shirt_for_web-0.jpg [dir] => uploads/products [product_id] => 7 [cover] => 1 [created] => 2011-03-03 08:42:17 [modified] => 2011-03-03 08:42:17 [mimetype] => image/jpeg [filesize] => 14479 ) ) I want this instead where the image value is taken from ProductImage.filename Array ( [0] => Array ( [id] => 8 [shop_id] => 2 [title] => test [description] => test [price] => 1. [created] => 2011-03-03 09:51:41 [modified] => 2011-03-03 09:51:41 [status] => 1 [weight] => 1. [currency] => SGD [weight_unit] => kg [shipping_required] => 1 [image] => wal_mart_t_shirt_for_web-1.jpg ) -- 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: how to use transactions in cakephp
Thank you for the update PhpNut :) On Jan 12, 6:58 pm, "Larry E. Masters" wrote: > I just noticed this thread. You might want to look at a video someone > uploaded tohttp://tv.cakephp.orgrecently showing how to use transactions > with CakePHP > > http://tv.cakephp.org/video/guille1983/2011/01/10/database_transactions > > -- > Larry E. Masters > > > > > > > > On Tue, Jan 11, 2011 at 11:44 PM, huoxito wrote: > > great topic, just helped me alot here, thanks! so good cake got this group! > > > 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 > om>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: manipulation of fields before saving - how to get it to work for saveAll?
What if the saveAll is called from the parent model rather than from the actual model itself? nope, i am not passing anything other than $data. On Jan 11, 7:56 pm, Amit Badkas wrote: > Hi, > > The saveAll() internally calls save(), that's why I suggested to use > beforeSave(). Are you passing any option to saveAll() other than data? > > Amit Badkas > > PHP Applications for E-Biz:http://www.sanisoft.com > > > > > > > > On Tue, Jan 11, 2011 at 5:11 PM, Zeu5 wrote: > > Thank you Amit, but the same issue arises. > > > in a saveAll, the fields are not directly at ['model_alias'] > > ['field_name'] > > > so changing it to beforeSave would not help. > > > I am not sure if i have made myself clear enough. > > > On Jan 11, 7:36 pm, Amit Badkas wrote: > > > Hi, > > > > I think you need to try beforeSave() instead of beforeValidate(), hope it > > > may work. > > > > Amit Badkas > > > > PHP Applications for E-Biz:http://www.sanisoft.com > > > > On Tue, Jan 11, 2011 at 5:02 PM, Zeu5 wrote: > > > > let say my model Link has 3 fields > > > > route, model, action, > > > > > what I want is that route is the combination of model and action. > > > > > eg > > > > model = '/orders/view/'; > > > > action = '3'; > > > > > so route is '/orders/view/3'; > > > > > i did this in my beforeValidate > > > > > if (isset($this->data['Link']['model']) && isset($this->data['Link'] > > > > ['action'])) { > > > > $this->data['Link']['route'] = > > > > $this->data['Link']['model'] . $this- > > > > >data['Link']['action']; > > > > } > > > > > now the problem is when i do a saveAll, this will not work. > > > > > because the data will be > > > > > Array( > > > > [Link] => Array( > > > > [0] => Array( > > > > [id] => 3, > > > > [model]=>'/orders/view/', > > > > [action]=>'3' > > > > ) > > > > ) > > > > ) > > > > > Please advise. > > > > > 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 > > > om> > > For more options, visit this > > group at > > > >http://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 > om>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: manipulation of fields before saving - how to get it to work for saveAll?
Thank you Amit, but the same issue arises. in a saveAll, the fields are not directly at ['model_alias'] ['field_name'] so changing it to beforeSave would not help. I am not sure if i have made myself clear enough. On Jan 11, 7:36 pm, Amit Badkas wrote: > Hi, > > I think you need to try beforeSave() instead of beforeValidate(), hope it > may work. > > Amit Badkas > > PHP Applications for E-Biz:http://www.sanisoft.com > > > > > > > > On Tue, Jan 11, 2011 at 5:02 PM, Zeu5 wrote: > > let say my model Link has 3 fields > > route, model, action, > > > what I want is that route is the combination of model and action. > > > eg > > model = '/orders/view/'; > > action = '3'; > > > so route is '/orders/view/3'; > > > i did this in my beforeValidate > > > if (isset($this->data['Link']['model']) && isset($this->data['Link'] > > ['action'])) { > > $this->data['Link']['route'] = > > $this->data['Link']['model'] . $this- > > >data['Link']['action']; > > } > > > now the problem is when i do a saveAll, this will not work. > > > because the data will be > > > Array( > > [Link] => Array( > > [0] => Array( > > [id] => 3, > > [model]=>'/orders/view/', > > [action]=>'3' > > ) > > ) > > ) > > > Please advise. > > > 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 > om>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
manipulation of fields before saving - how to get it to work for saveAll?
let say my model Link has 3 fields route, model, action, what I want is that route is the combination of model and action. eg model = '/orders/view/'; action = '3'; so route is '/orders/view/3'; i did this in my beforeValidate if (isset($this->data['Link']['model']) && isset($this->data['Link'] ['action'])) { $this->data['Link']['route'] = $this->data['Link']['model'] . $this- >data['Link']['action']; } now the problem is when i do a saveAll, this will not work. because the data will be Array( [Link] => Array( [0] => Array( [id] => 3, [model]=>'/orders/view/', [action]=>'3' ) ) ) Please advise. 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: ajax added child row is not sent as part of data.
Thank you cricket. Your response prompted me to look into the right place. I realised what i did and place my form tags properly this time. All i had to do was to put the form tags outside my table tags. Thank you. Have a nice day. On Jan 8, 6:14 am, cricket wrote: > On Fri, Jan 7, 2011 at 7:32 AM, Zeu5 wrote: > > Link is the model in this scenario. > > > In admin_index, > > > there is a list of Link records. > > > This whole list is wrapped within a Form. (Let us call this the > > EditListForm) > > > This EditListForm will post to the admin_edit action of the > > controller. > > > I also have a Add Link Form directly below the list. > > > The Add Link Form will create a new Link via Ajax. The Ajax response > > will return the newly created Link in HTML format. The HTML format > > will be treated as a string inside json. > > > Upon the successful completion, a js function afterAddLink() will be > > called to handle the ajax response. > > > This afterAddLink() js will append the ajax response into the list. > > using jquery. I used $('endoflist').before($response); > > This is probably your problem but without seeing your HTML structure, > I can't say for sure. Use Firebug's "inspect element" pane to watch > the list while you create a new link. Look to see if the new link is > properly included into the edit form. > > Instead of posting your ctp, could you do a view source and post just > the list (including the entire form) for one or two links? Also, the > HTML for a single, newly-added link. That would give us a better idea > of the JQuery selector to use when inserting it into the page. 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
ajax added child row is not sent as part of data.
Link is the model in this scenario. In admin_index, there is a list of Link records. This whole list is wrapped within a Form. (Let us call this the EditListForm) This EditListForm will post to the admin_edit action of the controller. I also have a Add Link Form directly below the list. The Add Link Form will create a new Link via Ajax. The Ajax response will return the newly created Link in HTML format. The HTML format will be treated as a string inside json. Upon the successful completion, a js function afterAddLink() will be called to handle the ajax response. This afterAddLink() js will append the ajax response into the list. using jquery. I used $('endoflist').before($response); here comes the issue. if i add a new link, the new link is displayed at the end of the list. and if i press the submit button of the EditListForm at this point in time, the new row will not be posted over. How do i fix this? Here are some extra information: 1) i use Security component, but that is not the issue, because when i use firebug, i cannot see the new row data when i post the EditListForm. 2) when the new row is added, i did use a Link.id.name, Link.id.id, etc format for the various input. 3) strangely if I do submit the EditListForm without first adding any new links, everything will be posted properly. 4) so if i originally have 3 links and I create a new link and then i submit the EditListForm, the firebug only displays the original 3 links data. however, if i originally have 3 links and I create a new link and then I refresh the page. Now i submit the EditListForm, all 4 links will then be posted. I cannot post my code because it is over 3 different ctp files in elements folder and others. so it is a tad messy for me to do so here. Please advise. 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: paginate posts substring body which uses tinymce - do i substr in the paginate or at the view?
i am so ignorant. http://book.cakephp.org/view/1625/truncate this is the solution and a great one. On Jan 3, 8:25 pm, Zeu5 wrote: > Hi there, > > i have a cake webapp that includes a blog. > > the body of the blog posts uses tinymce so i can put in some HTML > coding for the body of the post. > > At the index page of the blog, i do a posts/index which uses > paginate(). Straight forward enough. > > here comes the problem. > > at the index, i am displaying something like 25 posts per page. > > i want to display a shortened summary of the body of each post. > > there are 2 ways to do a substr. > > 1 way is at the paginate and use the sql code to do the substr. but i > do not know how to get it to work with cakephp paginate > > another way is that the paginate retrieves the entire body of the post > and then i use php substr function at the index.ctp. > > both seem not ideal when dealing with tinymce'd description. > > Please advise. 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
paginate posts substring body which uses tinymce - do i substr in the paginate or at the view?
Hi there, i have a cake webapp that includes a blog. the body of the blog posts uses tinymce so i can put in some HTML coding for the body of the post. At the index page of the blog, i do a posts/index which uses paginate(). Straight forward enough. here comes the problem. at the index, i am displaying something like 25 posts per page. i want to display a shortened summary of the body of each post. there are 2 ways to do a substr. 1 way is at the paginate and use the sql code to do the substr. but i do not know how to get it to work with cakephp paginate another way is that the paginate retrieves the entire body of the post and then i use php substr function at the index.ctp. both seem not ideal when dealing with tinymce'd description. Please advise. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: how to use updateAll and IN clause together
Sorry I just realised where i went wrong. I should have included literal quotes. $this->updateAll(array('product_price' =>"'" . $newPrice . "'"), array('product_id'=>$product_id, 'id '=>$cartItemIdArray)); On Dec 27, 2:15 pm, Zeu5 wrote: > This is the example of the query I want to execute. > // UPDATE cart_items SET product_price = 2 WHERE product_id = 4 AND id > IN (2,4) > > $this->updateAll(array('product_price' => $newPrice), > array('product_id'=>$product_id, > 'id '=>$cartItemIdArray)); > > $this->updateAll(array('product_price' => $newPrice), > array('product_id'=>$product_id, > 'id IN '=>$cartItemIdArray)); > > Neither of these queries work. > > Please advise. > > 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
how to use updateAll and IN clause together
This is the example of the query I want to execute. // UPDATE cart_items SET product_price = 2 WHERE product_id = 4 AND id IN (2,4) $this->updateAll(array('product_price' => $newPrice), array('product_id'=>$product_id, 'id '=>$cartItemIdArray)); $this->updateAll(array('product_price' => $newPrice), array('product_id'=>$product_id, 'id IN '=>$cartItemIdArray)); Neither of these queries work. Please advise. 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: how to use ssl to secure subdomains of a cakephp app
Hi Ryan, happy holidays! I have 3 questions. 2 are follow ups on your excellent replies. > The problem with this is figuring out how to transfer session data that > you've already started at subdomainx.example.com to secure.example.com. You > could set the session domain to example.com; that may be the cleanest option, > though this contradicts best practices for reducing cookie transmissions for > resources that don't need them, i.e.: > > http://developer.yahoo.com/performance/rules.html#cookie_free > > Another strategy to consider is just not using sessions on any of the > subdomains at all. If you come to a point where you need to put data into the > session, that's the time when you redirect to the secure hostname, and put > all session data there to start with. > 1) Thank you Ryan. I never thought there would be a good reason to have www.example.com and should just settle for example.com for the main site. Reading about the cookie-free rule leads me to understand this benefit. I also did not realise about the session transfer. For my implementation, www.example.com or example.com is just merely the basic signup page. whereas subdomain1.example.com, subdomain2.example.com, subdomain3.example.com, etc are standalone websites belonging to each user in my app. Right now i have 2 `app` folders in my cakephp project. the first `app` folder `subdomains` is for handling all the subdomains. ie those standalone websites. the second `app` folder called `main` is for handling the main domain. ie registration. (i may have future features like offering free themes in themes.example.com in future. These functions/features would be handled by this `main` folder) Clearly I want the various subdomains to be treated like separate websites as that is the purpose of the cakephp app. How do i achieve that? I am currently using database sessions in both `app` folders in my cakephp project. in my `subdomains` folder, in my app_controller beforeFilter function, i have already configured the cookie to be something like this $this->Cookie->name = Domain::get('Domain.subdomain'); $this->Cookie->time = '365 days'; $this->Cookie->key = '12345' . $domainId; Will this ensure that visitors to different subdomains have different cookies to different subdomains? Not sure how to do the same for session though. > Well, you either buy a wildcard SSL certificate that covers all the > subdomains of your domain, or you buy an individual regular SSL certificate > for each subdomain. One popular SSL certificate provider whose web site I > just checked charges $60/yr for a regular SSL certificate that covers one > subdomain, or $200/yr for a wildcard SSL certificate that covers unlimited > subdomains on a domain. Clearly, at these prices, if you need to protect 4 or > more subdomains, a wildcard SSL certificate is the cheaper option. 2) I found one that is 499/yr from GeoTrust/Equifax. Would love to hear which one is 200/yr. Is it GoDaddy? Think i am going to need a wildcard cert, because i intend to ssl secure the admin backend for users and that would mean something like https://subdomain.example.com/admin I also noticed that there is a difference between certs that verify the domain and certs that verify both domain and organizations. Would both have the same green indicator on modern browsers like chrome, firefox and IE? I just want one where the browsers would give a green indicator, whichever is cheaper. I am thinking both functionally are the same, just that the latter has an extra layer of authentication on the organization. Brand new question 3) because i allow my users to use domains they have registered themselves, http://subdomain1.example.com could easily become http://www.userowndomain.com Clearly i want to ssl secure transactions related pages like orders/ checkout. so if a visitor to http://www.userowndomain.com and goes to the orders/ checkout action, i would direct them to https://subdomain1.example.com/orders/checkout Implementation wise, this should not be a problem. The problem i am facing is the session/cookie issue. What are your thoughts? I am inclined towards your 2nd strategy of > Another strategy to consider is just not using sessions on any of the > subdomains at all. If you come to a point where you need to put data into the > session, that's the time when you redirect to the secure hostname, and put > all session data there to start with. A rough example to see how this would work using cakephp would be much much appreciated. 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://group
Re: how to use ssl to secure subdomains of a cakephp app
Thanks Matt. I spoke to poLK in #cakephp quite some time after my posting. She (i think) mentioned the same idea about using wildcard cert. Thanks for the tip. On Dec 25, 9:17 am, Matt Murphy wrote: > In order to get to user1.domain.com, your user would have to log in. Am I > right in thinking that is on the list of encrypted events? And certainly > there must be a few others like user management functions? Ok, shutting up > now. > > Unless you have a wildcart cert, you'll have to use method a. Obviously, > the wildcard cert solution would be way sexier (enabling method b), but > those things are expensive. > > Matt > > > > > > > > On Fri, Dec 24, 2010 at 7:06 PM, Zeu5 wrote: > > Hi there, > > > my cakephp app allows users to create subdomains. > > > for eg, > > > user1 creates subdomain1.example.com and > > user2 creates subdomain2.example.com and so on... > > > all subdomains are pointing to the same app folder. > > > if a new subdomain is created, i merely keep track of it by inserting > > new record in subdomains table. no new copies of `app` folder are > > created. > > > i have a action common in all subdomains called orders/checkout > > > i want to ssl secure this page. > > > Do I > > > a) > > create a separate subdomain such that all visitors to the different > > subdomains are redirected to it? > > > eg, visitors at subdomain1.example.com or subdomain2.example.com will > > ALL be directed tohttps://secure.example.com/orders/checkoutwhen > > they run the orders/checkout action > > > OR > > > b) > > > all the visitors at subdomain1.example.com are directed to > >https://subdomain1.example.com/orders/checkout > > > all the visitors at subdomain2.example.com are directed to > >https://subdomain2.example.com/orders/checkout > > > and so on.. > > > if it is a) how do i achieve that? > > > if it is b) how do i achieve that? > > > is there an alternative to a) and b)? if so, how do i achieve that? > > > Thank you . > > > Happy holidays > > > 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 > om>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
how to use ssl to secure subdomains of a cakephp app
Hi there, my cakephp app allows users to create subdomains. for eg, user1 creates subdomain1.example.com and user2 creates subdomain2.example.com and so on... all subdomains are pointing to the same app folder. if a new subdomain is created, i merely keep track of it by inserting new record in subdomains table. no new copies of `app` folder are created. i have a action common in all subdomains called orders/checkout i want to ssl secure this page. Do I a) create a separate subdomain such that all visitors to the different subdomains are redirected to it? eg, visitors at subdomain1.example.com or subdomain2.example.com will ALL be directed to https://secure.example.com/orders/checkout when they run the orders/checkout action OR b) all the visitors at subdomain1.example.com are directed to https://subdomain1.example.com/orders/checkout all the visitors at subdomain2.example.com are directed to https://subdomain2.example.com/orders/checkout and so on.. if it is a) how do i achieve that? if it is b) how do i achieve that? is there an alternative to a) and b)? if so, how do i achieve that? Thank you . Happy holidays Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: how to use transactions in cakephp
Hi Amit, it worked. Thank you very much. Saw your website. Interesting. Apparently i had previously added you to my watchlist for providers who appear to be experienced in cakephp. Perhaps next time when i seek major help in cakephp, i will consider your company more. :) Have a good weekend. On Dec 24, 4:31 pm, Amit Badkas wrote: > Hi, > > I didn't know that you need to use saveAll() inside transaction. By default, > saveAll() starts new transaction. So change your saveAll() call from > > $result = $this->saveAll($data); > > to > > $result = $this->saveAll($data, array('atomic' => false)); > > Hope this helps. > > Amit Badkas > > PHP Applications for E-Biz:http://www.sanisoft.com > > > > > > > > On Fri, Dec 24, 2010 at 1:30 PM, Zeu5 wrote: > > Hi all, > > > it did not work. > > > I have tried > > > This is for a Merchant Model; > > > $datasource = $this->getDataSource(); > > > $datasource->begin($this); > > > $result = $this->saveAll($data); > > if (!$result) { > > $datasource->rollback($this); > > return false; > > } > > /** > > * do something to form a $domainData array > > **/ > > $result = $this->Shop->Domain->save($domainData); > > > if (!$result) { > > $datasource->rollback($this); > > return false; > > } > > > // and so on. > > > // finally the last one has > > > if (!$result) { > > $datasource->rollback($this); > > return false; > > } else { > > $datasource->commit($this); > > } > > > There is no single transaction to speak of. because if i purposely > > fail the last save() or saveAll(). the previous save and saveAll will > > work. > > > Please advise. > > > 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 > om>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: how to use transactions in cakephp
Thanks for the tip Amit. I shall go try that. Any idea why i cannot subscribe to this particular thread via my gmail? On Dec 24, 4:31 pm, Amit Badkas wrote: > Hi, > > I didn't know that you need to use saveAll() inside transaction. By default, > saveAll() starts new transaction. So change your saveAll() call from > > $result = $this->saveAll($data); > > to > > $result = $this->saveAll($data, array('atomic' => false)); > > Hope this helps. > > Amit Badkas > > PHP Applications for E-Biz:http://www.sanisoft.com > > > > > > > > On Fri, Dec 24, 2010 at 1:30 PM, Zeu5 wrote: > > Hi all, > > > it did not work. > > > I have tried > > > This is for a Merchant Model; > > > $datasource = $this->getDataSource(); > > > $datasource->begin($this); > > > $result = $this->saveAll($data); > > if (!$result) { > > $datasource->rollback($this); > > return false; > > } > > /** > > * do something to form a $domainData array > > **/ > > $result = $this->Shop->Domain->save($domainData); > > > if (!$result) { > > $datasource->rollback($this); > > return false; > > } > > > // and so on. > > > // finally the last one has > > > if (!$result) { > > $datasource->rollback($this); > > return false; > > } else { > > $datasource->commit($this); > > } > > > There is no single transaction to speak of. because if i purposely > > fail the last save() or saveAll(). the previous save and saveAll will > > work. > > > Please advise. > > > 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 > om>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: how to use transactions in cakephp
Hi all, it did not work. I have tried This is for a Merchant Model; $datasource = $this->getDataSource(); $datasource->begin($this); $result = $this->saveAll($data); if (!$result) { $datasource->rollback($this); return false; } /** * do something to form a $domainData array **/ $result = $this->Shop->Domain->save($domainData); if (!$result) { $datasource->rollback($this); return false; } // and so on. // finally the last one has if (!$result) { $datasource->rollback($this); return false; } else { $datasource->commit($this); } There is no single transaction to speak of. because if i purposely fail the last save() or saveAll(). the previous save and saveAll will work. Please advise. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: how to use transactions in cakephp
Alright thanks! On Dec 23, 8:55 pm, Jon Bennett wrote: > > Unfortunately the 7 models are not interrelated to each other, some > > are of course related. > > > So i am not sure if saveAll allows that non interrelated models. > > I've only used transactions in cake to save related data, though I > believe once a transaction has been triggered, it will wrap any > subsequent saveAll's as well - not certain on that, worth checking! > > not used the datasource way of doing it, sorry. > > hth > > Jo > > -- > 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: how to use transactions in cakephp
Hi Jon > Use innodb and connect your keys/tables correctly. > Use saveAll not save and it will wrap all the SQL into a single transaction. Are you suggesting an alternative to http://book.cakephp.org/view/1633/Transactions ? Unfortunately the 7 models are not interrelated to each other, some are of course related. So i am not sure if saveAll allows that non interrelated models. 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
how to use transactions in cakephp
hi there, i have a 7 model transaction that needs to be rolled back whenever 1 of the tables do not commit properly. i found this but i am not sure how it works. http://book.cakephp.org/view/1633/Transactions I am vaguely familiar with MySQL transaction but prefer to follow cake way of doing things. Appreciate it with any advice rendered. 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