Development

Changeset 12013

You must first sign up to be able to contribute.

Changeset 12013

Show
Ignore:
Timestamp:
10/07/08 00:36:46 (2 months ago)
Author:
Jonathan.Wage
Message:

[1.1, 1.2] fixes #4509

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfDoctrinePlugin/branches/1.1/lib/validator/sfValidatorDoctrineChoice.class.php

    r9612 r12013  
    2626   * 
    2727   *  * model:      The model class (required) 
     28   *  * alias:      The alias of the root component used in the query 
    2829   *  * query:      A query to use when retrieving objects 
    2930   *  * column:     The column name (null by default which means we use the primary key) 
     
    3637  { 
    3738    $this->addRequiredOption('model'); 
     39    $this->addOption('alias', 'a'); 
    3840    $this->addOption('query', null); 
    3941    $this->addOption('column', null); 
     
    4749  { 
    4850    $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); 
    5154 
    5255    $object = $q->fetchOne(); 
  • plugins/sfDoctrinePlugin/branches/1.1/lib/validator/sfValidatorDoctrineChoiceMany.class.php

    r9611 r12013  
    2828      $values = array($values); 
    2929    } 
    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); 
    3434 
    3535    $objects = $q->execute(); 
  • plugins/sfDoctrinePlugin/branches/1.1/lib/widget/sfWidgetFormDoctrineSelect.class.php

    r11458 r12013  
    4141   *                  * The column to order by the results (must be in the PhpName format) 
    4242   *                  * 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 
    4445   *  * connection: The Doctrine connection to use (null by default) 
    4546   *  * multiple:   true if the select tag must allow multiple selections 
     
    5354    $this->addOption('method', '__toString'); 
    5455    $this->addOption('order_by', null); 
    55     $this->addOption('criteria', null); 
     56    $this->addOption('alias', 'a'); 
     57    $this->addOption('query', null); 
    5658    $this->addOption('connection', null); 
    5759    $this->addOption('multiple', false); 
     
    7274      $choices[''] = true === $this->getOption('add_empty') ? '' : $this->getOption('add_empty'); 
    7375    } 
    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'); 
    7779 
    7880    if ($order = $this->getOption('order_by')) 
    7981    { 
    80       $q->orderBy('a.' . $order[0] . ' ' . $order[1]); 
     82      $q->orderBy("$a." . $order[0] . ' ' . $order[1]); 
    8183    } 
    8284 
  • plugins/sfDoctrinePlugin/trunk/lib/validator/sfValidatorDoctrineChoice.class.php

    r11629 r12013  
    2727   * 
    2828   *  * model:      The model class (required) 
     29   *  * alias:      The alias of the root component used in the query 
    2930   *  * query:      A query to use when retrieving objects 
    3031   *  * column:     The column name (null by default which means we use the primary key) 
     
    3738  { 
    3839    $this->addRequiredOption('model'); 
     40    $this->addOption('alias', 'a'); 
    3941    $this->addOption('query', null); 
    4042    $this->addOption('column', null); 
     
    4850  { 
    4951    $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); 
    5255 
    5356    $object = $q->fetchOne(); 
  • plugins/sfDoctrinePlugin/trunk/lib/validator/sfValidatorDoctrineChoiceMany.class.php

    r11629 r12013  
    3030      $values = array($values); 
    3131    } 
    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); 
    3636 
    3737    $objects = $q->execute(); 
  • plugins/sfDoctrinePlugin/trunk/lib/widget/sfWidgetFormDoctrineSelect.class.php

    r11629 r12013  
    4343   *                  * The column to order by the results (must be in the PhpName format) 
    4444   *                  * 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 
    4647   *  * connection: The Doctrine connection to use (null by default) 
    4748   *  * multiple:   true if the select tag must allow multiple selections 
     
    5556    $this->addOption('method', '__toString'); 
    5657    $this->addOption('order_by', null); 
    57     $this->addOption('criteria', null); 
     58    $this->addOption('alias', 'a'); 
     59    $this->addOption('query', null); 
    5860    $this->addOption('connection', null); 
    5961    $this->addOption('multiple', false); 
     
    7476      $choices[''] = true === $this->getOption('add_empty') ? '' : $this->getOption('add_empty'); 
    7577    } 
    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'); 
    7981 
    8082    if ($order = $this->getOption('order_by')) 
    8183    { 
    82       $q->orderBy('a.' . $order[0] . ' ' . $order[1]); 
     84      $q->orderBy("$a." . $order[0] . ' ' . $order[1]); 
    8385    } 
    8486