HtmlHelper link method problem
Hello everyone, I have a strange problem with routes and html helper. I have the following routes: Router::connect('/view-category/:category-url/page-:page/', array('controller' = 'frontend_pages', 'action' = 'view_category'), array( 'pass' = array('category-url'), 'category-url' = '[\w-]+', 'page' = '[0-9]+' )); Router::connect('/view-category/:category-url/', array('controller' = 'frontend_pages', 'action' = 'view_category'), array( 'pass' = array('category-url'), 'category-url' = '[\w-]+' )); Now, if i acces any of the routes in the browser it works perfectly, but if I do: ?php echo $html-link('Next', array('controller' = 'frontend_pages', 'action' = 'view_category', 'category-url' = $category['Category']['url'], 'page' = $nextPage)); ? It doesn't output the link to the first route as it should. Why ? Thx for help Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Here is my database schema,please peovide me model for his.
Hi John, Here I am attatching my database schema.So can you provide me the sample model. Cheers: Anand Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Here is my database schema,please peovide me model for his.
Hi Anand, Sorry, I am using Google Groups, can't see any attachments. John On Dec 2, 11:04 am, anand angadi anuang...@gmail.com wrote: Hi John, Here I am attatching my database schema.So can you provide me the sample model. Cheers: Anand Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Html entities
if you used utf8 correctly, it would not do that... On 2 Dez., 08:55, Ernesto e.fanz...@gmail.com wrote: Hello. i have a controller, a model and the usual add/remove/edit views in the add view i have a simple form. here's the code echo $form-input(Items.0.code); echo $form-input(Items.0.description); echo $form-input(Items.1.code); echo $form-input(Items.1.description); echo $form-input(Items.2.code); echo $form-input(Items.2.description); the description fields has good probability to contain a math symbol or a comparison operator. when i save my form Cake converts those symbols in html entities. is there a way to avoid this? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Html entities
i solved the problem. the culprit was the Sanitize class On 2 Dic, 11:49, euromark dereurom...@googlemail.com wrote: if you used utf8 correctly, it would not do that... On 2 Dez., 08:55, Ernesto e.fanz...@gmail.com wrote: Hello. i have a controller, a model and the usual add/remove/edit views in the add view i have a simple form. here's the code echo $form-input(Items.0.code); echo $form-input(Items.0.description); echo $form-input(Items.1.code); echo $form-input(Items.1.description); echo $form-input(Items.2.code); echo $form-input(Items.2.description); the description fields has good probability to contain a math symbol or a comparison operator. when i save my form Cake converts those symbols in html entities. is there a way to avoid this? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: What to use (Component? Helper?) for methods used in both controller and view
i usually put them into components as components can easily be added in helpers/views as well with App::import() otherwise around it usually aint that clean (html markup etc in the helper?) so better this way a) you dont have bootstrap functions you only need once or twice b) you dont have redundancy c) your code stays clean structured On 1 Dez., 20:20, drbuzasi drbuz...@gmail.com wrote: Good idea! Thanks! I wanted to use a helper but as i wrote inhttp://groups.google.com/group/cake-php/browse_thread/thread/a65a11c3... controllers don't load helpers into class variables. I give it a try. On dec. 1, 18:48, Miles J mileswjohn...@gmail.com wrote: If they are just stand alone functions that dont need to be in either a component or a helper, just place the function in your bootstrap file. On Dec 1, 5:56 am, drbuzasi drbuz...@gmail.com wrote: Hi! I have some methods for several tasks that i need not only in controllers or in views but in both of them. There are helpers for views and components for controllers. Which of theese would be a better idea to share my logics. Or is there a third way to do this? Looking forward for any help from you Thanks Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Here is my database schema,please peovide me model for his.
Looks confusing, sorry :) Trying to transform your tables into a workable ER model (not CakePHP model): A user may have one or more phone numbers A user may have one or more addresses Each phone number belongs to one user Each address belongs to one user An address may have one or more details A detail belongs to one address Tables: users - id (primary key, auto number) - other necessary columns that you may require. - created - modified phonenumbers - id (primary key, auto number) - user_id (foreign key to table users) - other necessary columns that you may require. - created - modified addresses - id (primary key, auto number) - user_id (foreign key to table users) - other necessary columns that you may require. - created - modified addressdetails - id (primary key, auto number) - address_id (foreign key to table addresses) - other necessary columns that you may require. - created - modified Do I understand your schema correctly? John On Dec 2, 11:11 am, anand angadi anuang...@gmail.com wrote: Hi John, Sorry here its attached now... Cheers: Anand shcema.bmp 1299KViewDownload Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: What to use (Component? Helper?) for methods used in both controller and view
a.) Write both, Component and Helper, try to wrap Component methods from your helper. b.) Look at the Set:: or Inflector:: class, what they extend, where they are in core cake, how they get loaded while a cake app runs - implement it similar! c.) Whatever you do, most likely (there are exceptions, see Inflector or Set or Sanitize) you are doing it wrong and there is ONE domain that fits BEST (be it controller or view domain of MVC) King regards Jonas/ionas82 On Dec 2, 11:54 am, euromark dereurom...@googlemail.com wrote: i usually put them into components as components can easily be added in helpers/views as well with App::import() otherwise around it usually aint that clean (html markup etc in the helper?) so better this way a) you dont have bootstrap functions you only need once or twice b) you dont have redundancy c) your code stays clean structured On 1 Dez., 20:20, drbuzasi drbuz...@gmail.com wrote: Good idea! Thanks! I wanted to use a helper but as i wrote inhttp://groups.google.com/group/cake-php/browse_thread/thread/a65a11c3... controllers don't load helpers into class variables. I give it a try. On dec. 1, 18:48, Miles J mileswjohn...@gmail.com wrote: If they are just stand alone functions that dont need to be in either a component or a helper, just place the function in your bootstrap file. On Dec 1, 5:56 am, drbuzasi drbuz...@gmail.com wrote: Hi! I have some methods for several tasks that i need not only in controllers or in views but in both of them. There are helpers for views and components for controllers. Which of theese would be a better idea to share my logics. Or is there a third way to do this? Looking forward for any help from you Thanks Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Complex Relationships
Hi, I need some guidance on how to build these model relationships. I need to build something that allows people to book a room in an accommodation. These are the steps. User finds room. User requests to stay in room Owner accepts / declines User Pays / finds another room. I have 3 tables so far. Members, Accommodations, BookingRequests At the moment I have the foreign key member_id in Accommodation. Do I need to add it to BookingRequest as well? This is what I store in each. Members id,email,password Accommodation id,member_id,title,room_type,price,price_week,price_month BookingRequests id,accommodation_id,checkin_date,checkout_date,message,read,member_id The relationships are. Members hasMany Accommodation Accommodation hasMany BookingRequest, belongsTo Member BookingRequest belongsTo Accommodation. Any suggestions? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: alphaNumeric not allowing valid entry (1.2.5)
Yeah, Im having exactly the same problem with PHP 5.2.9 and CakePHP 1.2.5. Ive triple checked no punc or white space. Still refusing to accept the input. On Nov 23, 4:51 am, timstermatic timsterma...@gmail.com wrote: Hi All, I have PHP 5.1.6 with CakePHP 1.2.5 and I am having problems with validating user entry using thealphaNumericrule. All other rules seem to work ok, so I am guessing it is an issue relating to how my version of PHP handles regex. Does anyone have any pointers or resources that could help me resolve this (other than installing another version of PHP!). Thanks in advance, Tim Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Newbie question
I apologize if my questions is obvious or has been answered before. I tried searching for the answer, but I don't know what best to search for, mostly likely because I am barely sure of what the terms are for the issue I am facing. I am *very* new to Cake, but I am picking it up pretty quickly. I was thinking about trying to build a test blog of sorts. I was thinking it would be nice to include a drop-in open source WYSIWYG editor (CKEditor, probably) to remove the hassle of coding a blog post in html. But I realized, because Cake maps URL requests other than the actual folder structure, the editor script might try to pull up some images for its UI and get sent elsewhere. Is this the case? Or do requests from the server itself map directly to folders? If the former, any suggestions on if it is possible to integrate third party widgets like this short of nitty gritty tying them directly to the Cake framework? I apologize if I am not being very clear - as I said, I feel like I am missing some terminology to aptly describe the situation. Let me know if I need to be clearer on any points! Thanks in advance, Dave Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Populating field from session variables
1. User fills the form. When the user clicks next button, form fields are saved to the session variable. // Save to session $this-Session-write('mydata', this-data); 2. User is displayed with the data he entered before to confirm. 3. If the data is incorrect (Recall controller) something like redo_edit action: // Restore from session $this-data = $this-Session-read('mydata'); // Display edit page snip Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Self Join Problem
Hi All, I' ve got a problem with my self-join association. My model looks like this: ?php class Project extends AppModel{ var $name = 'Project'; var $belongsTo = array( 'Assembly' = array( 'className' = 'Assembly', 'foreignKey' = 'assembly_id' ), 'Linker' = array( 'className' = 'Linker', 'foreignKey' = 'linker_id' ), 'Vector' = array( 'className' = 'Vector', 'foreignKey' = 'vector_id' ), 'User' = array( 'className' = 'User', 'foreignKey' = 'user_id' ) ); var $hasMany = array( 'Child' = array( 'className' = 'Project', 'foreignKey' ='parent_id' ) ); var $hasOne = array( 'Precursor' = array( 'className' = 'Project', 'foreignKey' = false, 'conditions' = array('Project.parent_id' = 'Precursor.id') ) ); } ? The corresponding Controller-Part is following: function view($id){ $project = $this-Project-read(null , $id); $this-set('project', $project); } When I request the corresponding Array, i get this: Array ( [Project] = Array ( [id] = 2 [parent_id] = 1 [name] = test_project_1 [created] = 2009-12-02 09:09:00 [trail_purpose] = testing [description] = testing the self-join [assembly_id] = 1 [user_id] = 18 [vector_id] = 1 [linker_id] = 1 ) [Assembly] = Array ( [id] = 1 [name] = hg19 [genome] = human [release_date] = 2009-02-01 [alternative_name] = GRCh37 ) [Linker] = Array ( [id] = 1 [name] = test_linker [sequence] = CCTAACTGCTGTGCCACT [group_id] = 1 ) [Vector] = Array ( [id] = 1 [name] = test_lenti [type] = lenti [lam_direction] = 5 [version] = 1 [sequence] = AAGGGTCTCGAGGATTCGAT [ltr_id] = 3 [group_id] = 1 ) [User] = Array ( [id] = 18 [first_name] = Tester [last_name] = Testing [login_name] = testUser [password] = testing [email] = t...@test-db.com [gender] = male [degree] = none [last_login] = 2009-12-02 07:57:07 [create_time] = 2009-12-02 07:57:07 [access_level] = read_only [deleted] = 0 [group_id] = 1 ) [Precursor] = Array ( [id] = [parent_id] = [name] = [created] = [trail_purpose] = [description] = [assembly_id] = [user_id] = [vector_id] = [linker_id] = ) [Child] = Array ( ) ) You can see, that the self join relation could not be dissolved. So, I could not display the name of the precursor as I want. Where is my mistake. Thank you in advance for your effort. Thx, soleil83 Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: CakeFest IV - America - Help us pick a location!
I vote for New York or San Francisco...or Austin, TX. On Nov 19, 2:23 pm, Lance Willett nano...@gmail.com wrote: I vote for West Coast first, Central second. West: Denver, Phoenix, San Diego, Austin, and Bay Area are top choices. Easy to fly to, mostly good weather. ;) Central: Chicago would be my vote for ease of travel. Essentially, our choices are: - USA East Coast - USA West Coast - USA Central Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Polivoda Dynamic Menu and other menu htmlentities issues
Thanks a loot for this kind of menu. http://www.palivoda.eu/2008/04/dynamic-menu-in-cakephp and for the service, it helped me to improve my software solution based on cake. In order to validate (w3c) my pages I have encountered a small problem with ampersant () and in particoular the code in the case ‘current’ doesn’t escape, so in my page source I had ‘’ instead of ‘escaped’, in ‘no current’ case the escape was right, so I wasn’t able to have a unique validated result. I resolved this problem adding htmlentities PHP function in this way: $out[$caption] = $this-Html-div(’current’, htmlentities($caption)); instead of the original: $out[$caption] = $this-Html-div(’current’, $caption); Infact funtion 'link' escapes character automatically, 'div' probably no!! Thank again Polivoda you are great. But I think that this kind of problem could exists in other menu components (or in some other components at all) Babila Saronni Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
What is the proper place to alter $_findMethods? (CakePHP 1.3alpha)
Hi, I'm creating a custom find method in my AppModel: _findRandom. And I want it to be accessible to all models, as I understand, for this to be achieved I need random (as a string) to be present in a $_findMethods array. It is set in Model class, and I thought that I can append to it in beforeFind function in AppModel, however that did not work. Then I thought that perhaps I should try doing it in a constructor, but that resulted in a blank pages (no debug messages with debug level 2). So as a temporary solution I completely redefine $_findMethods in my AppModel, bellow is how my code looks now, but I was wondering if there's a better way to append to that array. --- ?php class AppModel extends Model { var $actsAs = array('Containable'); var $_findMethods = array( 'all' = true, 'first' = true, 'count' = true, 'neighbors' = true, 'list' = true, 'threaded' = true, 'random' = true ); function _findRandom($state, $query, $results = array()) { if($state == 'before') { if(!isset($query['limit'])) { $query['limit'] = 1; } # First find all ids with current conditions $findOptions = $query; unset($findOptions['limit']); $findOptions['fields'] = a('id'); $list = $this-find('list', $findOptions); # Select random id(s) $list = array_keys($list); $resArray = array(); for($i = 0; $i $query['limit']; $i++) { $id = mt_rand(0, count($list)-1); array_push($resArray, $list[$id]); } $list = $resArray; # Add to conditions $primaryKey = $this-alias . '.' . $this-primaryKey; $query['conditions'][$primaryKey] = $list; return $query; } else { if(empty($results[0])) { return false; } return $results; } } } ? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Delete confirm
A mostly working solution[1][2], that you can see here: http://github.com/ionas/sna/blob/master/www/app/app_controller.php#L11 http://github.com/ionas/sna/blob/master/www/app/app_error.php http://github.com/ionas/sna/blob/master/www/app/views/errors/possible_csrf_attack.ctp http://github.com/ionas/sna/blob/master/www/app/controllers/messages_controller.php#L8 http://github.com/ionas/sna/blob/master/www/app/views/messages/send.ctp http://github.com/ionas/sna/blob/master/www/app/views/helpers/secure.php It is based on Teknoids great information at his blog[3][4], combined with a helper that triggers a javascript::confirm(), doubleposts are essentially not possible due to SecurityComponent. If you really require an js-free confirmation, why not add a checkbox to that helper that you have to check before clicking (check if it was clicked in the helper and before that onSubmit via javascript) [1] http://code.cakephp.org/tickets/view/377 [2] http://code.cakephp.org/tickets/view/354 [3] http://teknoid.wordpress.com/2008/11/05/make-your-cakephp-forms-a-lot-more-secure/ [4] http://teknoid.wordpress.com/2008/11/06/clearing-up-some-confusion-regarding-the-security-component/ On Dec 1, 11:07 am, jburns jeremybu...@me.com wrote: Thanks for the reply. I guess it is a tad unreasonable to expect two year old code to 'just work'! I just like stuff out of the box :-) I'll follow your suggestions and then rather than slavishly try and make this function I'll branch off my own way until I get something working. I'll post back my solution here. On Dec 1, 9:34 am, AD7six andydawso...@gmail.com wrote: On 27 nov, 12:28, jburns jeremybu...@me.com wrote: @AD7Six Apologies, but I am still struggling with this. I have deployed your code as is, with the following changes: I have removed this line: if (isset($this-params[CAKE_ADMIN]) !$this-RequestHandler-isAjax ()) { $this-layout = 'admin'; } ...because it errors and is not relevant to me. Same with this line: if ($this-javascripts) { $this-set('javascripts', $this-javascripts); } I am not using admin routing, so have changed references to admin_delete to delete. This line errors: $this-Security-__generateToken($this); ...but works if I change the double underscore to a single underscore. I have created the _generic folder and put the confirm_action view in it. I *think* I understand what is going on in the code. It picks up that I am calling the delete action via a link (and therefore a GET). As 'delete' is in the $postActions array, I am directed to the _confirmAction function. This renders the confirm_action view, which contains a form that calls the delete action via a POST. When I submit the form it ought to come back into app_controller and pass through to the delete action. However, I am still being directed back to the confirm_action view. Stumped. I notice that it is calling Security-_generateToken. Should this be being picked up anywhere else? If not, what is its purpose? I appreciate your help. This is gnawing away at me and I can't work it through. Thanks. Without seeing your exact code I|other people can't help much. Yes, the core changed a little in the past 2 years, as did a few other things. e.g. I personally don't use a _generic folder anymore since you can just do $this-render('/elements/this_one'); - as can be seen in the repo solution I linked to. If you're being redirected to confirm_action in a loop the form token that's generated 'manually' (see the form helper create function if you want to see what else uses it) doesn't match what the security component is expecting. Except for the period of time when I was originally writing this technique - I haven't seen that happen. You'd need to debug and find out why. hth, AD Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: releted select
With Model-recursive you can just use associations and fetch data. See http://book.cakephp.org/view/82/hasMany in your ClientsController just do $this-set('clients', $this-Client- find('first', array('conditions' = array('Client.id' = $id; In your clients/view.ctp debug($clients); On Dec 1, 12:53 pm, Tom tomislav.vitenb...@gmail.com wrote: Hi, I need help. How to view and select only projects for selected client? CREATE TABLE IF NOT EXISTS `projects` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(200) NOT NULL, `client_id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; CREATE TABLE IF NOT EXISTS `clients` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(100) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; CREATE TABLE IF NOT EXISTS `activities` ( `id` int(11) NOT NULL AUTO_INCREMENT, `client_id` int(11) NOT NULL, `project_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Security component woes
Dump our beforeFilter (AppController and UsersController) On Dec 1, 6:20 pm, designv...@gmail.com designv...@gmail.com wrote: Hi all, I have the Security component enabled in my users controller and its adding the tokens into my register form and I am viewing it via HTTPS, however the form never submits, it just reloads the page, no save or no validation errors... I am sure I am missing something. I'm using Auth also and my login functions are fine via SSL... Any ideas? d. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: beforeSave vs beforeValidate
Check what those methods have to return, at least(maybe both) one of them (I think it was beforeSave) has to return true; On Dec 1, 10:46 pm, naidim nai...@gmail.com wrote: Sorry, I meant to say the code is in the user MODEL not controller. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Complex Relationships
I see the following objects in your description: Renter, Guest, Room, Owner, Booking Can one room have more than one Guest per room? Can one booking involve more than one room? John On Dec 2, 5:42 pm, onlymejosh star...@gmail.com wrote: Hi, I need some guidance on how to build these model relationships. I need to build something that allows people to book a room in an accommodation. These are the steps. User finds room. User requests to stay in room Owner accepts / declines User Pays / finds another room. I have 3 tables so far. Members, Accommodations, BookingRequests At the moment I have the foreign key member_id in Accommodation. Do I need to add it to BookingRequest as well? This is what I store in each. Members id,email,password Accommodation id,member_id,title,room_type,price,price_week,price_month BookingRequests id,accommodation_id,checkin_date,checkout_date,message,read,member_id The relationships are. Members hasMany Accommodation Accommodation hasMany BookingRequest, belongsTo Member BookingRequest belongsTo Accommodation. Any suggestions? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Error in the manual?
Well of course you cant use a helper in a controller. Helpers are used in views ONLY. You define it in the controller, which in turn passes it down to the views. On Dec 1, 9:18 am, drbuzasi drbuz...@gmail.com wrote: This page (http://book.cakephp.org/view/53/components-helpers-and- uses) begins with the following text: The next most often used controller attributes tell CakePHP what helpers, components, and models you’ll be using in conjunction with the current controller. Using these attributes make these MVC classes available to the controller as a class variable ($this-ModelName, for example). Maybe i'm wrong but i think helpers given by the $helpers attribute ain't available as class variables ($this-HelperName) as decribed in the 2nd sentence. At least not in version 1.2.5. So if you want to access your selt defined 'OwnHelper' i.e. in a controller it's not a good idea to set $helpers = array('OwnHelper'); as decribed there but rather have to App::import('Helper', 'OwnHelper'); it and then assign to the desired class variable: $this-Own = new OwnHelper; This doesn't happen automatically. Am i right or am i misunderstanding something? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
inventory management
I need guidance on how to setup an inventory system. The inventory I am managing is in liquid form and will be added/subtracted in different units. For example Product A will be added from the supplier in gallons, distributed out the door in pints, and applied in fluid ounces. I thought about having a quantity field in the products table to keep track of this but the only problem I see is which unit do I store it in? If it's stored in gallons and you subtract only a few ounces then it won't be very accurate to have a huge decimal number i.e. you had 5 gallons and subtracted a few ounces so now you have 4.966 gallons left. I could store it in ounces to avoid that but each product will have different units and it might be difficult to keep track of all that. Any suggestions on a good way to handle this? Are there any examples of inventory/inventory management systems for cake? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Any chance to get the ID of a new created record BEFORE I save it to the DB?
Hey, I have a serious problem, and I need a hint from you guys to solve it! In one of my controller actions, I have the problem that I need to create some records , let's say A, B, and C. The problem is, that record A needs a field from record B, which is the ID of record B, and which I only can set when record A is saved, and B is saved. In model C I need some information from the new created models A and B, which I only have when model A and B are saved. As this has to do with a register-process for my app, I need to validate the data for all models. The problem is, that when model A passes validation, and get's saved (which is needed to save the other models) and model B fails, I have a never used record of model A in my database. I need to get around that, because that's like a worst case for me! I hope there's any chance to create a record, set this record with the data I get from my registration form, and use the data for the other records and save everything at the end of the action when every record validates! I know I can check a record for validation by setting the model data with $this-Model-set($this-data) and then if($this-Model-validates()) { save the record(s) } But right now I'm only able to do this when I have an edit action and I set the Model to a specific record with like $this-Model-id = $id_from_get_parameter_or_so It would be VERY cool if there is a slight chance that I could create a new record with current auto-increment id from the database, use that id for my other models, and at the end when I created all needed records I'd check every record for validation and if every record is ok, they all get saved. If anyone knows how to achieve this, I would be very very happy! Cheers, DD P.S.: If needed, I can post the code of the whole RequestAction to see if maybe there's another solution to this... Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: How can I get the current session?
Hi Nick, thank you for your reply, very interesting suggestion for the who's online feature. And yes, once I get hold of who is browsing, I want to store the data in a table (may be 'users' with a status flag indicating they are not registered). But why rely on $_SERVER['REMOTE_ADDR'] (IPs aren't prone to duplicates, two or more users behind the same firewall?), where CakePHP automatically writes a 'CAKEPHP' (session, I think) cookie? I mean, a part from not being to access to its value, just like me :-) ... Best, Mario On 2 Dic, 05:10, nurvzy nur...@gmail.com wrote: Hi Mario, Well, if you want to use Sessions or Cookies I suggest reading the book on the two. The problem you'll face is both cookie and session are client based objects. So you can set all the sessions and cookies you want but you'll need a way to store them somewhere in either your server memory or a database so *you* can see it. I suggest ditching the Session/Cookie idea and go with a database or flat-file. The way I've tracked users in the past is create a database table ('onlines' for me). Then in my Online model I just create a little method that delete's all entries greater than 10 minutes modified. I then pass in $this-here to my Online's createOrUpdateUser model function, this is all in my beforeFilter() in my app_controller.php //app_controller beforeFilter() $this-Online-update(); $this-Online-createOrUpdateUser($this-here); In createOrUpdateUser($currentPage = null) I use the IP ( $_SERVER ['REMOTE_ADDR'] ) as the key and just update/create where the user currently is in the app $this-here in the app_controller. This gives me a nice little Online table that I can look at to see who's online (for the last 10 minutes). Hope that helps, Nick On Dec 1, 11:50 am, Mario mario.calli...@gmail.com wrote: Hi all, I am dealing with unregistered users (no Auth login) and I want to track them from page to page using sessions. I see in my browser a cookie named 'CAKEPHP' and I thought I could read it in a controller with $this-Cookie-read(Configure::read('Session.cookie')) [where in my config/core.php I have Configure::write('Session.cookie', 'CAKEPHP');] But it doesn't work, I get nothing. Any hint or alternative method I could implement? Thank you in advance. Best, Mario Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: How can I get the current session?
Hi Nick, thank you for your reply, very interesting suggestion for the who's online feature. And yes, once I get hold of who is browsing, I want to store the data in a table (may be 'users' with a status flag indicating they are not registered). But why rely on $_SERVER['REMOTE_ADDR'] (IPs aren't prone to duplicates, two or more users behind the same firewall?), where CakePHP automatically writes a 'CAKEPHP' (session, I think) cookie? I mean, a part from not being to access to its value, just like me :-) ... Best, Mario On 2 Dic, 05:10, nurvzy nur...@gmail.com wrote: Hi Mario, Well, if you want to use Sessions or Cookies I suggest reading the book on the two. The problem you'll face is both cookie and session are client based objects. So you can set all the sessions and cookies you want but you'll need a way to store them somewhere in either your server memory or a database so *you* can see it. I suggest ditching the Session/Cookie idea and go with a database or flat-file. The way I've tracked users in the past is create a database table ('onlines' for me). Then in my Online model I just create a little method that delete's all entries greater than 10 minutes modified. I then pass in $this-here to my Online's createOrUpdateUser model function, this is all in my beforeFilter() in my app_controller.php //app_controller beforeFilter() $this-Online-update(); $this-Online-createOrUpdateUser($this-here); In createOrUpdateUser($currentPage = null) I use the IP ( $_SERVER ['REMOTE_ADDR'] ) as the key and just update/create where the user currently is in the app $this-here in the app_controller. This gives me a nice little Online table that I can look at to see who's online (for the last 10 minutes). Hope that helps, Nick On Dec 1, 11:50 am, Mario mario.calli...@gmail.com wrote: Hi all, I am dealing with unregistered users (no Auth login) and I want to track them from page to page using sessions. I see in my browser a cookie named 'CAKEPHP' and I thought I could read it in a controller with $this-Cookie-read(Configure::read('Session.cookie')) [where in my config/core.php I have Configure::write('Session.cookie', 'CAKEPHP');] But it doesn't work, I get nothing. Any hint or alternative method I could implement? Thank you in advance. Best, Mario Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
modifying baked sources
Hi If I create models, controllers and views with bake, and I modify those files, the next time I run bake they'll overwritten (say that I added some new fields that I want to bake); is there a general idiom to deal with that? thanks in advance Lorenzo P.S. is bake documented in more details than it is here: http://book.cakephp.org/view/113/Code-Generation-with-Bake ? -- Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: What to use (Component? Helper?) for methods used in both controller and view
Another approach is to do neither. You can create classes that are not direct MVC bits and use them. Like jonas said the core Inflector and Set classes are excellent examples of non MVC utility classes. -Mark On Dec 2, 6:40 am, j0n4s.h4rtm...@googlemail.com j0n4s.h4rtm...@googlemail.com wrote: a.) Write both, Component and Helper, try to wrap Component methods from your helper. b.) Look at the Set:: or Inflector:: class, what they extend, where they are in core cake, how they get loaded while a cake app runs - implement it similar! c.) Whatever you do, most likely (there are exceptions, see Inflector or Set or Sanitize) you are doing it wrong and there is ONE domain that fits BEST (be it controller or view domain of MVC) King regards Jonas/ionas82 On Dec 2, 11:54 am, euromark dereurom...@googlemail.com wrote: i usually put them into components as components can easily be added in helpers/views as well with App::import() otherwise around it usually aint that clean (html markup etc in the helper?) so better this way a) you dont have bootstrap functions you only need once or twice b) you dont have redundancy c) your code stays clean structured On 1 Dez., 20:20, drbuzasi drbuz...@gmail.com wrote: Good idea! Thanks! I wanted to use a helper but as i wrote inhttp://groups.google.com/group/cake-php/browse_thread/thread/a65a11c3... controllers don't load helpers into class variables. I give it a try. On dec. 1, 18:48, Miles J mileswjohn...@gmail.com wrote: If they are just stand alone functions that dont need to be in either a component or a helper, just place the function in your bootstrap file. On Dec 1, 5:56 am, drbuzasi drbuz...@gmail.com wrote: Hi! I have some methods for several tasks that i need not only in controllers or in views but in both of them. There are helpers for views and components for controllers. Which of theese would be a better idea to share my logics. Or is there a third way to do this? Looking forward for any help from you Thanks Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Are unit tests REALLY a unit tests?
Although you don't use all the relations, all of the fixtures are needed due to the way associations are implemented by CakePHP. This is mostly a side effect of PHP4 support and will be removed once autoloading of models can be achieved. -Mark On Dec 1, 9:00 am, Grzegorz Pawlik grzegorzpaw...@gmail.com wrote: Those should test single unit. I know, that sometimes it's convenient to test model with (some close) associations. But I find quite odd that situation: Creating PackageTest, and including app.packages_appendix and app.appendix fixtures - it's reasonable for now. But why the heck I need to include app.entry fixture (Appendix belongs to Entry), and app.user (Entry belongs to User) and app.group (User is in Group), and so - to the end of relation chain. If I don't do that - I'll have missing database info instead of test results. I know that those are related (by transitions), but I never used so deep recursion. Even If I did, I do It by contain, so it would be better to get error from Containable, that I'm trying to use unknown model. After adding model and relations to my project some of my test cases seize to pass untill I tell them to use fixtures they don't need. Or am I doing something wrong? Greg ps. Thanks for CakePHP - it's great! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: inventory management
I suggest using a metric measure for your volumes which as base 10 will be easier to work with than the different scales between oz pints and gallons. You can then convert your metric measure to an imperial amount via a helper. What ever way you do it you'll need to maintain the same unit of measure. I'd suggest using litres as unit of measure. Mike Karthauser Brightstorm limited Tel: 07939252144 On 2 Dec 2009, at 18:03, fly2279 kennethf...@gmail.com wrote: I need guidance on how to setup an inventory system. The inventory I am managing is in liquid form and will be added/subtracted in different units. For example Product A will be added from the supplier in gallons, distributed out the door in pints, and applied in fluid ounces. I thought about having a quantity field in the products table to keep track of this but the only problem I see is which unit do I store it in? If it's stored in gallons and you subtract only a few ounces then it won't be very accurate to have a huge decimal number i.e. you had 5 gallons and subtracted a few ounces so now you have 4.966 gallons left. I could store it in ounces to avoid that but each product will have different units and it might be difficult to keep track of all that. Any suggestions on a good way to handle this? Are there any examples of inventory/inventory management systems for cake? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: inventory management
I agree that metric would be much easier to convert but therein lies the problem. Every time you convert from the user input of imperial to metric you lose some accuracy in the total inventory. I guess I just need to use the smallest unit to store it in the table and then convert when inventory is added/subtracted. Are there any good tutorials/examples on methods to add/subtract inventory? Should I be using a 'transactions' table and total those transactions to come up with a quantity on hand or will that get out of control with thousands of rows? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: modifying baked sources
I guess there are two approaches. 1. Rename the model/views/ controllers before you bake, then do a comparison and merge afterwards. 2. Once you have the initial bake complete, just amend the files rather than re-baking. This has the advantage of helping you learn as well. On Dec 2, 6:23 pm, Lorenzo Bettini bett...@dsi.unifi.it wrote: Hi If I create models, controllers and views with bake, and I modify those files, the next time I run bake they'll overwritten (say that I added some new fields that I want to bake); is there a general idiom to deal with that? thanks in advance Lorenzo P.S. is bake documented in more details than it is here:http://book.cakephp.org/view/113/Code-Generation-with-Bake? -- Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino HOME:http://www.lorenzobettini.itMUSIC:http://www.purplesucker.com BLOGS:http://tronprog.blogspot.com http://longlivemusic.blogspot.com Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
footer appears twice-problem
Hello people, i have build my app and i have a problem.I have created a footer which i included in every layout that i use.All seems good in all layouts apart from my home page.I saw the code from Firebug and i realize that the footer and the header as well appear 2 times.I imagine that this is caused by the default layout,and my question is how can i make it appear properly one time? Any help woulb be nice! Ty Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Complex Relationships
These are the objects Renter, Owner, Room, Booking The number of guests isn't a factor. The booking invovles one room at a time. Its not a normal hotel per- say On Dec 2, 5:18 pm, John Andersen j.andersen...@gmail.com wrote: I see the following objects in your description: Renter, Guest, Room, Owner, Booking Can one room have more than one Guest per room? Can one booking involve more than one room? John On Dec 2, 5:42 pm, onlymejosh star...@gmail.com wrote: Hi, I need some guidance on how to build these model relationships. I need to build something that allows people to book a room in an accommodation. These are the steps. User finds room. User requests to stay in room Owner accepts / declines User Pays / finds another room. I have 3 tables so far. Members, Accommodations, BookingRequests At the moment I have the foreign key member_id in Accommodation. Do I need to add it to BookingRequest as well? This is what I store in each. Members id,email,password Accommodation id,member_id,title,room_type,price,price_week,price_month BookingRequests id,accommodation_id,checkin_date,checkout_date,message,read,member_id The relationships are. Members hasMany Accommodation Accommodation hasMany BookingRequest, belongsTo Member BookingRequest belongsTo Accommodation. Any suggestions? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Any chance to get the ID of a new created record BEFORE I save it to the DB?
I think this would really help your situation http://bakery.cakephp.org/articles/view/wizard-component-1-2-1 I have used it in the past and if you read the documentation thoroughly it is very easy to implement. On Wed, Dec 2, 2009 at 1:05 PM, DigitalDude e.blumsten...@googlemail.comwrote: Hey, I have a serious problem, and I need a hint from you guys to solve it! In one of my controller actions, I have the problem that I need to create some records , let's say A, B, and C. The problem is, that record A needs a field from record B, which is the ID of record B, and which I only can set when record A is saved, and B is saved. In model C I need some information from the new created models A and B, which I only have when model A and B are saved. As this has to do with a register-process for my app, I need to validate the data for all models. The problem is, that when model A passes validation, and get's saved (which is needed to save the other models) and model B fails, I have a never used record of model A in my database. I need to get around that, because that's like a worst case for me! I hope there's any chance to create a record, set this record with the data I get from my registration form, and use the data for the other records and save everything at the end of the action when every record validates! I know I can check a record for validation by setting the model data with $this-Model-set($this-data) and then if($this-Model-validates()) { save the record(s) } But right now I'm only able to do this when I have an edit action and I set the Model to a specific record with like $this-Model-id = $id_from_get_parameter_or_so It would be VERY cool if there is a slight chance that I could create a new record with current auto-increment id from the database, use that id for my other models, and at the end when I created all needed records I'd check every record for validation and if every record is ok, they all get saved. If anyone knows how to achieve this, I would be very very happy! Cheers, DD P.S.: If needed, I can post the code of the whole RequestAction to see if maybe there's another solution to this... Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
TreeBehavior fails to set lft and rght correctly
Hi everyone, I'm using TreeBehavior in a classic model, but its lft and rght fields are not set correctly. I tried these two save() in a controller : $this-MenuItem-create(); $this-MenuItem-save(array('MenuItem' = array( 'url' = '/fre', 'parent_id' = null, 'label' = 'Home', 'online' = 1 ))); $parent_id = $this-MenuItem-id; debug($this-MenuItem-verify()); $this-MenuItem-create(); $this-MenuItem-save(array('MenuItem' = array( 'url' = '/fre/p/Choses', 'parent_id' = $parent_id, 'label' = 'Choses', 'online' = 1 ))); debug($this-MenuItem-verify()); debug($this-MenuItem-recover()); debug($this-MenuItem-verify()); die(); I truncated the table menu_items, ran the test and discovered that the two last calls to verify() fail, even after recover(). I followed the cookbook... but did I miss something? If it can helps : I'm running Cake 1.2.3.8166 I also tried to download the last TreeBehavior from cake's master branch, but it didn't change anything thanks! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Any chance to get the ID of a new created record BEFORE I save it to the DB?
Its impossible to get the ID for a row your about to save, until after you save it. The most you can do is do a query to select the last row in the table, then increment its ID by one. On Dec 2, 2:18 pm, Dave davidcr...@gmail.com wrote: I think this would really help your situation http://bakery.cakephp.org/articles/view/wizard-component-1-2-1 I have used it in the past and if you read the documentation thoroughly it is very easy to implement. On Wed, Dec 2, 2009 at 1:05 PM, DigitalDude e.blumsten...@googlemail.comwrote: Hey, I have a serious problem, and I need a hint from you guys to solve it! In one of my controller actions, I have the problem that I need to create some records , let's say A, B, and C. The problem is, that record A needs a field from record B, which is the ID of record B, and which I only can set when record A is saved, and B is saved. In model C I need some information from the new created models A and B, which I only have when model A and B are saved. As this has to do with a register-process for my app, I need to validate the data for all models. The problem is, that when model A passes validation, and get's saved (which is needed to save the other models) and model B fails, I have a never used record of model A in my database. I need to get around that, because that's like a worst case for me! I hope there's any chance to create a record, set this record with the data I get from my registration form, and use the data for the other records and save everything at the end of the action when every record validates! I know I can check a record for validation by setting the model data with $this-Model-set($this-data) and then if($this-Model-validates()) { save the record(s) } But right now I'm only able to do this when I have an edit action and I set the Model to a specific record with like $this-Model-id = $id_from_get_parameter_or_so It would be VERY cool if there is a slight chance that I could create a new record with current auto-increment id from the database, use that id for my other models, and at the end when I created all needed records I'd check every record for validation and if every record is ok, they all get saved. If anyone knows how to achieve this, I would be very very happy! Cheers, DD P.S.: If needed, I can post the code of the whole RequestAction to see if maybe there's another solution to this... Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: TreeBehavior fails to set lft and rght correctly
Can you paste your model? Or at least the important parts at the top? On Wed, Dec 2, 2009 at 6:19 PM, Martin Kirchgessner martin.ki...@gmail.comwrote: Hi everyone, I'm using TreeBehavior in a classic model, but its lft and rght fields are not set correctly. I tried these two save() in a controller : $this-MenuItem-create(); $this-MenuItem-save(array('MenuItem' = array( 'url' = '/fre', 'parent_id' = null, 'label' = 'Home', 'online' = 1 ))); $parent_id = $this-MenuItem-id; debug($this-MenuItem-verify()); $this-MenuItem-create(); $this-MenuItem-save(array('MenuItem' = array( 'url' = '/fre/p/Choses', 'parent_id' = $parent_id, 'label' = 'Choses', 'online' = 1 ))); debug($this-MenuItem-verify()); debug($this-MenuItem-recover()); debug($this-MenuItem-verify()); die(); I truncated the table menu_items, ran the test and discovered that the two last calls to verify() fail, even after recover(). I followed the cookbook... but did I miss something? If it can helps : I'm running Cake 1.2.3.8166 I also tried to download the last TreeBehavior from cake's master branch, but it didn't change anything thanks! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: TreeBehavior fails to set lft and rght correctly
Also, these two suggestions were in the comments. I didn't need the relationship from the first one but I am using the latest svn checkout, so perhaps he was posting that from an older version. Also the second one might be useful as well. The model needs a relation for me to work with this example. If I add the following to the model it works: pre var $belongsTo = array( 'Parent' =gt; array( 'className' =gt; 'Category', 'foreignKey' =gt; 'parent_id', 'conditions' =gt; '', 'fields' =gt; '', 'order' =gt; '', 'counterCache' =gt; ''), ); /pre By etipaced on 30/9/08 2 #comment_391 - bug/glitch/feature? I just spent a lot of time troubleshooting an odd issue. Make sure your id, lft and rght columns are set to just UNSIGNED and not UNSIGNED ZEROFILL. I like to use the ZEROFILL attribute on all my integer column types that store id values but the TreeBehavior fails without any warnings or errors if the integer column values are in the format of 0001 instead of just 1. On Wed, Dec 2, 2009 at 7:00 PM, Dave davidcr...@gmail.com wrote: Can you paste your model? Or at least the important parts at the top? On Wed, Dec 2, 2009 at 6:19 PM, Martin Kirchgessner martin.ki...@gmail.com wrote: Hi everyone, I'm using TreeBehavior in a classic model, but its lft and rght fields are not set correctly. I tried these two save() in a controller : $this-MenuItem-create(); $this-MenuItem-save(array('MenuItem' = array( 'url' = '/fre', 'parent_id' = null, 'label' = 'Home', 'online' = 1 ))); $parent_id = $this-MenuItem-id; debug($this-MenuItem-verify()); $this-MenuItem-create(); $this-MenuItem-save(array('MenuItem' = array( 'url' = '/fre/p/Choses', 'parent_id' = $parent_id, 'label' = 'Choses', 'online' = 1 ))); debug($this-MenuItem-verify()); debug($this-MenuItem-recover()); debug($this-MenuItem-verify()); die(); I truncated the table menu_items, ran the test and discovered that the two last calls to verify() fail, even after recover(). I followed the cookbook... but did I miss something? If it can helps : I'm running Cake 1.2.3.8166 I also tried to download the last TreeBehavior from cake's master branch, but it didn't change anything thanks! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Help accessing array from HABTM relationship
I have a table called Group that has a HABTM relationship to table Points. Group also has a HABTM relationship to Users. Groups_Points table manages this relationship. I can run a $thisPointGroupfindAll command and get an array that looks like this: Array ( [0] = Array ( [Group] = Array ( [id] = 1 [user_ID] = 1 [name] = Dallas Photogs [pic1] = [created] = 2009-12-01 21:23:15 [Moderate] = 0 ) [Point] = Array ( [0] = Array ( [id] = 1 [title] = Dallas, Texas [description] = dallas [user_ID] = 1 [type] = City [address] = 101 main st. dallas, tx [city] = dallas [state] = TX [zip] = 76010 [GroupsPoint] = Array ( [id] = 1 [group_id] = 1 [point_id] = 1 [created] = 2009-12-02 14:36:10 [modified] = 2009-12-02 14:36:10 ) ) ) [User] = Array ( [0] = Array ( [id] = 1 [username] = John [email] = j...@gmail.com [password] = 79467e27a472 [first_name] = John [last_name] = Smith [created] = 2009-11-24 23:15:16 [modified] = 2009-11-29 01:00:26 [GroupsUser] = Array ( [id] = 1 [group_id] = 1 [user_id] = 1 [admin] = 1 [created] = 2009-12-02 14:36:10 [modified] = 2009-12-02 14:36:10 ) ) ) ) ) I can do a foreach command in the view i.e. $groups as $group and access Group.Name as $group['Group']['name']. What's the best way to access the User.name data in this array. $group ['User']['username'] results in index not found...I see it's nested one level deep. Thanks for the advice in advance! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: inventory management
I have to agree at least if you store in metrics you will ever only have to convert it once, when you are displaying it. Though this inherently loses some accuracy, it is exponentially worse if you have to convert a conversion On Wed, Dec 2, 2009 at 1:45 PM, fly2279 kennethf...@gmail.com wrote: I agree that metric would be much easier to convert but therein lies the problem. Every time you convert from the user input of imperial to metric you lose some accuracy in the total inventory. I guess I just need to use the smallest unit to store it in the table and then convert when inventory is added/subtracted. Are there any good tutorials/examples on methods to add/subtract inventory? Should I be using a 'transactions' table and total those transactions to come up with a quantity on hand or will that get out of control with thousands of rows? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: How can I get the current session?
You can use the session id as the key as well if you prefer You just need to be sure to change the Security.level value in your core.php to at most medium. On high it regenerates the session id every request. On Wed, Dec 2, 2009 at 1:08 PM, Mario mario.calli...@gmail.com wrote: Hi Nick, thank you for your reply, very interesting suggestion for the who's online feature. And yes, once I get hold of who is browsing, I want to store the data in a table (may be 'users' with a status flag indicating they are not registered). But why rely on $_SERVER['REMOTE_ADDR'] (IPs aren't prone to duplicates, two or more users behind the same firewall?), where CakePHP automatically writes a 'CAKEPHP' (session, I think) cookie? I mean, a part from not being to access to its value, just like me :-) ... Best, Mario On 2 Dic, 05:10, nurvzy nur...@gmail.com wrote: Hi Mario, Well, if you want to use Sessions or Cookies I suggest reading the book on the two. The problem you'll face is both cookie and session are client based objects. So you can set all the sessions and cookies you want but you'll need a way to store them somewhere in either your server memory or a database so *you* can see it. I suggest ditching the Session/Cookie idea and go with a database or flat-file. The way I've tracked users in the past is create a database table ('onlines' for me). Then in my Online model I just create a little method that delete's all entries greater than 10 minutes modified. I then pass in $this-here to my Online's createOrUpdateUser model function, this is all in my beforeFilter() in my app_controller.php //app_controller beforeFilter() $this-Online-update(); $this-Online-createOrUpdateUser($this-here); In createOrUpdateUser($currentPage = null) I use the IP ( $_SERVER ['REMOTE_ADDR'] ) as the key and just update/create where the user currently is in the app $this-here in the app_controller. This gives me a nice little Online table that I can look at to see who's online (for the last 10 minutes). Hope that helps, Nick On Dec 1, 11:50 am, Mario mario.calli...@gmail.com wrote: Hi all, I am dealing with unregistered users (no Auth login) and I want to track them from page to page using sessions. I see in my browser a cookie named 'CAKEPHP' and I thought I could read it in a controller with $this-Cookie-read(Configure::read('Session.cookie')) [where in my config/core.php I have Configure::write('Session.cookie', 'CAKEPHP');] But it doesn't work, I get nothing. Any hint or alternative method I could implement? Thank you in advance. Best, Mario Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: How can I get the current session?
Ps. I think that previous statement that Session is a client side object is incorrect. Sessions = server side, Cookies = client side If I am not mistaken... which happens plenty heh On Wed, Dec 2, 2009 at 7:11 PM, Dave davidcr...@gmail.com wrote: You can use the session id as the key as well if you prefer You just need to be sure to change the Security.level value in your core.php to at most medium. On high it regenerates the session id every request. On Wed, Dec 2, 2009 at 1:08 PM, Mario mario.calli...@gmail.com wrote: Hi Nick, thank you for your reply, very interesting suggestion for the who's online feature. And yes, once I get hold of who is browsing, I want to store the data in a table (may be 'users' with a status flag indicating they are not registered). But why rely on $_SERVER['REMOTE_ADDR'] (IPs aren't prone to duplicates, two or more users behind the same firewall?), where CakePHP automatically writes a 'CAKEPHP' (session, I think) cookie? I mean, a part from not being to access to its value, just like me :-) ... Best, Mario On 2 Dic, 05:10, nurvzy nur...@gmail.com wrote: Hi Mario, Well, if you want to use Sessions or Cookies I suggest reading the book on the two. The problem you'll face is both cookie and session are client based objects. So you can set all the sessions and cookies you want but you'll need a way to store them somewhere in either your server memory or a database so *you* can see it. I suggest ditching the Session/Cookie idea and go with a database or flat-file. The way I've tracked users in the past is create a database table ('onlines' for me). Then in my Online model I just create a little method that delete's all entries greater than 10 minutes modified. I then pass in $this-here to my Online's createOrUpdateUser model function, this is all in my beforeFilter() in my app_controller.php //app_controller beforeFilter() $this-Online-update(); $this-Online-createOrUpdateUser($this-here); In createOrUpdateUser($currentPage = null) I use the IP ( $_SERVER ['REMOTE_ADDR'] ) as the key and just update/create where the user currently is in the app $this-here in the app_controller. This gives me a nice little Online table that I can look at to see who's online (for the last 10 minutes). Hope that helps, Nick On Dec 1, 11:50 am, Mario mario.calli...@gmail.com wrote: Hi all, I am dealing with unregistered users (no Auth login) and I want to track them from page to page using sessions. I see in my browser a cookie named 'CAKEPHP' and I thought I could read it in a controller with $this-Cookie-read(Configure::read('Session.cookie')) [where in my config/core.php I have Configure::write('Session.cookie', 'CAKEPHP');] But it doesn't work, I get nothing. Any hint or alternative method I could implement? Thank you in advance. Best, Mario Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: TreeBehavior fails to set lft and rght correctly
Top of the model is : class MenuItem extends AppModel { var $name = 'MenuItem'; var $actsAs = array('Tree', 'Containable'); the table : CREATE TABLE `menu_items` ( `id` int(11) NOT NULL auto_increment, `parent_id` int(11) default NULL, `lft` int(11) default NULL, `rght` int(11) default NULL, `label` varchar(255) NOT NULL, `url` varchar(255) NOT NULL, `online` int(1) NOT NULL, `order` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; Are you suggesting that I should add a belongTo to this model? (belongsTo itself?) On 3 déc, 01:02, Dave davidcr...@gmail.com wrote: Also, these two suggestions were in the comments. I didn't need the relationship from the first one but I am using the latest svn checkout, so perhaps he was posting that from an older version. Also the second one might be useful as well. The model needs a relation for me to work with this example. If I add the following to the model it works: pre var $belongsTo = array( 'Parent' =gt; array( 'className' =gt; 'Category', 'foreignKey' =gt; 'parent_id', 'conditions' =gt; '', 'fields' =gt; '', 'order' =gt; '', 'counterCache' =gt; ''), ); /pre By etipaced on 30/9/08 2 #comment_391 - bug/glitch/feature? I just spent a lot of time troubleshooting an odd issue. Make sure your id, lft and rght columns are set to just UNSIGNED and not UNSIGNED ZEROFILL. I like to use the ZEROFILL attribute on all my integer column types that store id values but the TreeBehavior fails without any warnings or errors if the integer column values are in the format of 0001 instead of just 1. On Wed, Dec 2, 2009 at 7:00 PM, Dave davidcr...@gmail.com wrote: Can you paste your model? Or at least the important parts at the top? On Wed, Dec 2, 2009 at 6:19 PM, Martin Kirchgessner martin.ki...@gmail.com wrote: Hi everyone, I'm using TreeBehavior in a classic model, but its lft and rght fields are not set correctly. I tried these two save() in a controller : $this-MenuItem-create(); $this-MenuItem-save(array('MenuItem' = array( 'url' = '/fre', 'parent_id' = null, 'label' = 'Home', 'online' = 1 ))); $parent_id = $this-MenuItem-id; debug($this-MenuItem-verify()); $this-MenuItem-create(); $this-MenuItem-save(array('MenuItem' = array( 'url' = '/fre/p/Choses', 'parent_id' = $parent_id, 'label' = 'Choses', 'online' = 1 ))); debug($this-MenuItem-verify()); debug($this-MenuItem-recover()); debug($this-MenuItem-verify()); die(); I truncated the table menu_items, ran the test and discovered that the two last calls to verify() fail, even after recover(). I followed the cookbook... but did I miss something? If it can helps : I'm running Cake 1.2.3.8166 I also tried to download the last TreeBehavior from cake's master branch, but it didn't change anything thanks! Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Containable query
Hmm... nobody have any ideas? On Tue, Nov 24, 2009 at 4:05 PM, Bryan Paddock bryanpadd...@gmail.comwrote: Hey all, I have this relationship in question: User - hasOne Student - hasMany Submission I'm a bit stumped on how I can fetch all the users who do not have any submissions linked to their name. I've tried: $list = $this-User-find('all', array( 'contain' = array( 'Student' = array( 'Submission' = array( 'conditions' = array( 'Submission.student_id' = null ) ), ) ) )); I have the actAs in the model so the containable behaviour is functioning - there is just a problem with my specific query. Any ideas? thanks! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: trying to Implement ajax stream of new blog post every 5 seconds
On Tue, Dec 1, 2009 at 2:58 AM, Casmit chav...@gmail.com wrote: I'm trying to implement a feature on our website where the page displays the latest 10 blog post through an ajax stream. Every 5 seconds, new post appear in the list and the older post fall off.. Any links/info on how this can be done? You can achieve this doing 5 sec periodic ajax calls to an action that retrieves the lastest posts added. Without a doubt you'll must use remoteTimer function to do this[1]. But first, take a look on how ajax calls works in CakePHP[2]. [1] http://book.cakephp.org/view/627/remoteTimer [2] http://book.cakephp.org/view/208/AJAX Best regards. -- MARCELO DE F. ANDRADE Belem, PA, Amazonia, Brazil Linux User #221105 Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: commands out of sync error
On Wed, Dec 2, 2009 at 4:44 AM, mahesh babu maheshbabu...@gmail.com wrote: hi, I have attatched screenshot regarding my error.Here i am used flex with php. plz help me Give us some information context to help you. I program PHP in Linux, barely used Flex, don't know nothing about your SQL query neither it was clear for me what CakePHP has to do in that case. Best regards. -- MARCELO DE F. ANDRADE Belem, PA, Amazonia, Brazil Linux User #221105 Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: How can I get the current session?
Hi Mario, I've repackaged my little who's online utility as a plugin. It works well enough for my purposes basing off IP, its easy to track test and get at easily. /shrug If you're interested, I wrote about it: http://www.webtechnick.com/blogs/view/227/CakePHP_Who_s_Online_Plugin You can dig around in the source to see how it works, if you come up with a better way feel free to add to it/etc... =) Nick On Dec 2, 11:08 am, Mario mario.calli...@gmail.com wrote: Hi Nick, thank you for your reply, very interesting suggestion for the who's online feature. And yes, once I get hold of who is browsing, I want to store the data in a table (may be 'users' with a status flag indicating they are not registered). But why rely on $_SERVER['REMOTE_ADDR'] (IPs aren't prone to duplicates, two or more users behind the same firewall?), where CakePHP automatically writes a 'CAKEPHP' (session, I think) cookie? I mean, a part from not being to access to its value, just like me :-) ... Best, Mario On 2 Dic, 05:10, nurvzy nur...@gmail.com wrote: Hi Mario, Well, if you want to use Sessions or Cookies I suggest reading the book on the two. The problem you'll face is both cookie and session are client based objects. So you can set all the sessions and cookies you want but you'll need a way to store them somewhere in either your server memory or a database so *you* can see it. I suggest ditching the Session/Cookie idea and go with a database or flat-file. The way I've tracked users in the past is create a database table ('onlines' for me). Then in my Online model I just create a little method that delete's all entries greater than 10 minutes modified. I then pass in $this-here to my Online's createOrUpdateUser model function, this is all in my beforeFilter() in my app_controller.php //app_controller beforeFilter() $this-Online-update(); $this-Online-createOrUpdateUser($this-here); In createOrUpdateUser($currentPage = null) I use the IP ( $_SERVER ['REMOTE_ADDR'] ) as the key and just update/create where the user currently is in the app $this-here in the app_controller. This gives me a nice little Online table that I can look at to see who's online (for the last 10 minutes). Hope that helps, Nick On Dec 1, 11:50 am, Mario mario.calli...@gmail.com wrote: Hi all, I am dealing with unregistered users (no Auth login) and I want to track them from page to page using sessions. I see in my browser a cookie named 'CAKEPHP' and I thought I could read it in a controller with $this-Cookie-read(Configure::read('Session.cookie')) [where in my config/core.php I have Configure::write('Session.cookie', 'CAKEPHP');] But it doesn't work, I get nothing. Any hint or alternative method I could implement? Thank you in advance. Best, Mario Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
HABTM questions
I've been scouring the web for a while trying to figure this out. My brain is fried, so I need some help. I have a model called Containers, a model called Assets and HABTM table called AssetsContainer. So a container can have many assets. The first question I have is when I'm doing this operation $this-Container-read(null,$id); How do I paginate the assets. right now I am only testing so there's only 2 assets linked to the container. Am I assuming right that there would be an endless number of assets? If not, still, how do I paginate this data? Next question is, each asset can be one of three different tables, Photos, Profiles, Blogs. Each of these models has a hasOne relationship of asset_id in each model. How do I get the read() function to retrieve this data automatically? My first instinct is to put a nominal field for each potential table of photo_id, profile_id and blog_id and update the model for Asset with the hasOne of each.. This way it will grab the data right? Also, is this an instance where instead of read, I use find('all') instead? Many thanks, Alan Example of my Container-read below Array ( [Container] = Array ( [id] = 1 [user_id] = 1 [title] = Default [total_items] = [mime_type] = image [photo_id] = 1 [created] = 2009-12-02 11:53:21 [modified] = 2009-12-02 11:53:21 [is_fan_club] = 0 [fan_club_requirements] = [nsfw] = 0 [ordering] = [active] = [deleted] = ) [User] = Array ( [id] = 1 [user_type_id] = 2 [user_group_id] = 3 [username] = user [email] = [name] = [gender_id] = 1 [password] = [salt] = [birthday] = 1991-11-23 [created] = 2009-11-23 21:41:24 [modified] = 2009-11-24 15:24:59 ) [Photo] = Array ( [id] = 1 [user_id] = 1 [asset_id] = 15 [created] = 1259625133 [modified] = 1259625133 [title] = [deleted] = [file_name] = c0a80aa6-5aab-f111.jpg [rel_path] = users/1/2009/11 [caption] = [server_id] = 1 [is_featured] = ) [Asset] = Array ( [0] = Array ( [id] = 1 [asset_type_id] = [user_id] = [created] = 2009-11-30 16:12:05 [modified] = 2009-11-30 16:12:05 [ordering] = 0 [allow_comments] = 1 [allow_rates] = 1 [nsfw] = 0 [total_views] = 0 [total_rates] = 0 [total_rating] = 0 [total_comments] = 0 [AssetsContainer] = Array ( [id] = 1 [asset_id] = 1 [container_id] = 1 [ordering] = 1 [created] = [modified] = ) ) [1] = Array ( [id] = 2 [asset_type_id] = [user_id] = [created] = 2009-11-30 16:13:47 [modified] = 2009-11-30 16:13:47 [ordering] = 0 [allow_comments] = 1 [allow_rates] = 1 [nsfw] = 0 [total_views] = 0 [total_rates] = 0 [total_rating] = 0 [total_comments] = 0 [AssetsContainer] = Array ( [id] = 2 [asset_id] = 2 [container_id] = 1 [ordering] = 2 [created] = [modified] = ) ) ) ) Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Populating field from session variables
at some point you must save the posted data to the session variable and set the variable for use in the view template. once you do that do echo $form-input('name', $options = array('value' = $data['name'])); in the view template and where $data is a variable that contains the data from the session that you would set in a controller action something like that. please check the cakephp docs on how to set values for input elements and other elements. I am pretty sure you set an array to $options, but I havent double checked Hope that helps On Dec 1, 11:54 pm, nashrul anas_a...@yahoo.com wrote: Sorry, I didn't think you get my message... What I want is, when user is in the edit page... the form in edit page will be populated with the values from session variables..So I created the form in ediit.ctp file like this : //app/views/persons/edit.ctp h1Edit Person/h1 ? ? echo $form-create('Person'); echo $form-input('name'); echo $form-input('pob'); echo $form-input('dob'); echo $form-input('address'); echo $form-end('Save'); ? Those form fields (name, pob, dob, address) will be automatically populated with the values from session variables. Maybe in the standard form field it should be like this: //app/views/persons/edit.ctp echo INPUT TYPE='text' NAME='name' value=$_SESSION['person.name']; echo INPUT TYPE='text' NAME='name' value=$_SESSION['person.pob']; echo INPUT TYPE='text' NAME='name' value=$_SESSION['person.dob']; echo INPUT TYPE='text' NAME='name' value=$_SESSION['person.address']; How can I do this using form helper ?? Thanks.. Saliem wrote: sorry: $this-set('data', $this-Session-read('session_variable_name')); On Dec 1, 8:46 pm, Saliem than.sal...@gmail.com wrote: $this-set('data', $this-data); OR $this-ser('data', $this-Session-read('session_variable_name')); something along these lines On Dec 1, 7:05 pm, nashrul anas_a...@yahoo.com wrote: HI, I'm new to cakephp I'm trying to populate form fields from the session variables.. I have a scenario like this. 1. User fills the form. When the user clicks next button, form fields are saved to the session variable. 2. User is displayed with the data he entered before to confirm. 3. If the data is correct, it proceeds to save the data. otherwise, it will display edit page. In edit page, form fields will be populated by the data from the session variables. If the process finishes, user will go the confirmation page, and repeats step 2. 4. when user confirms the data, set method in the model is called and save method is called. In step 3, how can I populate form fields from the session variables ?.. I've read about form and html helpers, and the documentation says that html helper is deprecated.. so I look to form helper. In form helper, afaik, there's no way to set form fields from variables.. Correct me if I was wrong.or somebody has a better idea to solve my problem ?? Thanks... I use cakephp 1.2 -- View this message in context:http://old.nabble.com/Populating-field-from-session-variables-tp26601... Sent from the CakePHP mailing list archive at Nabble.com. Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en -- View this message in context:http://old.nabble.com/Populating-form-fields-from-session-variables-t... Sent from the CakePHP mailing list archive at Nabble.com. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Populating field from session variables
sorry correction : echo $form-input('name', $options = array('value' = $data ['name'])); On Dec 2, 7:39 pm, Saliem than.sal...@gmail.com wrote: at some point you must save the posted data to the session variable and set the variable for use in the view template. once you do that do echo $form-input('name', $options = array('value' = $data['name'])); in the view template and where $data is a variable that contains the data from the session that you would set in a controller action something like that. please check the cakephp docs on how to set values for input elements and other elements. I am pretty sure you set an array to $options, but I havent double checked Hope that helps On Dec 1, 11:54 pm, nashrul anas_a...@yahoo.com wrote: Sorry, I didn't think you get my message... What I want is, when user is in the edit page... the form in edit page will be populated with the values from session variables..So I created the form in ediit.ctp file like this : //app/views/persons/edit.ctp h1Edit Person/h1 ? ? echo $form-create('Person'); echo $form-input('name'); echo $form-input('pob'); echo $form-input('dob'); echo $form-input('address'); echo $form-end('Save'); ? Those form fields (name, pob, dob, address) will be automatically populated with the values from session variables. Maybe in the standard form field it should be like this: //app/views/persons/edit.ctp echo INPUT TYPE='text' NAME='name' value=$_SESSION['person.name']; echo INPUT TYPE='text' NAME='name' value=$_SESSION['person.pob']; echo INPUT TYPE='text' NAME='name' value=$_SESSION['person.dob']; echo INPUT TYPE='text' NAME='name' value=$_SESSION['person.address']; How can I do this using form helper ?? Thanks.. Saliem wrote: sorry: $this-set('data', $this-Session-read('session_variable_name')); On Dec 1, 8:46 pm, Saliem than.sal...@gmail.com wrote: $this-set('data', $this-data); OR $this-ser('data', $this-Session-read('session_variable_name')); something along these lines On Dec 1, 7:05 pm, nashrul anas_a...@yahoo.com wrote: HI, I'm new to cakephp I'm trying to populate form fields from the session variables.. I have a scenario like this. 1. User fills the form. When the user clicks next button, form fields are saved to the session variable. 2. User is displayed with the data he entered before to confirm. 3. If the data is correct, it proceeds to save the data. otherwise, it will display edit page. In edit page, form fields will be populated by the data from the session variables. If the process finishes, user will go the confirmation page, and repeats step 2. 4. when user confirms the data, set method in the model is called and save method is called. In step 3, how can I populate form fields from the session variables ?.. I've read about form and html helpers, and the documentation says that html helper is deprecated.. so I look to form helper. In form helper, afaik, there's no way to set form fields from variables.. Correct me if I was wrong.or somebody has a better idea to solve my problem ?? Thanks... I use cakephp 1.2 -- View this message in context:http://old.nabble.com/Populating-field-from-session-variables-tp26601... Sent from the CakePHP mailing list archive at Nabble.com. Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en -- View this message in context:http://old.nabble.com/Populating-form-fields-from-session-variables-t... Sent from the CakePHP mailing list archive at Nabble.com. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Populating field from session variables
correction echo $form-input('name', $options = array('value' = $data ['name'])); On Dec 2, 7:39 pm, Saliem than.sal...@gmail.com wrote: at some point you must save the posted data to the session variable and set the variable for use in the view template. once you do that do echo $form-input('name', $options = array('value' = $data['name'])); in the view template and where $data is a variable that contains the data from the session that you would set in a controller action something like that. please check the cakephp docs on how to set values for input elements and other elements. I am pretty sure you set an array to $options, but I havent double checked Hope that helps On Dec 1, 11:54 pm, nashrul anas_a...@yahoo.com wrote: Sorry, I didn't think you get my message... What I want is, when user is in the edit page... the form in edit page will be populated with the values from session variables..So I created the form in ediit.ctp file like this : //app/views/persons/edit.ctp h1Edit Person/h1 ? ? echo $form-create('Person'); echo $form-input('name'); echo $form-input('pob'); echo $form-input('dob'); echo $form-input('address'); echo $form-end('Save'); ? Those form fields (name, pob, dob, address) will be automatically populated with the values from session variables. Maybe in the standard form field it should be like this: //app/views/persons/edit.ctp echo INPUT TYPE='text' NAME='name' value=$_SESSION['person.name']; echo INPUT TYPE='text' NAME='name' value=$_SESSION['person.pob']; echo INPUT TYPE='text' NAME='name' value=$_SESSION['person.dob']; echo INPUT TYPE='text' NAME='name' value=$_SESSION['person.address']; How can I do this using form helper ?? Thanks.. Saliem wrote: sorry: $this-set('data', $this-Session-read('session_variable_name')); On Dec 1, 8:46 pm, Saliem than.sal...@gmail.com wrote: $this-set('data', $this-data); OR $this-ser('data', $this-Session-read('session_variable_name')); something along these lines On Dec 1, 7:05 pm, nashrul anas_a...@yahoo.com wrote: HI, I'm new to cakephp I'm trying to populate form fields from the session variables.. I have a scenario like this. 1. User fills the form. When the user clicks next button, form fields are saved to the session variable. 2. User is displayed with the data he entered before to confirm. 3. If the data is correct, it proceeds to save the data. otherwise, it will display edit page. In edit page, form fields will be populated by the data from the session variables. If the process finishes, user will go the confirmation page, and repeats step 2. 4. when user confirms the data, set method in the model is called and save method is called. In step 3, how can I populate form fields from the session variables ?.. I've read about form and html helpers, and the documentation says that html helper is deprecated.. so I look to form helper. In form helper, afaik, there's no way to set form fields from variables.. Correct me if I was wrong.or somebody has a better idea to solve my problem ?? Thanks... I use cakephp 1.2 -- View this message in context:http://old.nabble.com/Populating-field-from-session-variables-tp26601... Sent from the CakePHP mailing list archive at Nabble.com. Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en -- View this message in context:http://old.nabble.com/Populating-form-fields-from-session-variables-t... Sent from the CakePHP mailing list archive at Nabble.com. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
$this-User-modelA-save doesn't key modelA properly
User has many ModelA So in the ModelA Controller, I replaced every $this-ModelA with $this- User-ModelA so every action done is user specific. The index action successfully shows only that users ModelA's, however the add() action creates ModelA with user_id = 0 everytime. If this is the intended functionality, then how do you manage users on yours sites that have their own exclusive instances of a model. I could just.. search the users for the one currently logged in, and manually place the foreign_key in.. but I'd like to think this kind of behaviour is natural given the rest of the framework's automagic. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: commands out of sync error
Thaq for ur response. i have called stored procedure from business layer(fnction name execute()) like this $sql = CALL sp_viewAllDivisions('.$_SESSION[organisationSID].');; The stored procedure like this: CREATE definer=`ro...@`localhost` PROCEDURE `sp_viewAllDivisions`(org_id int(11)) begin SELECT D.id_div, D.name_div, D.desc_div, D.active_div, D.modified_by, D.modified_date, E.fname_employee, E.lname_employee FROM light_division AS D, light_employee AS E, light_org AS O WHERE D.modified_by = E.id_employee AND D.id_org = org_id ORDER BY D.id_div DESC; end The screenshot i have attatched is sevice browser from amfphp. If i run the method from service browser i got that error. if i am writing sql query instead of stored procedure in business layer it is working fine.I did not get any error. plz help me Regards D.Mahesh Babu On Thu, Dec 3, 2009 at 7:27 AM, Marcelo Andrade mfandr...@gmail.com wrote: On Wed, Dec 2, 2009 at 4:44 AM, mahesh babu maheshbabu...@gmail.com wrote: hi, I have attatched screenshot regarding my error.Here i am used flex with php. plz help me Give us some information context to help you. I program PHP in Linux, barely used Flex, don't know nothing about your SQL query neither it was clear for me what CakePHP has to do in that case. Best regards. -- MARCELO DE F. ANDRADE Belem, PA, Amazonia, Brazil Linux User #221105 Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
How to get two input fields in same line?
Hi all How can I get two input fields in same line in cakephp? By default each input field are coming in seperate line. How can we put a space and bring it in same line. Please help.. Thanking You Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: How to get two input fields in same line?
can u show me the code for both line Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Here is my database schema,please peovide me model for his.
Hi john, No... here is table script attached... please take a look at it...u wil get an idea... Cheers: Anand On Wed, Dec 2, 2009 at 4:46 PM, John Andersen j.andersen...@gmail.comwrote: Looks confusing, sorry :) Trying to transform your tables into a workable ER model (not CakePHP model): A user may have one or more phone numbers A user may have one or more addresses Each phone number belongs to one user Each address belongs to one user An address may have one or more details A detail belongs to one address Tables: users - id (primary key, auto number) - other necessary columns that you may require. - created - modified phonenumbers - id (primary key, auto number) - user_id (foreign key to table users) - other necessary columns that you may require. - created - modified addresses - id (primary key, auto number) - user_id (foreign key to table users) - other necessary columns that you may require. - created - modified addressdetails - id (primary key, auto number) - address_id (foreign key to table addresses) - other necessary columns that you may require. - created - modified Do I understand your schema correctly? John On Dec 2, 11:11 am, anand angadi anuang...@gmail.com wrote: Hi John, Sorry here its attached now... Cheers: Anand shcema.bmp 1299KViewDownload Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en main.sql Description: Binary data
Re: How to get two input fields in same line?
Hi, This may help you... table width=100% border=0 cellspacing=4 cellpadding=0 class=content tr td align=right class=contentUserName : nbsp;/td td?php echo $form-input('username',array('label'=false)); ?/td td align=right class=contentPassword : nbsp;/td td?php echo $form-input('password',array('label'=false)); ?/td /tr /table Cheers: Anand On Thu, Dec 3, 2009 at 11:05 AM, cake dhanya@gmail.com wrote: Hi all How can I get two input fields in same line in cakephp? By default each input field are coming in seperate line. How can we put a space and bring it in same line. Please help.. Thanking You Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: How to get two input fields in same line?
You could also do this: ?php echo $form-input('User.name', array('div' = false));? You could do your own surrounding div, then two inputs with div = false; in other words, take case of the divs yourself. On Dec 3, 5:46 am, anand angadi anuang...@gmail.com wrote: Hi, This may help you... table width=100% border=0 cellspacing=4 cellpadding=0 class=content tr td align=right class=contentUserName : nbsp;/td td?php echo $form-input('username',array('label'=false)); ?/td td align=right class=contentPassword : nbsp;/td td?php echo $form-input('password',array('label'=false)); ?/td /tr /table Cheers: Anand On Thu, Dec 3, 2009 at 11:05 AM, cake dhanya@gmail.com wrote: Hi all How can I get two input fields in same line in cakephp? By default each input field are coming in seperate line. How can we put a space and bring it in same line. Please help.. Thanking You Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.c omFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Help accessing array from HABTM relationship
I have spread your array out so I can see its layout. I *think* you'd need to do a foreach loop on users too. On Dec 3, 12:02 am, Casmit chav...@gmail.com wrote: I have a table called Group that has a HABTM relationship to table Points. Group also has a HABTM relationship to Users. Groups_Points table manages this relationship. I can run a $thisPointGroupfindAll command and get an array that looks like this: Array ( [0] = Array ( [Group] = Array ( [id] = 1 [user_ID] = 1 [name] = Dallas Photogs [pic1] = [created] = 2009-12-01 21:23:15 [Moderate] = 0 ) [Point] = Array ( [0] = Array ( [id] = 1 [title] = Dallas, Texas [description] = dallas [user_ID] = 1 [type] = City [address] = 101 main st. dallas, tx [city] = dallas [state] = TX [zip] = 76010 [GroupsPoint] = Array ( [id] = 1 [group_id] = 1 [point_id] = 1 [created] = 2009-12-02 14:36:10 [modified] = 2009-12-02 14:36:10 ) ) ) [User] = Array ( [0] = Array ( [id] = 1 [username] = John [email] = j...@gmail.com [password] = 79467e27a472 [first_name] = John [last_name] = Smith [created] = 2009-11-24 23:15:16 [modified] = 2009-11-29 01:00:26 [GroupsUser] = Array ( [id] = 1 [group_id] = 1 [user_id] = 1 [admin] = 1 [created] = 2009-12-02 14:36:10 [modified] = 2009-12-02 14:36:10 ) ) ) ) ) I can do a foreach command in the view i.e. $groups as $group and access Group.Name as $group['Group']['name']. What's the best way to access the User.name data in this array. $group ['User']['username'] results in index not found...I see it's nested one level deep. Thanks for the advice in advance! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Here is my database schema,please peovide me model for his.
Sorry to say Anand, but your schema does not conform to what CakePHP expects, which makes it difficult to make it work with CakePHP, without specifying a lot of information. Suggest you rethink your schema, so that: 1) It conforms to CakePHP (table names plural, foreign keys equal foreign key table name singular + underscore + 'id', etc.; 2) Makes use of primary key auto numbering; 3) Each table has its own primary key (id) - not depending on another tables primary key (id); 4) Tinyint is only for boolean columns (true/false)! This will make it a lot easier to use by CakePHP and for the future maintenance! I myself would not consider using your schema! Use my previous post as a base for replanning your schema. Enjoy, John On Dec 3, 7:42 am, anand angadi anuang...@gmail.com wrote: Hi john, No... here is table script attached... please take a look at it...u wil get an idea... Cheers: Anand On Wed, Dec 2, 2009 at 4:46 PM, John Andersen j.andersen...@gmail.comwrote: Looks confusing, sorry :) Trying to transform your tables into a workable ER model (not CakePHP model): A user may have one or more phone numbers A user may have one or more addresses Each phone number belongs to one user Each address belongs to one user An address may have one or more details A detail belongs to one address Tables: users - id (primary key, auto number) - other necessary columns that you may require. - created - modified phonenumbers - id (primary key, auto number) - user_id (foreign key to table users) - other necessary columns that you may require. - created - modified addresses - id (primary key, auto number) - user_id (foreign key to table users) - other necessary columns that you may require. - created - modified addressdetails - id (primary key, auto number) - address_id (foreign key to table addresses) - other necessary columns that you may require. - created - modified Do I understand your schema correctly? John On Dec 2, 11:11 am, anand angadi anuang...@gmail.com wrote: Hi John, Sorry here its attached now... Cheers: Anand shcema.bmp 1299KViewDownload Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en main.sql 5KViewDownload Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Here is my database schema,please peovide me model for his.
Hi john, Thanks a lot for your valuable result...will do accordingly... Cheers: Anand On Thu, Dec 3, 2009 at 11:52 AM, John Andersen j.andersen...@gmail.comwrote: Sorry to say Anand, but your schema does not conform to what CakePHP expects, which makes it difficult to make it work with CakePHP, without specifying a lot of information. Suggest you rethink your schema, so that: 1) It conforms to CakePHP (table names plural, foreign keys equal foreign key table name singular + underscore + 'id', etc.; 2) Makes use of primary key auto numbering; 3) Each table has its own primary key (id) - not depending on another tables primary key (id); 4) Tinyint is only for boolean columns (true/false)! This will make it a lot easier to use by CakePHP and for the future maintenance! I myself would not consider using your schema! Use my previous post as a base for replanning your schema. Enjoy, John On Dec 3, 7:42 am, anand angadi anuang...@gmail.com wrote: Hi john, No... here is table script attached... please take a look at it...u wil get an idea... Cheers: Anand On Wed, Dec 2, 2009 at 4:46 PM, John Andersen j.andersen...@gmail.com wrote: Looks confusing, sorry :) Trying to transform your tables into a workable ER model (not CakePHP model): A user may have one or more phone numbers A user may have one or more addresses Each phone number belongs to one user Each address belongs to one user An address may have one or more details A detail belongs to one address Tables: users - id (primary key, auto number) - other necessary columns that you may require. - created - modified phonenumbers - id (primary key, auto number) - user_id (foreign key to table users) - other necessary columns that you may require. - created - modified addresses - id (primary key, auto number) - user_id (foreign key to table users) - other necessary columns that you may require. - created - modified addressdetails - id (primary key, auto number) - address_id (foreign key to table addresses) - other necessary columns that you may require. - created - modified Do I understand your schema correctly? John On Dec 2, 11:11 am, anand angadi anuang...@gmail.com wrote: Hi John, Sorry here its attached now... Cheers: Anand shcema.bmp 1299KViewDownload Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.com cake-php%2bunsubscr...@googlegroups.comcake-php%252bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en main.sql 5KViewDownload Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: $this-User-modelA-save doesn't key modelA properly
In your ModelA controller, you have to add the users id manually before invoking the ModelA save. If you are using Auth, then get the users id from $this-Auth-user ('id') /* From my memory */ and add it to the data array before invoking ModelA. By using $this-User-ModelA does not automatically add the users id to the data array! It only tells the Controller how to get to the ModelA. But anyway, the User model is not needed in the ModelA controller, only the ModelA model. Enjoy, John On Dec 3, 6:41 am, Christian cdamiani...@gmail.com wrote: User has many ModelA So in the ModelA Controller, I replaced every $this-ModelA with $this-User-ModelA so every action done is user specific. The index action successfully shows only that users ModelA's, however the add() action creates ModelA with user_id = 0 everytime. If this is the intended functionality, then how do you manage users on yours sites that have their own exclusive instances of a model. I could just.. search the users for the one currently logged in, and manually place the foreign_key in.. but I'd like to think this kind of behaviour is natural given the rest of the framework's automagic. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Complex Relationships
Ok :) Using your terms, the following may be defined: Owner hasMany Location, Location belongsTo Owner Location hasMany Room, Room belongsTo Location Category hasMany Room, Room belongsTo Category Room hasMany Booking, Booking belongsTo Room Renter hasMany Booking, Booking belongsTo Renter Where: Owner owns one or more locations, each with one or more rooms. Location is a building, a camping field, whatever Category gives the basic information on each room Room defines a bookable room in a location Renter makes a booking of a room. Booking defines the actual request for a room. Booking also is used for tracking the reply from the owner (status field) and final price (price settled, price_type). Database schema would be something like: Booking (id, room_id, renter_id, arrival, departure, status, message, price_type, price_settled, created, modified) Location (id, owner_id, address, created) Category (id, name, price_daily, price_weekly, price_forthnight, price_monthly, occupants, created) Room (id, location_id, category_id, description, created) Well, the above is only ideas, so take what you can use! Probably you also need something in which to track that the payment has been made. Enjoy, John On Dec 2, 10:31 pm, onlymejosh star...@gmail.com wrote: These are the objects Renter, Owner, Room, Booking The number of guests isn't a factor. The booking invovles one room at a time. Its not a normal hotel per- say On Dec 2, 5:18 pm, John Andersen j.andersen...@gmail.com wrote: I see the following objects in your description: Renter, Guest, Room, Owner, Booking Can one room have more than one Guest per room? Can one booking involve more than one room? John On Dec 2, 5:42 pm, onlymejosh star...@gmail.com wrote: Hi, I need some guidance on how to build these model relationships. I need to build something that allows people to book a room in an accommodation. These are the steps. User finds room. User requests to stay in room Owner accepts / declines User Pays / finds another room. I have 3 tables so far. Members, Accommodations, BookingRequests At the moment I have the foreign key member_id in Accommodation. Do I need to add it to BookingRequest as well? This is what I store in each. Members id,email,password Accommodation id,member_id,title,room_type,price,price_week,price_month BookingRequests id,accommodation_id,checkin_date,checkout_date,message,read,member_id The relationships are. Members hasMany Accommodation Accommodation hasMany BookingRequest, belongsTo Member BookingRequest belongsTo Accommodation. Any suggestions? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: TreeBehavior fails to set lft and rght correctly
That was what the comment suggested and I was suggesting you try their suggestion =) I wish I could help more, as I said, I didn't need to specify anything different then what you are using, but I am also using the latest svn checkout. I thought perhaps the comment was regarding an older version (hence why you may need to do it but its not in the docs). Just a thought, wish I could help more, good luck! On Wed, Dec 2, 2009 at 7:19 PM, Martin Kirchgessner martin.ki...@gmail.comwrote: Top of the model is : class MenuItem extends AppModel { var $name = 'MenuItem'; var $actsAs = array('Tree', 'Containable'); the table : CREATE TABLE `menu_items` ( `id` int(11) NOT NULL auto_increment, `parent_id` int(11) default NULL, `lft` int(11) default NULL, `rght` int(11) default NULL, `label` varchar(255) NOT NULL, `url` varchar(255) NOT NULL, `online` int(1) NOT NULL, `order` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; Are you suggesting that I should add a belongTo to this model? (belongsTo itself?) On 3 déc, 01:02, Dave davidcr...@gmail.com wrote: Also, these two suggestions were in the comments. I didn't need the relationship from the first one but I am using the latest svn checkout, so perhaps he was posting that from an older version. Also the second one might be useful as well. The model needs a relation for me to work with this example. If I add the following to the model it works: pre var $belongsTo = array( 'Parent' =gt; array( 'className' =gt; 'Category', 'foreignKey' =gt; 'parent_id', 'conditions' =gt; '', 'fields' =gt; '', 'order' =gt; '', 'counterCache' =gt; ''), ); /pre By etipaced on 30/9/08 2 #comment_391 - bug/glitch/feature? I just spent a lot of time troubleshooting an odd issue. Make sure your id, lft and rght columns are set to just UNSIGNED and not UNSIGNED ZEROFILL. I like to use the ZEROFILL attribute on all my integer column types that store id values but the TreeBehavior fails without any warnings or errors if the integer column values are in the format of 0001 instead of just 1. On Wed, Dec 2, 2009 at 7:00 PM, Dave davidcr...@gmail.com wrote: Can you paste your model? Or at least the important parts at the top? On Wed, Dec 2, 2009 at 6:19 PM, Martin Kirchgessner martin.ki...@gmail.com wrote: Hi everyone, I'm using TreeBehavior in a classic model, but its lft and rght fields are not set correctly. I tried these two save() in a controller : $this-MenuItem-create(); $this-MenuItem-save(array('MenuItem' = array( 'url' = '/fre', 'parent_id' = null, 'label' = 'Home', 'online' = 1 ))); $parent_id = $this-MenuItem-id; debug($this-MenuItem-verify()); $this-MenuItem-create(); $this-MenuItem-save(array('MenuItem' = array( 'url' = '/fre/p/Choses', 'parent_id' = $parent_id, 'label' = 'Choses', 'online' = 1 ))); debug($this-MenuItem-verify()); debug($this-MenuItem-recover()); debug($this-MenuItem-verify()); die(); I truncated the table menu_items, ran the test and discovered that the two last calls to verify() fail, even after recover(). I followed the cookbook... but did I miss something? If it can helps : I'm running Cake 1.2.3.8166 I also tried to download the last TreeBehavior from cake's master branch, but it didn't change anything thanks! Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.com cake-php%2bunsubscr...@googlegroups.comcake-php%252bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check
Re: Any chance to get the ID of a new created record BEFORE I save it to the DB?
@Miles J Your idea won't work with mysql and id field as autoincrement (dunno how with other db but i assume that can be the same). If you have 100 rows with id from 1 to 100 and you will delete last 5 (from 96 to 100), then doing insert new rown you will get id 101, not 96. @DigitalDude Please take a look at http://blog.jamiedoris.com/geek/560/ Best Regards, Miro On Dec 3, 12:40 am, Miles J mileswjohn...@gmail.com wrote: Its impossible to get the ID for a row your about to save, until after you save it. The most you can do is do a query to select the last row in the table, then increment its ID by one. On Dec 2, 2:18 pm, Dave davidcr...@gmail.com wrote: I think this would really help your situation http://bakery.cakephp.org/articles/view/wizard-component-1-2-1 I have used it in the past and if you read the documentation thoroughly it is very easy to implement. On Wed, Dec 2, 2009 at 1:05 PM, DigitalDude e.blumsten...@googlemail.comwrote: Hey, I have a serious problem, and I need a hint from you guys to solve it! In one of my controller actions, I have the problem that I need to create some records , let's say A, B, and C. The problem is, that record A needs a field from record B, which is the ID of record B, and which I only can set when record A is saved, and B is saved. In model C I need some information from the new created models A and B, which I only have when model A and B are saved. As this has to do with a register-process for my app, I need to validate the data for all models. The problem is, that when model A passes validation, and get's saved (which is needed to save the other models) and model B fails, I have a never used record of model A in my database. I need to get around that, because that's like a worst case for me! I hope there's any chance to create a record, set this record with the data I get from my registration form, and use the data for the other records and save everything at the end of the action when every record validates! I know I can check a record for validation by setting the model data with $this-Model-set($this-data) and then if($this-Model-validates()) { save the record(s) } But right now I'm only able to do this when I have an edit action and I set the Model to a specific record with like $this-Model-id = $id_from_get_parameter_or_so It would be VERY cool if there is a slight chance that I could create a new record with current auto-increment id from the database, use that id for my other models, and at the end when I created all needed records I'd check every record for validation and if every record is ok, they all get saved. If anyone knows how to achieve this, I would be very very happy! Cheers, DD P.S.: If needed, I can post the code of the whole RequestAction to see if maybe there's another solution to this... Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en