Development

IrcFAQ (diff)

You must first sign up to be able to contribute.

Changes from Version 1 of IrcFAQ

Show
Ignore:
Author:
raphaelburnes (IP: 76.76.224.157)
Timestamp:
08/26/10 16:17:12 (7 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • IrcFAQ

    v0 v1  
     1A collection of questions I see often in irc.freenode.com #symfony. 
     2 
     3Most seem to relate to symfony 1.4 and Doctrine. 
     4 
     5 
     6Q: How do I get the name of a related model object to show up instead of the id in a dropdown?[[BR]] 
     7 
     8A: create a toString method in lib/model/doctrine/ModelName.class.php ( or lib/model/ModelName.class.php for Propel ) 
     9 
     10{{{ 
     11public function __toString() 
     12{ 
     13  return $this->getName(); 
     14} 
     15}}} 
     16 
     17 
     18---- 
     19 
     20 
     21Q: What is the difference between ModelName.class.php and ModelNameTable.class.php (Doctrine)[[BR]] 
     22 
     23A: ModelName.class.php is for operating on a single instance or record of that type, whereas ModelNameTable.class.php is for operating on the entire related table. For example: 
     24 
     25{{{ 
     26// $onePerson is an instance of the Person class, retrieved with the PersonTable class 
     27$onePerson = PersonTable::getInstance()->findOneByName('Bob'); 
     28 
     29// Get a Doctrine Collection of some people records with the PersonTable class. 
     30$people = PersonTable::getInstance()->findAll(); 
     31 
     32foreach($people as $person) 
     33{ 
     34  // each $person is an instance of the plain Person class. 
     35  $person->getName(); 
     36} 
     37 
     38}}} 
     39 
     40 
     41---- 
     42 
     43Q: How can I use multiple databases in symfony?[[BR]] 
     44 
     45A: Doctrine: http://symfony-world.blogspot.com/2010/05/multiple-database-symfony-configuration.html[[BR]] 
     46A: Propel: http://stackoverflow.com/questions/733224/multiple-databases-support-in-symfony 
     47 
     48 
     49---- 
     50 
     51Q: How can I set a default form parameter in my form?[[BR]] 
     52 
     53A: Create a new object for the form, set the parameter you want on it, and pass it to the form. 
     54 
     55{{{ 
     56  $person = new Person(); 
     57  $person->setName($request->getParameter('paramName')); 
     58  $this->form = new PersonForm($person); 
     59}}}