[symfony-users] Re: Propel and 1:1 relationships
Hey Crafty, glad to hear you found a solution. I get what you're trying to do, I guess I was just a little unclear on the term 1-to-1 relationship. I may be wrong on this, but it seems to me there is no such thing as a 1-to-1 relationship in a propel model.. after all, the Record model has a foreign key pointing to a record in the RecordCriteria model, correct? Now, technically you could have many Records pointing to the same RecordCriteria, and this would give you a 1-to-many relationship.. At least nothing in the datamodel restricts a 1-to-1 relationship. In my opinion, when you have a 1-to-1 relationship of data, the data should really be in the very same model. Does that make sense, or am I going wrong somethere? Have a good night everybody, Daniel On May 22, 5:38 am, Crafty_Shadow vankat...@gmail.com wrote: Ok, I managed to write a static method for the Peer class that does exactly what I need, thanks for the help. I'm going to post it here: public static function doSelectJoinRecordCriteria(Criteria $criteria, PropelPDO $con = null) { $criteria = clone $criteria; RecordPeer::addSelectColumns($criteria); // add columns of the Record object to the criteria $startcol = (RecordPeer::NUM_COLUMNS - RecordPeer::NUM_LAZY_LOAD_COLUMNS); // this will be used as offset to the RecordCriteria table columns later RecordCriteriaPeer::addSelectColumns($criteria); // add columns of the RecordCriteria $criteria-addJoin(RecordPeer::ID, RecordCriteriaPeer::ID); // join on ID $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt-fetch(PDO::FETCH_NUM)) { $primary_key = RecordPeer::getPrimaryKeyHashFromRow($row, 0); if (!$record_object = RecordPeer::getInstanceFromPool ($primary_key)) // check Propel's object pool for our Record object, and create it if it's not found { $record_object = new Record(); $record_object-hydrate($row); RecordPeer::addInstanceToPool($record_object, $primary_key); } $primary_key = RecordCriteriaPeer::getPrimaryKeyHashFromRow ($row, $startcol); // same as the record primary key, but I put it for clarification if (!$record_criteria_object = RecordCriteriaPeer::getInstanceFromPool($primary_key)) // this time check the pool for the RecordCriteria object and create if not found { $record_criteria_object = new RecordCriteria(); $record_criteria_object-hydrate($row, $startcol); RecordCriteriaPeer::addInstanceToPool($record_criteria_object, $primary_key); } $record_criteria_object-setRecord($record_object); // set the object relation $results[] = $record_object; } $stmt-closeCursor(); return $results; } On May 22, 2:25 pm, Gareth McCumskey gmccums...@gmail.com wrote: Taken from the Propel upgrade info for moving from propel 1.2 to 1.3 (http://propel.phpdb.org/trac/wiki/Users/Documentation/1.3/Upgrading): ?php // example of how to manually hydrate objects $stmt = AuthorPeer::doSelectStmt(new Criteria()); while($row = $stmt-fetch(PDO::FETCH_NUM)) { $a = new Author(); $a-hydrate($row); } On Fri, May 22, 2009 at 1:19 PM, Crafty_Shadow vankat...@gmail.com wrote: The manual hydration is the problem, I'm not really sure how to accomplish it On May 22, 8:11 am, Gareth McCumskey gmccums...@gmail.com wrote: You mentioned you manually created the join but the doSelect returns nothing. From my experience with Propel 1.2 you would need to use a doSelectRS to return the resultset. But in 1.3 you use doSelectStmt() to run your query with join and get aresaultset which you can then hydrate yourself manually. Would this help? On Thu, May 21, 2009 at 10:54 PM, Crafty_Shadow vankat...@gmail.com wrote: Thanks for the interest in my problem, Richtermister. The code I have shown above accounts only for a small part of my model, but I thought it would be sufficient to convey the point. There really isn't anything special about the Option 0,1,2,3,... etc, but I will provide you with as much information as I can considering the nature of the project Consider the following: The Record model accounts for a particular governmental system. It has the name and address of the person who submitted the request, an unique number, and a few other miscellaneous fields. There is a second model, RecordCriteria, tied in a 1:1 relationship with the first model. It has only boolean fields representing different sets of requirements that the applicant must meet, and a single float field that calculates the weight of the application, based on the requirements. There are MANY queries run on those 2 tables, and often a lot of records have to be displayed at once. Of course, this results in an additional query being executed for
[symfony-users] batch script +send email
Hi how we can send email in a batch script using sendEmail method.And how we can set request parameter for this.I am using symfony 1.0. Thanks, Kusum --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Re: backend
Yes. Check your executeIndex() from what i remember, executeIndex has a redirect to the list method. Alecs On Sat, May 23, 2009 at 1:50 AM, Lithium inmu...@gmail.com wrote: hi, i've generated admin using propel:generte-admin command, then show me a list with actions edit an delete for each record and i need a action that show the information by defaultit's possible?? -- I am on twitter: http://twitter.com/alecslupu I am on linkedIn: http://www.linkedin.com/in/alecslupu Tel: (+4)0748.543.798 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Re: How to access the object of an embedded form
Hi, First, I'm not sure that works : ?php foreach($form as $cartItemForm): ? tr td?php echo $cartItemForm['quantity']-renderLabel() ?/ td td?php echo $cartItemForm['quantity'] ?/td td/td /tr ?php endforeach; ? It doesn't match with what you wrote in your form, what do you have in your action file? You should have in your view something like that : ?php foreach($form-getEmbeddedForms() as $cartItemForm): ? tr td colspan=2?php echo $cartItemForm ?/td /tr ?php enforeach ? Second (this is a really special gift, I spend several weeks to find this tricks on the net, so I'm waiting for sf1.3 http://trac.symfony-project.org/ticket/5264) If you want to design your embedded forms you should use this code in the foreach : $nameFormat = $form-getWidgetSchema()-generateName($name) . '[%s]'; $cartItemForm-getWidgetSchema()-setNameFormat($nameFormat); else the name used in fields will be the same, then the form can't work. Then you have now your array of sfForm, you can get the embedded forms of the embedded form. $cartItemForm-getEmbeddedForms() On May 21, 8:33 pm, Tom Haskins-Vaughan t...@templestreetmedia.com wrote: Hi, I have successfully embedded a form like so: class CartForm extends BaseCartForm { public function configure() { unset( $this['id'], $this['is_default'], $this['buyer_id'] ); foreach($this-getObject()-getCartItems() as $cartItem) { $this-embedForm( 'cartitem_'.$cartItem-cart_id.'_'.$cartItem-harvest_id, new CartItemForm($cartItem) ); } } } And I have managed to display it like so: form method=post action=?php echo url_for('@my_cart') ? tbody ?php foreach($form as $cartItemForm): ? tr td?php echo $cartItemForm['quantity']-renderLabel() ?/td td?php echo $cartItemForm['quantity'] ?/td td/td /tr ?php endforeach; ? /tbody /table input type=submit value=Update cart / /form But I need to access some more information about each CartItem to display in the form, such as the Producer ($cartItem-Harvest-Producer). But in my example, it seems that $cartItemForm is not an sfForm but a sfFormField. So how do I access the Object of a form from a form field? Any help much appreciated. Thanks Tom --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Re: How to access the object of an embedded form
Oups, another tip : Don't forget that echo $form will display all the form and embedded ones, It's really helpfull to design forms. Cheers, David. On May 23, 11:26 am, esion esio...@gmail.com wrote: Hi, First, I'm not sure that works : ?php foreach($form as $cartItemForm): ? tr td?php echo $cartItemForm['quantity']-renderLabel() ?/ td td?php echo $cartItemForm['quantity'] ?/td td/td /tr ?php endforeach; ? It doesn't match with what you wrote in your form, what do you have in your action file? You should have in your view something like that : ?php foreach($form-getEmbeddedForms() as $cartItemForm): ? tr td colspan=2?php echo $cartItemForm ?/td /tr ?php enforeach ? Second (this is a really special gift, I spend several weeks to find this tricks on the net, so I'm waiting for sf1.3http://trac.symfony-project.org/ticket/5264) If you want to design your embedded forms you should use this code in the foreach : $nameFormat = $form-getWidgetSchema()-generateName($name) . '[%s]'; $cartItemForm-getWidgetSchema()-setNameFormat($nameFormat); else the name used in fields will be the same, then the form can't work. Then you have now your array of sfForm, you can get the embedded forms of the embedded form. $cartItemForm-getEmbeddedForms() On May 21, 8:33 pm, Tom Haskins-Vaughan t...@templestreetmedia.com wrote: Hi, I have successfully embedded a form like so: class CartForm extends BaseCartForm { public function configure() { unset( $this['id'], $this['is_default'], $this['buyer_id'] ); foreach($this-getObject()-getCartItems() as $cartItem) { $this-embedForm( 'cartitem_'.$cartItem-cart_id.'_'.$cartItem-harvest_id, new CartItemForm($cartItem) ); } } } And I have managed to display it like so: form method=post action=?php echo url_for('@my_cart') ? tbody ?php foreach($form as $cartItemForm): ? tr td?php echo $cartItemForm['quantity']-renderLabel() ?/td td?php echo $cartItemForm['quantity'] ?/td td/td /tr ?php endforeach; ? /tbody /table input type=submit value=Update cart / /form But I need to access some more information about each CartItem to display in the form, such as the Producer ($cartItem-Harvest-Producer). But in my example, it seems that $cartItemForm is not an sfForm but a sfFormField. So how do I access the Object of a form from a form field? Any help much appreciated. Thanks Tom --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Re: Propel and 1:1 relationships
Hey Richtermeister (damn, I tried saying your name out loud 3 times and I bit my tongue ) You are right in assuming that normally this should be one model. I however decided to divide it, seeing as the two parts do vastly different work. The division is purely for the sake of making the code and database more tidy. You see, the record model contains VERY sensitive information, and I have thusly decided to use encryption for it. It is a mysql compatible 128bit AES, however I do my encryption and decryption in php, as I don't want to transmit the password to the mysql sever (And you are also familiar with how symfony shows queries in plain view). The Record model also takes care of specific data manipulation and some final validation (most of which I have in forms, but because of the sensitivity of the information the last stretch is in the model) and is over 700 lines of code, where as the RecordCriteria model is pretty straight forward, all it does is calculate the weight or score if you'd prefer and provide some data-retrieval methods. So, in my mind, the most sensible thing to do was to separate the two models. I believe it's more clean, and more clear that way. The foreign key is set to the ID column, so record of id 10 has a recordCriteria of id 10. Essentailly a 1:1 relationship. Not something that one should really need to use very often. As a matter of fact, this is the very first time I have used one. Once again, thanks to everyone for pointing me in the right direction. PS And sorry for the double post before, especially one so lengthy On May 23, 9:30 am, Richtermeister nex...@gmail.com wrote: Hey Crafty, glad to hear you found a solution. I get what you're trying to do, I guess I was just a little unclear on the term 1-to-1 relationship. I may be wrong on this, but it seems to me there is no such thing as a 1-to-1 relationship in a propel model.. after all, the Record model has a foreign key pointing to a record in the RecordCriteria model, correct? Now, technically you could have many Records pointing to the same RecordCriteria, and this would give you a 1-to-many relationship.. At least nothing in the datamodel restricts a 1-to-1 relationship. In my opinion, when you have a 1-to-1 relationship of data, the data should really be in the very same model. Does that make sense, or am I going wrong somethere? Have a good night everybody, Daniel On May 22, 5:38 am, Crafty_Shadow vankat...@gmail.com wrote: Ok, I managed to write a static method for the Peer class that does exactly what I need, thanks for the help. I'm going to post it here: public static function doSelectJoinRecordCriteria(Criteria $criteria, PropelPDO $con = null) { $criteria = clone $criteria; RecordPeer::addSelectColumns($criteria); // add columns of the Record object to the criteria $startcol = (RecordPeer::NUM_COLUMNS - RecordPeer::NUM_LAZY_LOAD_COLUMNS); // this will be used as offset to the RecordCriteria table columns later RecordCriteriaPeer::addSelectColumns($criteria); // add columns of the RecordCriteria $criteria-addJoin(RecordPeer::ID, RecordCriteriaPeer::ID); // join on ID $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt-fetch(PDO::FETCH_NUM)) { $primary_key = RecordPeer::getPrimaryKeyHashFromRow($row, 0); if (!$record_object = RecordPeer::getInstanceFromPool ($primary_key)) // check Propel's object pool for our Record object, and create it if it's not found { $record_object = new Record(); $record_object-hydrate($row); RecordPeer::addInstanceToPool($record_object, $primary_key); } $primary_key = RecordCriteriaPeer::getPrimaryKeyHashFromRow ($row, $startcol); // same as the record primary key, but I put it for clarification if (!$record_criteria_object = RecordCriteriaPeer::getInstanceFromPool($primary_key)) // this time check the pool for the RecordCriteria object and create if not found { $record_criteria_object = new RecordCriteria(); $record_criteria_object-hydrate($row, $startcol); RecordCriteriaPeer::addInstanceToPool($record_criteria_object, $primary_key); } $record_criteria_object-setRecord($record_object); // set the object relation $results[] = $record_object; } $stmt-closeCursor(); return $results; } On May 22, 2:25 pm, Gareth McCumskey gmccums...@gmail.com wrote: Taken from the Propel upgrade info for moving from propel 1.2 to 1.3 (http://propel.phpdb.org/trac/wiki/Users/Documentation/1.3/Upgrading): ?php // example of how to manually hydrate objects $stmt = AuthorPeer::doSelectStmt(new Criteria()); while($row = $stmt-fetch(PDO::FETCH_NUM)) { $a = new Author(); $a-hydrate($row); } On Fri, May 22, 2009 at 1:19 PM, Crafty_Shadow
[symfony-users] Re: Propel and 1:1 relationships
Hey Crafty, ah I see. Thanks for walking me through that, I think that makes perfect sense. I'll have to look at your solution in detail, may need that myself one of these days :) Have a great weekend, Daniel On May 23, 3:08 am, Crafty_Shadow vankat...@gmail.com wrote: Hey Richtermeister (damn, I tried saying your name out loud 3 times and I bit my tongue ) You are right in assuming that normally this should be one model. I however decided to divide it, seeing as the two parts do vastly different work. The division is purely for the sake of making the code and database more tidy. You see, the record model contains VERY sensitive information, and I have thusly decided to use encryption for it. It is a mysql compatible 128bit AES, however I do my encryption and decryption in php, as I don't want to transmit the password to the mysql sever (And you are also familiar with how symfony shows queries in plain view). The Record model also takes care of specific data manipulation and some final validation (most of which I have in forms, but because of the sensitivity of the information the last stretch is in the model) and is over 700 lines of code, where as the RecordCriteria model is pretty straight forward, all it does is calculate the weight or score if you'd prefer and provide some data-retrieval methods. So, in my mind, the most sensible thing to do was to separate the two models. I believe it's more clean, and more clear that way. The foreign key is set to the ID column, so record of id 10 has a recordCriteria of id 10. Essentailly a 1:1 relationship. Not something that one should really need to use very often. As a matter of fact, this is the very first time I have used one. Once again, thanks to everyone for pointing me in the right direction. PS And sorry for the double post before, especially one so lengthy On May 23, 9:30 am, Richtermeister nex...@gmail.com wrote: Hey Crafty, glad to hear you found a solution. I get what you're trying to do, I guess I was just a little unclear on the term 1-to-1 relationship. I may be wrong on this, but it seems to me there is no such thing as a 1-to-1 relationship in a propel model.. after all, the Record model has a foreign key pointing to a record in the RecordCriteria model, correct? Now, technically you could have many Records pointing to the same RecordCriteria, and this would give you a 1-to-many relationship.. At least nothing in the datamodel restricts a 1-to-1 relationship. In my opinion, when you have a 1-to-1 relationship of data, the data should really be in the very same model. Does that make sense, or am I going wrong somethere? Have a good night everybody, Daniel On May 22, 5:38 am, Crafty_Shadow vankat...@gmail.com wrote: Ok, I managed to write a static method for the Peer class that does exactly what I need, thanks for the help. I'm going to post it here: public static function doSelectJoinRecordCriteria(Criteria $criteria, PropelPDO $con = null) { $criteria = clone $criteria; RecordPeer::addSelectColumns($criteria); // add columns of the Record object to the criteria $startcol = (RecordPeer::NUM_COLUMNS - RecordPeer::NUM_LAZY_LOAD_COLUMNS); // this will be used as offset to the RecordCriteria table columns later RecordCriteriaPeer::addSelectColumns($criteria); // add columns of the RecordCriteria $criteria-addJoin(RecordPeer::ID, RecordCriteriaPeer::ID); // join on ID $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt-fetch(PDO::FETCH_NUM)) { $primary_key = RecordPeer::getPrimaryKeyHashFromRow($row, 0); if (!$record_object = RecordPeer::getInstanceFromPool ($primary_key)) // check Propel's object pool for our Record object, and create it if it's not found { $record_object = new Record(); $record_object-hydrate($row); RecordPeer::addInstanceToPool($record_object, $primary_key); } $primary_key = RecordCriteriaPeer::getPrimaryKeyHashFromRow ($row, $startcol); // same as the record primary key, but I put it for clarification if (!$record_criteria_object = RecordCriteriaPeer::getInstanceFromPool($primary_key)) // this time check the pool for the RecordCriteria object and create if not found { $record_criteria_object = new RecordCriteria(); $record_criteria_object-hydrate($row, $startcol); RecordCriteriaPeer::addInstanceToPool($record_criteria_object, $primary_key); } $record_criteria_object-setRecord($record_object); // set the object relation $results[] = $record_object; } $stmt-closeCursor(); return $results; } On May 22, 2:25 pm, Gareth McCumskey gmccums...@gmail.com wrote: Taken from the Propel upgrade info for moving
[symfony-users] Re: Best Practices for Schema Changes
Lawrence, propel:data-dump and propel-build-all-load works great for a small database. Once your database reaches a certain size, this method is no longer feasible as you continue to get php out of memory errors. With a php.ini max memory set to 128mb, Ive found I usually reach this limit when the database dump gets to around 10meg in size (you are talking an average ~20,000 rows across your tables, where a table might contain an average of 5/6 columns). Once you hit these size limitations, using slinky66's method seems the best way to go for me... (medium sized db's) and I guess once that gets too big (large sized db's - 1m rows+) then James Cauwelier's method seems like the way to go... Would be interested to hear how other big sites handle this... Sherif On May 24, 6:18 am, Lawrence lkrub...@geocities.com wrote: On May 20, 9:50 am, slinky66 tcasto...@comcast.net wrote: I have not been able to find a best practice approach in the Symfony docs for dealing with schema changes as it relates to rebuilding the data model. Can someone give me some guidance with this scenario? Site is up and running and a few weeks later, a new column needs to be added to the database. Can some one describe the steps? If you work alone, you can do pretty much anything you want. We've a team of 5 programmers, scattered all over the world, so we need to be systematic. Our checklist: 1.) create a migration. test and debug on your local box. 2.) check it in. 3.) run the migration on the live site. 4.) (important!) do a symfony propel:data-dump data/fixtures/ frontend.yml 5.) run symfony propel:build-all-load 6.) when all works, make sure to check in the new fixture. 7.) run ‘php symfony cc’ after making so many changes. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Re: sfGuard problem
symfony cc ? On Sun, May 24, 2009 at 6:58 AM, murthy murthy_vija...@yahoo.com wrote: Hello, I am using Propel ORM. On May 20, 5:11 pm, Jan De Coster j...@we-create.be wrote: What ORM are you using ? Kr, -Oorspronkelijk bericht- Van: symfony-users@googlegroups.com [mailto: symfony-us...@googlegroups.com] Namens murthy Verzonden: woensdag 20 mei 2009 13:58 Aan: symfony users Onderwerp: [symfony-users]sfGuardproblem When I try to do symfony propel:build-model after installing the sfGuardplugin, I get the error, Class 'sfPropelBaseTask' not found What is the reason?. Please provide me solution. I searched on Internet but no use. -- I am on twitter: http://twitter.com/alecslupu I am on linkedIn: http://www.linkedin.com/in/alecslupu Tel: (+4)0748.543.798 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---