Re: How to upload and retrieve an image from databse/dir?
It will be better if you can save the image inside *app/webroot/image/ *folder rather than saving the images in database . In datatbase you can save the name of images . If you will be saving it in database you have to worry the type of image and the size of image will can make the database huge. But, if you want to save it in database follow this link: http://vikasmahajan.wordpress.com/2010/07/07/inserting-and-displaying-images-in-mysql-using-php/ On Tue, Jul 31, 2012 at 10:16 PM, rahul rahul.mamtani...@gmail.com wrote: Hi i am new to cakephp.I have created a registration form and i want when i fill this form and select an image for a person i can save information with image in database.After saving information i will be able to view that information along with that image. Can anyone help me? -- 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
Database sessions garbage collection issue
I'm having some issues with my sessions. It's probably configuration somewhere, but don't know what to change/where to look. I'm using database sessions for my cake application, these sessions are not getting cleaned up. The app in question I have the issue on is an old one written on 1.3.10 running with php version 5.3.5. The garbage collection function in the 2.x branch is the same so don't think the framework version will matter. I've tracked down the issue to the function __gc located in the CakeSession class and that function is registered there in the php session_set_save_handler function, this is the function in question: /** * Helper function called on gc for database sessions. * * @param integer $expires Timestamp (defaults to current time) * @return boolean Success * @access private */function __gc($expires = null) { $model = ClassRegistry::getObject('Session'); if (!$expires) { $expires = time(); } $return = $model-deleteAll(array($model-alias . .expires = $expires), false, false); return $return; } Now, the comments say that $expires is a timestamp, but this isn't correct according to the php docs: gc($lifetime) The garbage collector callback is invoked internally by PHP periodically in order to purge old session data. The frequency is controlled by session.gc_probability and session.gc_divisor. The value of lifetime which is passed to this callback can be set in session.gc_maxlifetime. Return value should be TRUE for success, FALSE for failure. The value for $lifeime, so gc_maxlifetime in php.ini is the following: ; After this number of seconds, stored data will be seen as 'garbage' and ; cleaned up by the garbage collection process.session.gc_maxlifetime = 3600 So this results in a query that never deletes anything: delete from cake_sessions where expires 3600; Could someone clarify what I'm doing wrong or if this is an issue in cake itself? I've posted this on ask.cakephp.org as well, when I find the answer I'll make sure to update both locations. http://ask.cakephp.org/questions/view/database_sessions_garbage_collection_issue -- 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: Is CakePHP more suitable for web services or Zend Framework?
Thanks for the recommendation. Although CakePHP may be an overkill, it is flexible enough to handle future new features requested by customer. slimframework may be useful for personal projects but I will stick to a more flexible framework like CakePHP or Zend when making recommendation to my boss. On Wednesday, August 1, 2012 1:44:57 PM UTC+8, Dr. Tarique Sani wrote: If you are sure that your project is always going to be web service only I would suggest start with a framework dedicated for such task. eg: Slim http://www.slimframework.com/ Both CakePHP and ZendFW will be an overkill HTH Tarique On Wed, Aug 1, 2012 at 6:55 AM, Lightee lightai...@gmail.com wrote: Dear CakePHP gurus, I have no intention to start an emotional thread about which framework is better. Asking this question on this forum is also rather stupid because members here are likely to be biased. Nevertheless, I hope to get objective replies. I would like to build a website that focuses on web services - particularly CRUD, search and query functions. From what I read on the net, Zend Framework supporters say that Zend has much more components than CakePHP to support web services. On the other hand, my understanding of CakePHP is that Zend Framework components can be imported into CakePHP vendors folder. If that is the case, wouldn't it be a no-brainer to use CakePHP? In that regard, I have a few questions ... - How easy is it to import Zend components into CakePHP? Do we need to modify the Zend components such that they follow certain naming conventions? - Can most Zend components or only selected ones be imported? How about the ones that deal with web services? Thank you for your help. -- 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 -- = PHP for E-Biz: http://sanisoft.com = -- 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
Use of requestaction
I just want to know that the use of *requestaction* in a view file is good for coding or using *Class::Rergistry* is better then *requestaction* ? -- 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 upload and retrieve an image from databse/dir?
Thanks nikhil for your quick reply. Would you mind telling me how to save images inside directory? On Wednesday, August 1, 2012 12:15:36 PM UTC+5:30, Nikhil Agrawal wrote: It will be better if you can save the image inside *app/webroot/image/ *folder rather than saving the images in database . In datatbase you can save the name of images . If you will be saving it in database you have to worry the type of image and the size of image will can make the database huge. But, if you want to save it in database follow this link: http://vikasmahajan.wordpress.com/2010/07/07/inserting-and-displaying-images-in-mysql-using-php/ On Tue, Jul 31, 2012 at 10:16 PM, rahul rahul.mamtani...@gmail.comwrote: Hi i am new to cakephp.I have created a registration form and i want when i fill this form and select an image for a person i can save information with image in database.After saving information i will be able to view that information along with that image. Can anyone help me? -- 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. -- 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: Is CakePHP more suitable for web services or Zend Framework?
For a RESTful API I just created a template that generate RESTful controller. Please check https://launchpad.net/cakephpapitemplate It would be nice to get help with this project. On Wed, Aug 1, 2012 at 10:34 AM, Lightee lightai...@gmail.com wrote: Thanks for the recommendation. Although CakePHP may be an overkill, it is flexible enough to handle future new features requested by customer. slimframework may be useful for personal projects but I will stick to a more flexible framework like CakePHP or Zend when making recommendation to my boss. On Wednesday, August 1, 2012 1:44:57 PM UTC+8, Dr. Tarique Sani wrote: If you are sure that your project is always going to be web service only I would suggest start with a framework dedicated for such task. eg: Slim http://www.slimframework.com/ Both CakePHP and ZendFW will be an overkill HTH Tarique On Wed, Aug 1, 2012 at 6:55 AM, Lightee lightai...@gmail.com wrote: Dear CakePHP gurus, I have no intention to start an emotional thread about which framework is better. Asking this question on this forum is also rather stupid because members here are likely to be biased. Nevertheless, I hope to get objective replies. I would like to build a website that focuses on web services - particularly CRUD, search and query functions. From what I read on the net, Zend Framework supporters say that Zend has much more components than CakePHP to support web services. On the other hand, my understanding of CakePHP is that Zend Framework components can be imported into CakePHP vendors folder. If that is the case, wouldn't it be a no-brainer to use CakePHP? In that regard, I have a few questions ... - How easy is it to import Zend components into CakePHP? Do we need to modify the Zend components such that they follow certain naming conventions? - Can most Zend components or only selected ones be imported? How about the ones that deal with web services? Thank you for your help. -- 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+unsubscribe@**googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/**group/cake-phphttp://groups.google.com/group/cake-php -- ==**==**= PHP for E-Biz: http://sanisoft.com ==**==**= -- 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 -- Regards, Zaky Katalan-Ezra QA Administrator www.IGeneriX.com Sites.IGeneriX.com 054-7762312 -- 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: hide model fields from controller
well i am worried about controller so no other team member can directly change some fields , i need to encapsulate some fields -- 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: Is CakePHP more suitable for web services or Zend Framework?
CakePHP can do what you want just fine, I've created several api's in it already. My reason for using cake is like what you say, cake has a very flexable data layer and I needed several custom datasources as i wasn't always using databases as a data source but other webservices and tcp/ip api's. What I did was create the api as a plug-in because it was part of an already existing site. I must say that worked out very well, it's both fast and very well structured. On Wednesday, August 1, 2012 3:25:43 AM UTC+2, Lightee wrote: Dear CakePHP gurus, I have no intention to start an emotional thread about which framework is better. Asking this question on this forum is also rather stupid because members here are likely to be biased. Nevertheless, I hope to get objective replies. I would like to build a website that focuses on web services - particularly CRUD, search and query functions. From what I read on the net, Zend Framework supporters say that Zend has much more components than CakePHP to support web services. On the other hand, my understanding of CakePHP is that Zend Framework components can be imported into CakePHP vendors folder. If that is the case, wouldn't it be a no-brainer to use CakePHP? In that regard, I have a few questions ... - How easy is it to import Zend components into CakePHP? Do we need to modify the Zend components such that they follow certain naming conventions? - Can most Zend components or only selected ones be imported? How about the ones that deal with web services? Thank you for your help. -- 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: Concurrent login issue: Users being logged out
Anybody? I can't be the only one who has noticed this problem, I don't believe it is as a result of any strange configuration I have in place as I do not stray far from the norm. Any help would be appreciated. On Wednesday, July 25, 2012 8:58:14 AM UTC+1, phpMagpie wrote: Morning, I am having problems when more than one person is logged in where sessions are timing out for no reason. This does not have to be two people using the same account, simply having two authorised users looking through the site (typically when I am demoing the site to a client or when multiple people testing the site at once) you have to keep logging back in, which is annoying. I am using Auth with Database Sessions and Security.level is set to medium, any pointers as to where I should be looking to resolve this? Thanks, Paul. -- 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: hide model fields from controller
if you can't trust your co-workers, you might want to change the company. PS: they could still go into the database directly to alter values (or do you also cipher the database.php?) in any case the above hints should get you started on how to address the problem. Am Mittwoch, 1. August 2012 10:37:29 UTC+2 schrieb Mahmoud Adel Farid: well i am worried about controller so no other team member can directly change some fields , i need to encapsulate some fields -- 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: hide model fields from controller
You can use the model callbacks for that, the beforesave one, see: http://book.cakephp.org/2.0/en/models/callback-methods.html#beforesave On Wednesday, August 1, 2012 10:37:29 AM UTC+2, Mahmoud Adel Farid wrote: well i am worried about controller so no other team member can directly change some fields , i need to encapsulate some fields -- 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: hide model fields from controller
it boils down to either - use security component (form fields cannot be messed with) - or use whitelisting (fieldList) on save: http://book.cakephp.org/2.0/en/models/saving-your-data.html#model-save-array-data-null-boolean-validate-true-array-fieldlist-array Am Mittwoch, 1. August 2012 11:09:21 UTC+2 schrieb Crazy: You can use the model callbacks for that, the beforesave one, see: http://book.cakephp.org/2.0/en/models/callback-methods.html#beforesave On Wednesday, August 1, 2012 10:37:29 AM UTC+2, Mahmoud Adel Farid wrote: well i am worried about controller so no other team member can directly change some fields , i need to encapsulate some fields -- 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: Is CakePHP more suitable for web services or Zend Framework?
Ask the right questions and you will get right answers :-) Tarique On Wed, Aug 1, 2012 at 1:04 PM, Lightee lightai...@gmail.com wrote: Thanks for the recommendation. Although CakePHP may be an overkill, it is flexible enough to handle future new features requested by customer. slimframework may be useful for personal projects but I will stick to a more flexible framework like CakePHP or Zend when making recommendation to my boss. On Wednesday, August 1, 2012 1:44:57 PM UTC+8, Dr. Tarique Sani wrote: If you are sure that your project is always going to be web service only I would suggest start with a framework dedicated for such task. eg: Slim http://www.slimframework.com/ Both CakePHP and ZendFW will be an overkill HTH Tarique On Wed, Aug 1, 2012 at 6:55 AM, Lightee lightai...@gmail.com wrote: Dear CakePHP gurus, I have no intention to start an emotional thread about which framework is better. Asking this question on this forum is also rather stupid because members here are likely to be biased. Nevertheless, I hope to get objective replies. I would like to build a website that focuses on web services - particularly CRUD, search and query functions. From what I read on the net, Zend Framework supporters say that Zend has much more components than CakePHP to support web services. On the other hand, my understanding of CakePHP is that Zend Framework components can be imported into CakePHP vendors folder. If that is the case, wouldn't it be a no-brainer to use CakePHP? In that regard, I have a few questions ... - How easy is it to import Zend components into CakePHP? Do we need to modify the Zend components such that they follow certain naming conventions? - Can most Zend components or only selected ones be imported? How about the ones that deal with web services? Thank you for your help. -- 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 -- = PHP for E-Biz: http://sanisoft.com = -- 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 -- = PHP for E-Biz: http://sanisoft.com = -- 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: hide model fields from controller
@*euromarks** ** *@Crazy* *thanks @euromarks it is not a trust issue it is matter of good programming practice that is what encapsulation originally made for (correct me if i am wrong) -- 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
Number Problem in V1.3
Hi, $this-Number-addFormat('EUR', array('after' = ' €', 'decimals' = ',', 'thousands' = '.', 'negative' = '-')); $this-Number-currency($value, 'EUR'); When I return money amounts, saved in DB as decimal(10,2) it returns the following 25.00 = 25€ correct 0.33 = 33 € not correct!! What is wrong in my syntax above? How do I get the right format? Thanks for help!! -- 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 images stored in database
Hi abiram. I want to store and retrieve image in database but i cant bcoz i am new to cakephp. Can you help me.I am doing like this: To upload an image i m doing this ?php echo $this-Form-create('Movie'); echo $this-Form-inputs(array('title', 'genre', 'rating', 'format', 'length')); echo $this-Form-input('file', array('type' = 'file')); echo $this-Form-end('Add'); ? and to show image i m doing like this: ?php echo $this-Html-image($movie['Movie']['image']); ? Am i doing in right way. On Tuesday, February 12, 2008 3:46:12 PM UTC+5:30, abiram wrote: Hai i got answer it is images stored in database lke varchar and retrive time this is like ?php $html-image() ? On Feb 11, 2:39 pm, abiram hari.k...@gmail.com wrote: Hi all i want store images in database actually images stored in webroot img folder in database image path is entering it means only img names or overall path and how to retrive viewpage like ?php $product['products']['img] ? and what path is save in database pls send answ -- 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
ControllerTestCase::testAction() causes Error: [MissingControllerException] Controller class WebrootController could not be found
Hi I am trying to learn how to run unit tests in my cake 2.2 app but recieve the following error in error.log when attempting to run$this-testAction('/controller/action');in my test class: 2012-08-01 14:29:24 Error: [MissingControllerException] Controller class WebrootController could not be found. #0 /var/www/htdocs/app/webroot/index.php(111): Dispatcher-dispatch(Object(CakeRequest), Object(CakeResponse)) #1 {main} I don't recieve this error at any other time and am now kind of stuck. It may be worth noting that my cakephp core resides in a seperate directory and I have changed the value of the CAKE_CORE_INCLUDE_PATH constant in my webroot/index.php to match. Does anyone have any ideas of what could be causing this? Thanks Adrian -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Problem with ordering by a calculated field
hi daniel i have the same probleme like you and i want to help me. my english is not good. well i develop a backEnd that receive the request of the client (lat lng) and it's calculate the distance from the client to the hotels how can i calculate the distance i calculated field and sort it thanks -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Auth sessions not working in firefox or ie7
Im having the same problem with cakePHP2+ . Please let me know if you have found a solution. -- 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
Problem With console plugin
Hi I'm get trouble to bake a plugin with cakephp 2.x , I'm searching days a solution and didn't find any answer I'm working with ubuntu and I install cake in the directory/usr/share/php/cake/ and my website directory is /home/hugo/www/miko/ I try to bake a model in my plugin Miko with this commande: hugo@hugo-Presario-C700-Notebook-PC:~/www/miko/app$ cake bake plugin Miko Welcome to CakePHP v2.1.4 Console --- App : app Path: /home/hugo/www/miko/app/ --- 1. /home/hugo/www/miko/app/Plugin/ 2. /usr/share/php/cake/plugins/ Choose a plugin path from the paths above. 1 --- Plugin Name: Miko Plugin Directory: /home/hugo/www/miko/app/Plugin/Miko --- Look okay? (y/n/q) [y] y cake bake model --plugin Miko and it show me *wrong *directory Welcome to CakePHP v2.1.4 Console --- App : app Path: /home/hugo/www/miko/app/ --- --- Bake Model Path: /usr/share/php/cake/plugins/Miko/Model/ --- Use Database Config: (default/test) Is Anyone know where is my mistake? -- 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
Getting DB error on calling Model
I'm using Cake 2.0, and getting a database error when I call a particular model. I think I've probably named something wrongly, but I can't see what! I have the following: *DB table:* confcommittees *Model/Confcommittee.php:* class Confcommittee extends AppModel { public $name = 'Confcommittee'; var $belongsTo = array('Conference'); public function myFunction() { return false; } } *Controller/ConferencesController.php:* App::uses('AppController', 'Controller'); class ConferencesController extends AppController { public $name = 'Conferences'; public $helpers = array('Html', 'Session'); public $uses = array('Conference', 'Confcommittee'); /* Filters and callbacks */ function beforeFilter() { parent::beforeFilter(); } /* * admin_manage * Allows the admin user to manage any given conference */ function admin_manage($conference_id = null) { if(!$conference_id) { $this-redirect('/admin/conferences/main'); exit; } $this-Confcommittee-myFunction(); } } When I access admin/conferences/manage, I get the following error: Database Error *Error: *SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'myFunction' at line 1 *SQL Query: *myFunction *Notice: *If you want to customize this error message, create app\View\Errors\pdo_error.ctp Stack Trace - CORE\Cake\Model\Datasource\DboSource.php line 437http://localhost/IAAD_New/admin/conferences/manage/1# → PDOStatement-execute(array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Model\Datasource\DboSource.php line 403http://localhost/IAAD_New/admin/conferences/manage/1# → DboSource-_execute(string, array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Model\Datasource\DboSource.php line 647http://localhost/IAAD_New/admin/conferences/manage/1# → DboSource-execute(string, array, array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Model\Datasource\DboSource.php line 589http://localhost/IAAD_New/admin/conferences/manage/1# → DboSource-fetchAll(string, array, array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Model\Model.php line 775http://localhost/IAAD_New/admin/conferences/manage/1# → DboSource-query(string, array, AppModel)http://localhost/IAAD_New/admin/conferences/manage/1# - APP\Controller\ConferencesController.php line 96http://localhost/IAAD_New/admin/conferences/manage/1# → Model-__call(string, array)http://localhost/IAAD_New/admin/conferences/manage/1# - APP\Controller\ConferencesController.php line 96http://localhost/IAAD_New/admin/conferences/manage/1# → AppModel-myFunction()http://localhost/IAAD_New/admin/conferences/manage/1# - [internal function]http://localhost/IAAD_New/admin/conferences/manage/1# → ConferencesController-admin_manage(string)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Controller\Controller.php line 485http://localhost/IAAD_New/admin/conferences/manage/1# → ReflectionMethod-invokeArgs(ConferencesController, array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Routing\Dispatcher.php line 103http://localhost/IAAD_New/admin/conferences/manage/1# → Controller-invokeAction(CakeRequest)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Routing\Dispatcher.php line 85http://localhost/IAAD_New/admin/conferences/manage/1# → Dispatcher-_invoke(ConferencesController, CakeRequest, CakeResponse) http://localhost/IAAD_New/admin/conferences/manage/1# - APP\webroot\index.php line 92http://localhost/IAAD_New/admin/conferences/manage/1# → Dispatcher-dispatch(CakeRequest, CakeResponse)http://localhost/IAAD_New/admin/conferences/manage/1# As I said, I think I've given something the wrong name, but I can't find it. Can anyone help?! -- 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: [Models] saveAll doesn't work
Did you look at the clear-as-day MySQL error you were given? SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column body violates not-null constraint You are entering in a null value into the body column which does not allow null values. So either change the table so that body DOES accept null values, or ensure that the data you're saving has a non-null body value. On Tuesday, July 31, 2012 3:12:03 AM UTC-7, TWEESTY wrote: Up. Thanks ! -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Selecting hasMany fields
Use a join. I don't know which page in the manual to link to so search online for cakephp find join. On Tue, Jul 31, 2012 at 8:01 PM, lirc201 brian.e.lave...@gmail.com wrote: I have an Order that hasMany LineItems. I only want to extract an Order if certain LineItems.fields meet my conditions. I'm using $this-Order-find('list', array( 'conditions' = array('LineItem.event_id' = '3', 'LineItem.pulled' = '1'), //'order' = array(Order.id = 'asc'), 'recursive' = '2' )); However all I get is ALL Orders. Any ideas, thanks Brian -- 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: Use of requestaction
Those are very different things. What do you want to do exactly? On Wed, Aug 1, 2012 at 3:43 AM, Bharat Maheshwari bharat.maheshw...@logicspice.com wrote: I just want to know that the use of requestaction in a view file is good for coding or using Class::Rergistry is better then requestaction ? -- 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: Concurrent login issue: Users being logged out
Are you certain that more than one user is required to trigger this? Could it be that your sessions, in general, are timing out too soon? Or maybe these other people's computer setups don't play well with cookies? Log in from a computer that has shown this problem before and browse around until you're satisfied that the session problem is not occurring. Log out, then log in from another computer -- also one from which the problem has been seen -- and do the same. If still no trouble appears, try logging in from both at the same time. If that gets you nowhere, try setting your DB to log everything. Maybe that will provide a clue. On Wed, Aug 1, 2012 at 5:04 AM, phpMagpie p...@webbedit.co.uk wrote: Anybody? I can't be the only one who has noticed this problem, I don't believe it is as a result of any strange configuration I have in place as I do not stray far from the norm. Any help would be appreciated. On Wednesday, July 25, 2012 8:58:14 AM UTC+1, phpMagpie wrote: Morning, I am having problems when more than one person is logged in where sessions are timing out for no reason. This does not have to be two people using the same account, simply having two authorised users looking through the site (typically when I am demoing the site to a client or when multiple people testing the site at once) you have to keep logging back in, which is annoying. I am using Auth with Database Sessions and Security.level is set to medium, any pointers as to where I should be looking to resolve this? Thanks, Paul. -- 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: Getting DB error on calling Model
This is the only thing I can see that looks odd: Controller/ConferencesController.php: App::uses('AppController', 'Controller'); class ConferencesController extends AppController { However, adding it to one of my own controllers doesn't seem to do any harm, so maybe that's not the problem. The App::uses line is only (sometimes) necessary in AppController, in which case it looks like this: App::uses('Controller', 'Controller'); class AppController extends Controller I say sometimes because I vaguely remember there is some issue which adding that to AppController resolves, but it's not generally necessary. -- 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: Database sessions garbage collection issue
By default there is 1% chance for gc to be called by PHP. If you want to test if gc() is fired, increase *session.gc_probability *close to *divisor*: http://www.php.net/manual/en/session.configuration.php#ini.session.gc-probability Then watch SQL log for that query. Anyway, expires should be current timestamp + Session.timeout config I know, PHP and sessions - nothing but sorcery :D On Wednesday, August 1, 2012 9:12:13 AM UTC+2, Crazy wrote: I'm having some issues with my sessions. It's probably configuration somewhere, but don't know what to change/where to look. I'm using database sessions for my cake application, these sessions are not getting cleaned up. The app in question I have the issue on is an old one written on 1.3.10 running with php version 5.3.5. The garbage collection function in the 2.x branch is the same so don't think the framework version will matter. I've tracked down the issue to the function __gc located in the CakeSession class and that function is registered there in the php session_set_save_handler function, this is the function in question: /** * Helper function called on gc for database sessions. * * @param integer $expires Timestamp (defaults to current time) * @return boolean Success * @access private */function __gc($expires = null) { $model = ClassRegistry::getObject('Session'); if (!$expires) { $expires = time(); } $return = $model-deleteAll(array($model-alias . .expires = $expires), false, false); return $return; } Now, the comments say that $expires is a timestamp, but this isn't correct according to the php docs: gc($lifetime) The garbage collector callback is invoked internally by PHP periodically in order to purge old session data. The frequency is controlled by session.gc_probability and session.gc_divisor. The value of lifetime which is passed to this callback can be set in session.gc_maxlifetime. Return value should be TRUE for success, FALSE for failure. The value for $lifeime, so gc_maxlifetime in php.ini is the following: ; After this number of seconds, stored data will be seen as 'garbage' and ; cleaned up by the garbage collection process.session.gc_maxlifetime = 3600 So this results in a query that never deletes anything: delete from cake_sessions where expires 3600; Could someone clarify what I'm doing wrong or if this is an issue in cake itself? I've posted this on ask.cakephp.org as well, when I find the answer I'll make sure to update both locations. http://ask.cakephp.org/questions/view/database_sessions_garbage_collection_issue -- 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: Concurrent login issue: Users being logged out
I know this is a multiple user issue as when using the site normally sessions NEVER timeout unexpectedly, whereas you can be filling in a multistage form with two people in the site at once and the session times out from one step to the next. This has happened with multiple client sites that I develop for an agency and when logged in alone me and the agency can use the sites without issue, as soon as more than one person tries to be in the site at same time .. The sessions start expiring unexpectedly. This is not an issue related to a particular computer config. I have also had my other agency client complaining of the same issue when trying to demo a site I have developed for him to his client. What info should I see in the logs about this? What do you mean by set the DB to log everything. No logs are saved into the DB? Sent from my iPad On 1 Aug 2012, at 19:08, lowpass zijn.digi...@gmail.com wrote: Are you certain that more than one user is required to trigger this? Could it be that your sessions, in general, are timing out too soon? Or maybe these other people's computer setups don't play well with cookies? Log in from a computer that has shown this problem before and browse around until you're satisfied that the session problem is not occurring. Log out, then log in from another computer -- also one from which the problem has been seen -- and do the same. If still no trouble appears, try logging in from both at the same time. If that gets you nowhere, try setting your DB to log everything. Maybe that will provide a clue. On Wed, Aug 1, 2012 at 5:04 AM, phpMagpie p...@webbedit.co.uk wrote: Anybody? I can't be the only one who has noticed this problem, I don't believe it is as a result of any strange configuration I have in place as I do not stray far from the norm. Any help would be appreciated. On Wednesday, July 25, 2012 8:58:14 AM UTC+1, phpMagpie wrote: Morning, I am having problems when more than one person is logged in where sessions are timing out for no reason. This does not have to be two people using the same account, simply having two authorised users looking through the site (typically when I am demoing the site to a client or when multiple people testing the site at once) you have to keep logging back in, which is annoying. I am using Auth with Database Sessions and Security.level is set to medium, any pointers as to where I should be looking to resolve this? Thanks, Paul. -- 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: find with complex conditions (AND and OR)
Thanks for your response. Unfortunately, that did not work. I'm still only getting the last element of the OR array. FWIW: Cake 1.3.10 SELECT DISTINCT(`Equipment`.`product_id`) AS id, `Product`.`name`, `Product`.`id` FROM `equipment` AS `Equipment` LEFT JOIN `products` AS `Product` ON (`Equipment`.`product_id` = `Product`.`id`) WHERE ((`Equipment`.`company_id` = 23) AND (`Equipment`.`deleted` = 0) AND (`Equipment`.`location_id` = -2)) GROUP BY `Equipment`.`product_id` ORDER BY `Product`.`name` ASC Any other help? On Tuesday, July 31, 2012 4:09:16 PM UTC-4, lavin wrote: Try something like this: $params = array('contain' = 'Product.name', 'fields' = array('DISTINCT(Equipment.product_id) AS id', 'Product.name'), 'order' = array('Product.name'), 'group' = array('Equipment.product_id'), 'conditions' = array( 'AND' = array( 'Equipment.company_id' = $this-passedArgs['company'], 'Equipment.deleted' = 0, 'OR' = array( 'Equipment.location_id' = null, 'Equipment.location_id' = -1, 'Equipment.location_id' = -2 ) ) )); Allowing the OR subset to be one of the elements considered inside the AND 2012/7/31 scs: I'm trying to perform what has been called a complex condition in some of the documentation I have found. I want to use AND and OR in the conditions portion of my query via find('all', $params). I haven't been able to find anything that seems to match my issue (although I'm sure it's out there). I'm not sure what to do. I've tried many different variations of the conditions array, none seem to work. At best, the query is built with only 1 of the OR items, always the last one in the array. Here's the information: $params = array('contain' = 'Product.name', 'fields' = array('DISTINCT(Equipment.product_id) AS id', 'Product.name'), 'order' = array('Product.name'), 'group' = array('Equipment.product_id'), 'conditions' = array('AND' = array('Equipment.company_id' = $this-passedArgs['company'], 'Equipment.deleted' = 0,), 'OR' = array('Equipment.location_id' = null, 'Equipment.location_id' = -1, 'Equipment.location_id' = -2)) ); $equipList = $this-Equipment-find('all', $params); The sql debugged is: SELECT DISTINCT(`Equipment`.`product_id`) AS id, `Product`.`name`, `Product`.`id` FROM `equipment` AS `Equipment` LEFT JOIN `products` AS `Product` ON (`Equipment`.`product_id` = `Product`.`id`) WHERE ((`Equipment`.`company_id` = 23) AND (`Equipment`.`deleted` = 0)) AND `Equipment`.`location_id` = -2 GROUP BY `Equipment`.`product_id` ORDER BY `Product`.`name` ASC What I am looking for is: SELECT DISTINCT(`Equipment`.`product_id`) AS id, `Product`.`name`, `Product`.`id` FROM `equipment` AS `Equipment` LEFT JOIN `products` AS `Product` ON (`Equipment`.`product_id` = `Product`.`id`) WHERE ((`Equipment`.`company_id` = 23) AND (`Equipment`.`deleted` = 0)) AND (`Equipment`.`location_id` IS NULL OR `Equipment`.`location_id` = -1 OR `Equipment`.`location_id` = -2) GROUP BY `Equipment`.`product_id` ORDER BY `Product`.`name` ASC Any and all help is greatly appreciated. Thanks. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- -Carlos -- 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: Getting DB error on calling Model
Model Confcommittee is not found, so Cake creates an instance of AppModel. You are using $uses property, so try to add in Model/Confcommittee.php: App::uses('Confcommittee ', 'Model'); class Confcommittee extends AppModel { ... Btw, you don't need to call exit() after redirect() in that controller. On Wednesday, August 1, 2012 5:44:18 PM UTC+2, WhyNotSmile wrote: I'm using Cake 2.0, and getting a database error when I call a particular model. I think I've probably named something wrongly, but I can't see what! I have the following: *DB table:* confcommittees *Model/Confcommittee.php:* class Confcommittee extends AppModel { public $name = 'Confcommittee'; var $belongsTo = array('Conference'); public function myFunction() { return false; } } *Controller/ConferencesController.php:* App::uses('AppController', 'Controller'); class ConferencesController extends AppController { public $name = 'Conferences'; public $helpers = array('Html', 'Session'); public $uses = array('Conference', 'Confcommittee'); /* Filters and callbacks */ function beforeFilter() { parent::beforeFilter(); } /* * admin_manage * Allows the admin user to manage any given conference */ function admin_manage($conference_id = null) { if(!$conference_id) { $this-redirect('/admin/conferences/main'); exit; } $this-Confcommittee-myFunction(); } } When I access admin/conferences/manage, I get the following error: Database Error *Error: *SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'myFunction' at line 1 *SQL Query: *myFunction *Notice: *If you want to customize this error message, create app\View\Errors\pdo_error.ctp Stack Trace - CORE\Cake\Model\Datasource\DboSource.php line 437http://localhost/IAAD_New/admin/conferences/manage/1# → PDOStatement-execute(array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Model\Datasource\DboSource.php line 403http://localhost/IAAD_New/admin/conferences/manage/1# → DboSource-_execute(string, array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Model\Datasource\DboSource.php line 647http://localhost/IAAD_New/admin/conferences/manage/1# → DboSource-execute(string, array, array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Model\Datasource\DboSource.php line 589http://localhost/IAAD_New/admin/conferences/manage/1# → DboSource-fetchAll(string, array, array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Model\Model.php line 775http://localhost/IAAD_New/admin/conferences/manage/1# → DboSource-query(string, array, AppModel)http://localhost/IAAD_New/admin/conferences/manage/1# - APP\Controller\ConferencesController.php line 96http://localhost/IAAD_New/admin/conferences/manage/1# → Model-__call(string, array)http://localhost/IAAD_New/admin/conferences/manage/1# - APP\Controller\ConferencesController.php line 96http://localhost/IAAD_New/admin/conferences/manage/1# → AppModel-myFunction()http://localhost/IAAD_New/admin/conferences/manage/1# - [internal function]http://localhost/IAAD_New/admin/conferences/manage/1# → ConferencesController-admin_manage(string)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Controller\Controller.php line 485http://localhost/IAAD_New/admin/conferences/manage/1# → ReflectionMethod-invokeArgs(ConferencesController, array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Routing\Dispatcher.php line 103http://localhost/IAAD_New/admin/conferences/manage/1# → Controller-invokeAction(CakeRequest)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Routing\Dispatcher.php line 85http://localhost/IAAD_New/admin/conferences/manage/1# → Dispatcher-_invoke(ConferencesController, CakeRequest, CakeResponse) http://localhost/IAAD_New/admin/conferences/manage/1# - APP\webroot\index.php line 92http://localhost/IAAD_New/admin/conferences/manage/1# → Dispatcher-dispatch(CakeRequest, CakeResponse)http://localhost/IAAD_New/admin/conferences/manage/1# As I said, I think I've given something the wrong name, but I can't find it. Can anyone help?! -- 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: [Models] saveAll doesn't work
Hi! I know it, but my field body is not null! Here my array : Array ( [Topic] = Array ( [subject] = ZEZEEZ [user_id] = 3 ) [Message] = Array ( * [body] = QSDDD * [user_id] = 3 ) [Belong] = Array ( [user_id] = 3 ) ) Thanks Le mercredi 1 août 2012 18:39:01 UTC+2, Jamie a écrit : Did you look at the clear-as-day MySQL error you were given? SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column body violates not-null constraint You are entering in a null value into the body column which does not allow null values. So either change the table so that body DOES accept null values, or ensure that the data you're saving has a non-null body value. On Tuesday, July 31, 2012 3:12:03 AM UTC-7, TWEESTY wrote: Up. Thanks ! -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Problem With console plugin
Try cake bake model Miko.MyModelName You can always run cake bake model to see the list of available models (tables) On Wednesday, August 1, 2012 8:50:37 AM UTC+2, Hugues Mary wrote: Hi I'm get trouble to bake a plugin with cakephp 2.x , I'm searching days a solution and didn't find any answer I'm working with ubuntu and I install cake in the directory/usr/share/php/cake/ and my website directory is /home/hugo/www/miko/ I try to bake a model in my plugin Miko with this commande: hugo@hugo-Presario-C700-Notebook-PC:~/www/miko/app$ cake bake plugin Miko Welcome to CakePHP v2.1.4 Console --- App : app Path: /home/hugo/www/miko/app/ --- 1. /home/hugo/www/miko/app/Plugin/ 2. /usr/share/php/cake/plugins/ Choose a plugin path from the paths above. 1 --- Plugin Name: Miko Plugin Directory: /home/hugo/www/miko/app/Plugin/Miko --- Look okay? (y/n/q) [y] y cake bake model --plugin Miko and it show me *wrong *directory Welcome to CakePHP v2.1.4 Console --- App : app Path: /home/hugo/www/miko/app/ --- --- Bake Model Path: /usr/share/php/cake/plugins/Miko/Model/ --- Use Database Config: (default/test) Is Anyone know where is my mistake? -- 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: find with complex conditions (AND and OR)
How about: $params = array('contain' = 'Product.name', 'fields' = array('DISTINCT(Equipment.**product_id) AS id', 'Product.name'), 'order' = array('Product.name'), 'group' = array('Equipment.product_id'), 'conditions' = array( 'AND' = array( ** 'Equipment.company_id' = $this-passedArgs['company'], ** 'Equipment.deleted' = 0, ** 'OR' = array( ** array('Equipment.location_**id' = null), ** array('Equipment.location_**id' = -1 ), ** array('Equipment.location_**id' = -2) ** ) ) )); According to an example in http://book.cakephp.org/1.3/view/1030/Complex-Find-Conditions that sets multiple conditions on the same field inside an OR: array( 'OR' = array( array('Post.title LIKE' = '%one%'), array('Post.title LIKE' = '%two%') ) ); 2012/8/1 scs jsfin...@gmail.com Thanks for your response. Unfortunately, that did not work. I'm still only getting the last element of the OR array. FWIW: Cake 1.3.10 SELECT DISTINCT(`Equipment`.`product_id`) AS id, `Product`.`name`, `Product`.`id` FROM `equipment` AS `Equipment` LEFT JOIN `products` AS `Product` ON (`Equipment`.`product_id` = `Product`.`id`) WHERE ((`Equipment`.`company_id` = 23) AND (`Equipment`.`deleted` = 0) AND (`Equipment`.`location_id` = -2)) GROUP BY `Equipment`.`product_id` ORDER BY `Product`.`name` ASC Any other help? On Tuesday, July 31, 2012 4:09:16 PM UTC-4, lavin wrote: Try something like this: $params = array('contain' = 'Product.name', 'fields' = array('DISTINCT(Equipment.**product_id) AS id', 'Product.name'), 'order' = array('Product.name'), 'group' = array('Equipment.product_id'), 'conditions' = array( 'AND' = array( ** 'Equipment.company_id' = $this-passedArgs['company'], ** 'Equipment.deleted' = 0, ** 'OR' = array( ** 'Equipment.location_**id' = null, ** 'Equipment.location_**id' = -1, ** 'Equipment.location_**id' = -2 ** ) ) )); Allowing the OR subset to be one of the elements considered inside the AND 2012/7/31 scs: I'm trying to perform what has been called a complex condition in some of the documentation I have found. I want to use AND and OR in the conditions portion of my query via find('all', $params). I haven't been able to find anything that seems to match my issue (although I'm sure it's out there). I'm not sure what to do. I've tried many different variations of the conditions array, none seem to work. At best, the query is built with only 1 of the OR items, always the last one in the array. Here's the information: $params = array('contain' = 'Product.name', 'fields' = array('DISTINCT(Equipment.**product_id) AS id', 'Product.name'), 'order' = array('Product.name'), 'group' = array('Equipment.product_id'), 'conditions' = array('AND' = array('Equipment.company_id' = $this-passedArgs['company'], 'Equipment.deleted' = 0,), 'OR' = array('Equipment.location_id' = null, 'Equipment.location_id' = -1, 'Equipment.location_id' = -2)) ); $equipList = $this-Equipment-find('all', $params); The sql debugged is: SELECT DISTINCT(`Equipment`.`product_**id`) AS id, `Product`.`name`, `Product`.`id` FROM `equipment` AS `Equipment` LEFT JOIN `products` AS `Product` ON (`Equipment`.`product_id` = `Product`.`id`) WHERE ((`Equipment`.`company_id` = 23) AND (`Equipment`.`deleted` = 0)) AND `Equipment`.`location_id` = -2 GROUP BY `Equipment`.`product_id` ORDER BY `Product`.`name` ASC What I am looking for is: SELECT DISTINCT(`Equipment`.`product_**id`) AS id, `Product`.`name`, `Product`.`id` FROM `equipment` AS `Equipment` LEFT JOIN `products` AS `Product` ON (`Equipment`.`product_id` = `Product`.`id`) WHERE ((`Equipment`.`company_id` = 23) AND (`Equipment`.`deleted` = 0)) AND (`Equipment`.`location_id` IS NULL OR `Equipment`.`location_id` = -1 OR `Equipment`.`location_id` = -2) GROUP BY `Equipment`.`product_id` ORDER BY `Product`.`name` ASC Any and all help is greatly appreciated. Thanks. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their
Re: Linking Models Together
Gah - I'm a numpty. Kept putting the foreignKey as the column on the table I'm joining to. As for books/authors - I took the simple approach and gave each book one author. If a book is written by John Smith and Bob Jones, then there is a row in the author table John Smith Bob Jones. Makes the design easier, but it does mean if I want to find all the books by Bob Jones then I need to search for %Bob Jones%'. But I may change that design anyway, but at least I can now do all the other foreignKey look ups. Thanks, N. On Wednesday, August 1, 2012 12:10:17 AM UTC+1, Daniel Baird wrote: http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#belongsto ...is where belongsTo is documented, you should look over that. But -- even though I hate to be that jerk who points out problems other than the one you asked about -- before you get too far, the data model you describe only lets a book have a single author. If you're storing actual real-world books in there, you probably want to support books having multiple authors, which means a HABTM hasAndBelongsToMany association. For that you need a third table authors_books, etc as described in the cookbook. Good luck ;Daniel -- Daniel Baird I've tried going to the XHTML bar / a few times, but it's always closed. -- 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: Getting DB error on calling Model
Thanks for the help, but it hasn't made any difference. I'm totally baffled, because I've used the same code in other places with different model names, and it seems fine... I must have just missed something on copying it. On Wednesday, 1 August 2012 20:58:42 UTC+1, majna wrote: Model Confcommittee is not found, so Cake creates an instance of AppModel. You are using $uses property, so try to add in Model/Confcommittee.php: App::uses('Confcommittee ', 'Model'); class Confcommittee extends AppModel { ... Btw, you don't need to call exit() after redirect() in that controller. On Wednesday, August 1, 2012 5:44:18 PM UTC+2, WhyNotSmile wrote: I'm using Cake 2.0, and getting a database error when I call a particular model. I think I've probably named something wrongly, but I can't see what! I have the following: *DB table:* confcommittees *Model/Confcommittee.php:* class Confcommittee extends AppModel { public $name = 'Confcommittee'; var $belongsTo = array('Conference'); public function myFunction() { return false; } } *Controller/ConferencesController.php:* App::uses('AppController', 'Controller'); class ConferencesController extends AppController { public $name = 'Conferences'; public $helpers = array('Html', 'Session'); public $uses = array('Conference', 'Confcommittee'); /* Filters and callbacks */ function beforeFilter() { parent::beforeFilter(); } /* * admin_manage * Allows the admin user to manage any given conference */ function admin_manage($conference_id = null) { if(!$conference_id) { $this-redirect('/admin/conferences/main'); exit; } $this-Confcommittee-myFunction(); } } When I access admin/conferences/manage, I get the following error: Database Error *Error: *SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'myFunction' at line 1 *SQL Query: *myFunction *Notice: *If you want to customize this error message, create app\View\Errors\pdo_error.ctp Stack Trace - CORE\Cake\Model\Datasource\DboSource.php line 437http://localhost/IAAD_New/admin/conferences/manage/1# → PDOStatement-execute(array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Model\Datasource\DboSource.php line 403http://localhost/IAAD_New/admin/conferences/manage/1# → DboSource-_execute(string, array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Model\Datasource\DboSource.php line 647http://localhost/IAAD_New/admin/conferences/manage/1# → DboSource-execute(string, array, array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Model\Datasource\DboSource.php line 589http://localhost/IAAD_New/admin/conferences/manage/1# → DboSource-fetchAll(string, array, array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Model\Model.php line 775http://localhost/IAAD_New/admin/conferences/manage/1# → DboSource-query(string, array, AppModel)http://localhost/IAAD_New/admin/conferences/manage/1# - APP\Controller\ConferencesController.php line 96http://localhost/IAAD_New/admin/conferences/manage/1# → Model-__call(string, array)http://localhost/IAAD_New/admin/conferences/manage/1# - APP\Controller\ConferencesController.php line 96http://localhost/IAAD_New/admin/conferences/manage/1# → AppModel-myFunction()http://localhost/IAAD_New/admin/conferences/manage/1# - [internal function]http://localhost/IAAD_New/admin/conferences/manage/1# → ConferencesController-admin_manage(string)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Controller\Controller.php line 485http://localhost/IAAD_New/admin/conferences/manage/1# → ReflectionMethod-invokeArgs(ConferencesController, array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Routing\Dispatcher.php line 103http://localhost/IAAD_New/admin/conferences/manage/1# → Controller-invokeAction(CakeRequest)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Routing\Dispatcher.php line 85http://localhost/IAAD_New/admin/conferences/manage/1# → Dispatcher-_invoke(ConferencesController, CakeRequest, CakeResponse) http://localhost/IAAD_New/admin/conferences/manage/1# - APP\webroot\index.php line 92http://localhost/IAAD_New/admin/conferences/manage/1# → Dispatcher-dispatch(CakeRequest, CakeResponse)http://localhost/IAAD_New/admin/conferences/manage/1# As I said, I think I've given something the wrong name, but I can't find it. Can anyone help?! -- 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
Building a CakePHP app with Parse.com - anyone done it?
A client has asked me about using Parse.com for a site. I already have a version of the site in CakePHP 2.0, but he reckons that in the future they'll want a mobile app, and the mobile developers said that they find it much easier to build if they use Parse.com. Therefore, he asked me about porting the site over to Parse.com. From a quick read of the Parse.com docs, it looks like it would basically replace the MySQL database, and instead the site would need to use REST queries to get the data from Parse. I've done a little bit of REST stuff before, but it's almost always been by copying and pasting from the relevant documentation, so it's not something I fully have a grasp of. Anyway, I wondered whether anyone else has built a Cake app on this platform, and if so, what's it like to work with? Thanks! -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Getting DB error on calling Model
Is this code inside a plugin? 2012/8/1 WhyNotSmile sharongilmor...@gmail.com Thanks for the help, but it hasn't made any difference. I'm totally baffled, because I've used the same code in other places with different model names, and it seems fine... I must have just missed something on copying it. On Wednesday, 1 August 2012 20:58:42 UTC+1, majna wrote: Model Confcommittee is not found, so Cake creates an instance of AppModel. You are using $uses property, so try to add in Model/Confcommittee.php: App::uses('Confcommittee ', 'Model'); class Confcommittee extends AppModel { ... Btw, you don't need to call exit() after redirect() in that controller. On Wednesday, August 1, 2012 5:44:18 PM UTC+2, WhyNotSmile wrote: I'm using Cake 2.0, and getting a database error when I call a particular model. I think I've probably named something wrongly, but I can't see what! I have the following: *DB table:* confcommittees *Model/Confcommittee.php:* class Confcommittee extends AppModel { public $name = 'Confcommittee'; var $belongsTo = array('Conference'); public function myFunction() { return false; } } *Controller/ConferencesController.php:* App::uses('AppController', 'Controller'); class ConferencesController extends AppController { public $name = 'Conferences'; public $helpers = array('Html', 'Session'); public $uses = array('Conference', 'Confcommittee'); /* Filters and callbacks */ function beforeFilter() { parent::beforeFilter(); } /* * admin_manage * Allows the admin user to manage any given conference */ function admin_manage($conference_id = null) { if(!$conference_id) { $this-redirect('/admin/**conferences/main'); exit; } $this-Confcommittee-**myFunction(); } } When I access admin/conferences/manage, I get the following error: Database Error *Error: *SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'myFunction' at line 1 *SQL Query: *myFunction *Notice: *If you want to customize this error message, create app\View\Errors\pdo_error.ctp Stack Trace - CORE\Cake\Model\Datasource\**DboSource.php line 437http://localhost/IAAD_New/admin/conferences/manage/1# → PDOStatement-execute(**array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Model\Datasource\**DboSource.php line 403http://localhost/IAAD_New/admin/conferences/manage/1# → DboSource-_execute(string, array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Model\Datasource\**DboSource.php line 647http://localhost/IAAD_New/admin/conferences/manage/1# → DboSource-execute(string, array, array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Model\Datasource\**DboSource.php line 589http://localhost/IAAD_New/admin/conferences/manage/1# → DboSource-fetchAll(string, array, array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Model\Model.php line 775http://localhost/IAAD_New/admin/conferences/manage/1# → DboSource-query(string, array, AppModel)http://localhost/IAAD_New/admin/conferences/manage/1# - APP\Controller\**ConferencesController.php line 96http://localhost/IAAD_New/admin/conferences/manage/1# → Model-__call(string, array)http://localhost/IAAD_New/admin/conferences/manage/1# - APP\Controller\**ConferencesController.php line 96http://localhost/IAAD_New/admin/conferences/manage/1# → AppModel-myFunction()http://localhost/IAAD_New/admin/conferences/manage/1# - [internal function]http://localhost/IAAD_New/admin/conferences/manage/1# → ConferencesController-**admin_manage(string)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Controller\**Controller.php line 485http://localhost/IAAD_New/admin/conferences/manage/1# → ReflectionMethod-**invokeArgs(**ConferencesController, array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Routing\Dispatcher.**php line 103http://localhost/IAAD_New/admin/conferences/manage/1# → Controller-invokeAction(**CakeRequest)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Routing\Dispatcher.**php line 85http://localhost/IAAD_New/admin/conferences/manage/1# → Dispatcher-_invoke(**ConferencesController, CakeRequest, CakeResponse)http://localhost/IAAD_New/admin/conferences/manage/1# - APP\webroot\index.php line 92http://localhost/IAAD_New/admin/conferences/manage/1# → Dispatcher-dispatch(**CakeRequest, CakeResponse)http://localhost/IAAD_New/admin/conferences/manage/1# As I said, I think I've given something the wrong name, but I can't find it. Can anyone help?! -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions
Re: Getting DB error on calling Model
If it's not the plugin issue, then Conference model is associated with Confcommittee with wrong 'class' name. You can test that if you change order in $uses: public $uses = array('Confcommittee', 'Conference'); On Wednesday, August 1, 2012 10:35:12 PM UTC+2, majna wrote: Is this code inside a plugin? 2012/8/1 WhyNotSmile sharongilmor...@gmail.com Thanks for the help, but it hasn't made any difference. I'm totally baffled, because I've used the same code in other places with different model names, and it seems fine... I must have just missed something on copying it. On Wednesday, 1 August 2012 20:58:42 UTC+1, majna wrote: Model Confcommittee is not found, so Cake creates an instance of AppModel. You are using $uses property, so try to add in Model/Confcommittee.php: App::uses('Confcommittee ', 'Model'); class Confcommittee extends AppModel { ... Btw, you don't need to call exit() after redirect() in that controller. On Wednesday, August 1, 2012 5:44:18 PM UTC+2, WhyNotSmile wrote: I'm using Cake 2.0, and getting a database error when I call a particular model. I think I've probably named something wrongly, but I can't see what! I have the following: *DB table:* confcommittees *Model/Confcommittee.php:* class Confcommittee extends AppModel { public $name = 'Confcommittee'; var $belongsTo = array('Conference'); public function myFunction() { return false; } } *Controller/ConferencesController.php:* App::uses('AppController', 'Controller'); class ConferencesController extends AppController { public $name = 'Conferences'; public $helpers = array('Html', 'Session'); public $uses = array('Conference', 'Confcommittee'); /* Filters and callbacks */ function beforeFilter() { parent::beforeFilter(); } /* * admin_manage * Allows the admin user to manage any given conference */ function admin_manage($conference_id = null) { if(!$conference_id) { $this-redirect('/admin/**conferences/main'); exit; } $this-Confcommittee-**myFunction(); } } When I access admin/conferences/manage, I get the following error: Database Error *Error: *SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'myFunction' at line 1 *SQL Query: *myFunction *Notice: *If you want to customize this error message, create app\View\Errors\pdo_error.ctp Stack Trace - CORE\Cake\Model\Datasource\**DboSource.php line 437http://localhost/IAAD_New/admin/conferences/manage/1# → PDOStatement-execute(**array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Model\Datasource\**DboSource.php line 403http://localhost/IAAD_New/admin/conferences/manage/1# → DboSource-_execute(string, array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Model\Datasource\**DboSource.php line 647http://localhost/IAAD_New/admin/conferences/manage/1# → DboSource-execute(string, array, array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Model\Datasource\**DboSource.php line 589http://localhost/IAAD_New/admin/conferences/manage/1# → DboSource-fetchAll(string, array, array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Model\Model.php line 775http://localhost/IAAD_New/admin/conferences/manage/1# → DboSource-query(string, array, AppModel)http://localhost/IAAD_New/admin/conferences/manage/1# - APP\Controller\**ConferencesController.php line 96http://localhost/IAAD_New/admin/conferences/manage/1# → Model-__call(string, array)http://localhost/IAAD_New/admin/conferences/manage/1# - APP\Controller\**ConferencesController.php line 96http://localhost/IAAD_New/admin/conferences/manage/1# → AppModel-myFunction()http://localhost/IAAD_New/admin/conferences/manage/1# - [internal function]http://localhost/IAAD_New/admin/conferences/manage/1# → ConferencesController-**admin_manage(string)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Controller\**Controller.php line 485http://localhost/IAAD_New/admin/conferences/manage/1# → ReflectionMethod-**invokeArgs(**ConferencesController, array)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Routing\Dispatcher.**php line 103http://localhost/IAAD_New/admin/conferences/manage/1# → Controller-invokeAction(**CakeRequest)http://localhost/IAAD_New/admin/conferences/manage/1# - CORE\Cake\Routing\Dispatcher.**php line 85http://localhost/IAAD_New/admin/conferences/manage/1# → Dispatcher-_invoke(**ConferencesController, CakeRequest, CakeResponse)http://localhost/IAAD_New/admin/conferences/manage/1# - APP\webroot\index.php line 92http://localhost/IAAD_New/admin/conferences/manage/1# →
Re: Database sessions garbage collection issue
The function is located here: http://api13.cakephp.org/view_source/cake-session/#l-784 The value passed is the one from the php config, session.gc_maxlifetime, so in my case 3600. On Wednesday, August 1, 2012 7:58:09 PM UTC+2, cricket wrote: Where is __gc() called and what value is passed to it? On Wed, Aug 1, 2012 at 3:12 AM, Crazy wrote: I'm having some issues with my sessions. It's probably configuration somewhere, but don't know what to change/where to look. I'm using database sessions for my cake application, these sessions are not getting cleaned up. The app in question I have the issue on is an old one written on 1.3.10 running with php version 5.3.5. The garbage collection function in the 2.x branch is the same so don't think the framework version will matter. I've tracked down the issue to the function __gc located in the CakeSession class and that function is registered there in the php session_set_save_handler function, this is the function in question: /** * Helper function called on gc for database sessions. * * @param integer $expires Timestamp (defaults to current time) * @return boolean Success * @access private */ function __gc($expires = null) { $model = ClassRegistry::getObject('Session'); if (!$expires) { $expires = time(); } $return = $model-deleteAll(array($model-alias . .expires = $expires), false, false); return $return; } Now, the comments say that $expires is a timestamp, but this isn't correct according to the php docs: gc($lifetime) The garbage collector callback is invoked internally by PHP periodically in order to purge old session data. The frequency is controlled by session.gc_probability and session.gc_divisor. The value of lifetime which is passed to this callback can be set in session.gc_maxlifetime. Return value should be TRUE for success, FALSE for failure. The value for $lifeime, so gc_maxlifetime in php.ini is the following: ; After this number of seconds, stored data will be seen as 'garbage' and ; cleaned up by the garbage collection process. session.gc_maxlifetime = 3600 So this results in a query that never deletes anything: delete from cake_sessions where expires 3600; Could someone clarify what I'm doing wrong or if this is an issue in cake itself? I've posted this on ask.cakephp.org as well, when I find the answer I'll make sure to update both locations. http://ask.cakephp.org/questions/view/database_sessions_garbage_collection_issue -- 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: Database sessions garbage collection issue
The function is getting called just fine, that's not the problem. At first I thought it was something with the php settings or cake settings. But the session_save_handlers are pure php, and I have the default settings + nothing cake related is put in between in the gc function. On Wednesday, August 1, 2012 9:32:38 PM UTC+2, majna wrote: By default there is 1% chance for gc to be called by PHP. If you want to test if gc() is fired, increase *session.gc_probability *close to *divisor*: http://www.php.net/manual/en/session.configuration.php#ini.session.gc-probability Then watch SQL log for that query. Anyway, expires should be current timestamp + Session.timeout config I know, PHP and sessions - nothing but sorcery :D On Wednesday, August 1, 2012 9:12:13 AM UTC+2, Crazy wrote: I'm having some issues with my sessions. It's probably configuration somewhere, but don't know what to change/where to look. I'm using database sessions for my cake application, these sessions are not getting cleaned up. The app in question I have the issue on is an old one written on 1.3.10 running with php version 5.3.5. The garbage collection function in the 2.x branch is the same so don't think the framework version will matter. I've tracked down the issue to the function __gc located in the CakeSession class and that function is registered there in the php session_set_save_handler function, this is the function in question: /** * Helper function called on gc for database sessions. * * @param integer $expires Timestamp (defaults to current time) * @return boolean Success * @access private */function __gc($expires = null) { $model = ClassRegistry::getObject('Session'); if (!$expires) { $expires = time(); } $return = $model-deleteAll(array($model-alias . .expires = $expires), false, false); return $return; } Now, the comments say that $expires is a timestamp, but this isn't correct according to the php docs: gc($lifetime) The garbage collector callback is invoked internally by PHP periodically in order to purge old session data. The frequency is controlled by session.gc_probability and session.gc_divisor. The value of lifetime which is passed to this callback can be set in session.gc_maxlifetime. Return value should be TRUE for success, FALSE for failure. The value for $lifeime, so gc_maxlifetime in php.ini is the following: ; After this number of seconds, stored data will be seen as 'garbage' and ; cleaned up by the garbage collection process.session.gc_maxlifetime = 3600 So this results in a query that never deletes anything: delete from cake_sessions where expires 3600; Could someone clarify what I'm doing wrong or if this is an issue in cake itself? I've posted this on ask.cakephp.org as well, when I find the answer I'll make sure to update both locations. http://ask.cakephp.org/questions/view/database_sessions_garbage_collection_issue -- 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: Database sessions garbage collection issue
Oh, It's in 1.3, but yeah, it's kind of a bug It should be time() + $expires as PHP passes gc_maxlifetime to callback so it never deletes old sessions. But Cake fires gc() in __close() method too: http://api13.cakephp.org/view_source/cake-session/#l-709 Try to test by increasing $probability var to 150 2012/8/1 Crazy crazy...@gmail.com The function is getting called just fine, that's not the problem. At first I thought it was something with the php settings or cake settings. But the session_save_handlers are pure php, and I have the default settings + nothing cake related is put in between in the gc function. On Wednesday, August 1, 2012 9:32:38 PM UTC+2, majna wrote: By default there is 1% chance for gc to be called by PHP. If you want to test if gc() is fired, increase *session.gc_probability *close to *divisor*: http://www.php.net/manual/en/**session.configuration.php#ini.** session.gc-probabilityhttp://www.php.net/manual/en/session.configuration.php#ini.session.gc-probability Then watch SQL log for that query. Anyway, expires should be current timestamp + Session.timeout config I know, PHP and sessions - nothing but sorcery :D On Wednesday, August 1, 2012 9:12:13 AM UTC+2, Crazy wrote: I'm having some issues with my sessions. It's probably configuration somewhere, but don't know what to change/where to look. I'm using database sessions for my cake application, these sessions are not getting cleaned up. The app in question I have the issue on is an old one written on 1.3.10 running with php version 5.3.5. The garbage collection function in the 2.x branch is the same so don't think the framework version will matter. I've tracked down the issue to the function __gc located in the CakeSession class and that function is registered there in the php session_set_save_handler function, this is the function in question: /** * Helper function called on gc for database sessions. * * @param integer $expires Timestamp (defaults to current time) * @return boolean Success * @access private */function __gc($expires = null) { $model = ClassRegistry::getObject('**Session'); if (!$expires) { $expires = time(); } $return = $model-deleteAll(array($model**-alias . .expires = $expires), false, false); return $return; } Now, the comments say that $expires is a timestamp, but this isn't correct according to the php docs: gc($lifetime) The garbage collector callback is invoked internally by PHP periodically in order to purge old session data. The frequency is controlled by session.gc_probability and session.gc_divisor. The value of lifetime which is passed to this callback can be set in session.gc_maxlifetime. Return value should be TRUE for success, FALSE for failure. The value for $lifeime, so gc_maxlifetime in php.ini is the following: ; After this number of seconds, stored data will be seen as 'garbage' and ; cleaned up by the garbage collection process.session.gc_maxlifetime = 3600 So this results in a query that never deletes anything: delete from cake_sessions where expires 3600; Could someone clarify what I'm doing wrong or if this is an issue in cake itself? I've posted this on ask.cakephp.org as well, when I find the answer I'll make sure to update both locations. http://ask.cakephp.org/**questions/view/database_** sessions_garbage_collection_**issuehttp://ask.cakephp.org/questions/view/database_sessions_garbage_collection_issue -- 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: Database sessions garbage collection issue
If you need to run gc more often, you can create Session model and override deleteAll() to fix that $expires On Wednesday, August 1, 2012 11:21:23 PM UTC+2, majna wrote: Oh, It's in 1.3, but yeah, it's kind of a bug It should be time() + $expires as PHP passes gc_maxlifetime to callback so it never deletes old sessions. But Cake fires gc() in __close() method too: http://api13.cakephp.org/view_source/cake-session/#l-709 Try to test by increasing $probability var to 150 2012/8/1 Crazy crazy...@gmail.com The function is getting called just fine, that's not the problem. At first I thought it was something with the php settings or cake settings. But the session_save_handlers are pure php, and I have the default settings + nothing cake related is put in between in the gc function. On Wednesday, August 1, 2012 9:32:38 PM UTC+2, majna wrote: By default there is 1% chance for gc to be called by PHP. If you want to test if gc() is fired, increase *session.gc_probability *close to *divisor*: http://www.php.net/manual/en/**session.configuration.php#ini.** session.gc-probabilityhttp://www.php.net/manual/en/session.configuration.php#ini.session.gc-probability Then watch SQL log for that query. Anyway, expires should be current timestamp + Session.timeout config I know, PHP and sessions - nothing but sorcery :D On Wednesday, August 1, 2012 9:12:13 AM UTC+2, Crazy wrote: I'm having some issues with my sessions. It's probably configuration somewhere, but don't know what to change/where to look. I'm using database sessions for my cake application, these sessions are not getting cleaned up. The app in question I have the issue on is an old one written on 1.3.10 running with php version 5.3.5. The garbage collection function in the 2.x branch is the same so don't think the framework version will matter. I've tracked down the issue to the function __gc located in the CakeSession class and that function is registered there in the php session_set_save_handler function, this is the function in question: /** * Helper function called on gc for database sessions. * * @param integer $expires Timestamp (defaults to current time) * @return boolean Success * @access private */function __gc($expires = null) { $model = ClassRegistry::getObject('**Session'); if (!$expires) { $expires = time(); } $return = $model-deleteAll(array($model**-alias . .expires = $expires), false, false); return $return; } Now, the comments say that $expires is a timestamp, but this isn't correct according to the php docs: gc($lifetime) The garbage collector callback is invoked internally by PHP periodically in order to purge old session data. The frequency is controlled by session.gc_probability and session.gc_divisor. The value of lifetime which is passed to this callback can be set in session.gc_maxlifetime. Return value should be TRUE for success, FALSE for failure. The value for $lifeime, so gc_maxlifetime in php.ini is the following: ; After this number of seconds, stored data will be seen as 'garbage' and ; cleaned up by the garbage collection process.session.gc_maxlifetime = 3600 So this results in a query that never deletes anything: delete from cake_sessions where expires 3600; Could someone clarify what I'm doing wrong or if this is an issue in cake itself? I've posted this on ask.cakephp.org as well, when I find the answer I'll make sure to update both locations. http://ask.cakephp.org/**questions/view/database_** sessions_garbage_collection_**issuehttp://ask.cakephp.org/questions/view/database_sessions_garbage_collection_issue -- 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: Database sessions garbage collection issue
It's the same code in the 2.x branch, I'll log a ticket, just wanted to be 100% sure before I did. In the close method it only gets called when using cache, not when using database sessions. I'll patch the function, thanks for the help. -- 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
Proper MVC location for a function and its call
Hello. Thank you, so very much, for you time and expertise. I am just getting started with PHP, MVC, and CakePHP. Having read through the documentation, I'm still confused about how, where to do things with proper MVC. I have a function for a TreeBehavior that returns the level of a node in the tree (1, 2, 3, etc.) based upon getPath() method. /** * getlevel * * @param int $id * @return int */ public function getlevel($id=null) { // Count of array items, minus one, will tell me the level of the node $count = count($this-TopicTree-getPath($id,array('TopicTree.id')))-1; // debugger::dump($count); die; return $count; } The function works with debugger::dump($count); die;, producing a result, e.g.: (int) 4 Now, I would like to use that returned value in the controller's edit and add actions, to insert into the database this value in a level field. I want to use proper MVC approach. So, where does this function reside (in the TopicTree Model?) and where do I call it (from the edit and add actions of the TopicTreesController?) ? Maybe this is an entirely different issue, but would your answer change if I also wanted to use the function to, say, include the level in the Title of the index view? So confused, but really do want to learn how to do this right! Thank you!! Kevin -- 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: Proper MVC location for a function and its call
Will this function be used by just one model - TopicTree? ? If yes then put it in model and call it from the controller $this-TopicTree-getLevel($id); HTH Tarique On Thu, Aug 2, 2012 at 8:22 AM, kevin.ncbible ke...@ncbible.com wrote: Hello. Thank you, so very much, for you time and expertise. I am just getting started with PHP, MVC, and CakePHP. Having read through the documentation, I'm still confused about how, where to do things with proper MVC. I have a function for a TreeBehavior that returns the level of a node in the tree (1, 2, 3, etc.) based upon getPath() method. /** * getlevel * * @param int $id * @return int */ public function getlevel($id=null) { // Count of array items, minus one, will tell me the level of the node $count = count($this-TopicTree-getPath($id,array('TopicTree.id')))-1; // debugger::dump($count); die; return $count; } The function works with debugger::dump($count); die;, producing a result, e.g.: (int) 4 Now, I would like to use that returned value in the controller's edit and add actions, to insert into the database this value in a level field. I want to use proper MVC approach. So, where does this function reside (in the TopicTree Model?) and where do I call it (from the edit and add actions of the TopicTreesController?) ? Maybe this is an entirely different issue, but would your answer change if I also wanted to use the function to, say, include the level in the Title of the index view? So confused, but really do want to learn how to do this right! Thank you!! Kevin -- 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 -- = PHP for E-Biz: http://sanisoft.com = -- 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
link database tables that are not matched to a model
I have a table, 'userDetails' and another table 'accountUsage'. The first stores emails, passwords etc. the other login dates, creation dates etc. They both have a field called 'id' which links the two rows together for 1 person. In cake i have a model called 'User' which handles logging in/out, registration... Can i link the two tables inside the user model so i can access and update them both simultaneously or do I have to use a join every time? Thanks -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Can CakePHP service be provided to download cvs into Excel?
Dear Cakephp gurus, I would like to use Excel to call a cvs service at CakePHP app and download the csv data into Excel cells. May I know if this can be done? Anyone can provide helpful links on this? Thank you for your help in advance. -- 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