Changeset 12013
- Timestamp:
- 10/07/08 00:36:46 (2 months ago)
- Files:
-
- plugins/sfDoctrinePlugin/branches/1.1/lib/validator/sfValidatorDoctrineChoice.class.php (modified) (3 diffs)
- plugins/sfDoctrinePlugin/branches/1.1/lib/validator/sfValidatorDoctrineChoiceMany.class.php (modified) (1 diff)
- plugins/sfDoctrinePlugin/branches/1.1/lib/widget/sfWidgetFormDoctrineSelect.class.php (modified) (3 diffs)
- plugins/sfDoctrinePlugin/trunk/lib/validator/sfValidatorDoctrineChoice.class.php (modified) (3 diffs)
- plugins/sfDoctrinePlugin/trunk/lib/validator/sfValidatorDoctrineChoiceMany.class.php (modified) (1 diff)
- plugins/sfDoctrinePlugin/trunk/lib/widget/sfWidgetFormDoctrineSelect.class.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfDoctrinePlugin/branches/1.1/lib/validator/sfValidatorDoctrineChoice.class.php
r9612 r12013 26 26 * 27 27 * * model: The model class (required) 28 * * alias: The alias of the root component used in the query 28 29 * * query: A query to use when retrieving objects 29 30 * * column: The column name (null by default which means we use the primary key) … … 36 37 { 37 38 $this->addRequiredOption('model'); 39 $this->addOption('alias', 'a'); 38 40 $this->addOption('query', null); 39 41 $this->addOption('column', null); … … 47 49 { 48 50 $q = is_null($this->getOption('query')) ? Doctrine_Query::create() : $this->getOption('query'); 49 $q->from($this->getOption('model') . ' a') 50 ->addWhere('a.' . $this->getColumn() . ' = ?', $value); 51 $a = $this->getOption('alias'); 52 $q->from($this->getOption('model') . ' ' . $a) 53 ->addWhere($a . '.' . $this->getColumn() . ' = ?', $value); 51 54 52 55 $object = $q->fetchOne(); plugins/sfDoctrinePlugin/branches/1.1/lib/validator/sfValidatorDoctrineChoiceMany.class.php
r9611 r12013 28 28 $values = array($values); 29 29 } 30 31 $ q = is_null($this->getOption('query')) ? Doctrine_Query::create() : $this->getOption('query');32 $q ->from($this->getOption('model') . ' a')33 ->whereIn('a.'. $this->getColumn(), $values);30 31 $a = $this->getOption('alias'); 32 $q = is_null($this->getOption('query')) ? Doctrine_Query::create()->from($this->getOption('model') . " $a") : $this->getOption('query'); 33 $q = $q->whereIn("$a." . $this->getColumn(), $values); 34 34 35 35 $objects = $q->execute(); plugins/sfDoctrinePlugin/branches/1.1/lib/widget/sfWidgetFormDoctrineSelect.class.php
r11458 r12013 41 41 * * The column to order by the results (must be in the PhpName format) 42 42 * * asc or desc 43 * * criteria: A criteria to use when retrieving objects 43 * * alias: The alias for the main component involved in the query 44 * * query: A query to use when retrieving objects 44 45 * * connection: The Doctrine connection to use (null by default) 45 46 * * multiple: true if the select tag must allow multiple selections … … 53 54 $this->addOption('method', '__toString'); 54 55 $this->addOption('order_by', null); 55 $this->addOption('criteria', null); 56 $this->addOption('alias', 'a'); 57 $this->addOption('query', null); 56 58 $this->addOption('connection', null); 57 59 $this->addOption('multiple', false); … … 72 74 $choices[''] = true === $this->getOption('add_empty') ? '' : $this->getOption('add_empty'); 73 75 } 74 75 $ q = Doctrine_Query::create()76 ->from($this->getOption('model') . ' a');76 77 $a = $this->getOption('alias'); 78 $q = is_null($this->getOption('query')) ? Doctrine_Query::create()->from($this->getOption('model')." $a") : $this->getOption('query'); 77 79 78 80 if ($order = $this->getOption('order_by')) 79 81 { 80 $q->orderBy( 'a.'. $order[0] . ' ' . $order[1]);82 $q->orderBy("$a." . $order[0] . ' ' . $order[1]); 81 83 } 82 84 plugins/sfDoctrinePlugin/trunk/lib/validator/sfValidatorDoctrineChoice.class.php
r11629 r12013 27 27 * 28 28 * * model: The model class (required) 29 * * alias: The alias of the root component used in the query 29 30 * * query: A query to use when retrieving objects 30 31 * * column: The column name (null by default which means we use the primary key) … … 37 38 { 38 39 $this->addRequiredOption('model'); 40 $this->addOption('alias', 'a'); 39 41 $this->addOption('query', null); 40 42 $this->addOption('column', null); … … 48 50 { 49 51 $q = is_null($this->getOption('query')) ? Doctrine_Query::create() : $this->getOption('query'); 50 $q->from($this->getOption('model') . ' a') 51 ->addWhere('a.' . $this->getColumn() . ' = ?', $value); 52 $a = $this->getOption('alias'); 53 $q->from($this->getOption('model') . ' ' . $a) 54 ->addWhere($a . '.' . $this->getColumn() . ' = ?', $value); 52 55 53 56 $object = $q->fetchOne(); plugins/sfDoctrinePlugin/trunk/lib/validator/sfValidatorDoctrineChoiceMany.class.php
r11629 r12013 30 30 $values = array($values); 31 31 } 32 33 $ q = is_null($this->getOption('query')) ? Doctrine_Query::create() : $this->getOption('query');34 $q ->from($this->getOption('model') . ' a')35 ->whereIn('a.'. $this->getColumn(), $values);32 33 $a = $this->getOption('alias'); 34 $q = is_null($this->getOption('query')) ? Doctrine_Query::create()->from($this->getOption('model') . " $a") : $this->getOption('query'); 35 $q = $q->whereIn("$a." . $this->getColumn(), $values); 36 36 37 37 $objects = $q->execute(); plugins/sfDoctrinePlugin/trunk/lib/widget/sfWidgetFormDoctrineSelect.class.php
r11629 r12013 43 43 * * The column to order by the results (must be in the PhpName format) 44 44 * * asc or desc 45 * * criteria: A criteria to use when retrieving objects 45 * * alias: The alias for the main component involved in the query 46 * * query: A query to use when retrieving objects 46 47 * * connection: The Doctrine connection to use (null by default) 47 48 * * multiple: true if the select tag must allow multiple selections … … 55 56 $this->addOption('method', '__toString'); 56 57 $this->addOption('order_by', null); 57 $this->addOption('criteria', null); 58 $this->addOption('alias', 'a'); 59 $this->addOption('query', null); 58 60 $this->addOption('connection', null); 59 61 $this->addOption('multiple', false); … … 74 76 $choices[''] = true === $this->getOption('add_empty') ? '' : $this->getOption('add_empty'); 75 77 } 76 77 $ q = Doctrine_Query::create()78 ->from($this->getOption('model') . ' a');78 79 $a = $this->getOption('alias'); 80 $q = is_null($this->getOption('query')) ? Doctrine_Query::create()->from($this->getOption('model')." $a") : $this->getOption('query'); 79 81 80 82 if ($order = $this->getOption('order_by')) 81 83 { 82 $q->orderBy( 'a.'. $order[0] . ' ' . $order[1]);84 $q->orderBy("$a." . $order[0] . ' ' . $order[1]); 83 85 } 84 86