Categories
newbie

symfony question from Javi

little children portraits taken in the studio ...

We’ve recently got the following question from newbie and thought someone may have a quick response for this to help the guy 🙂

Hi,

these are my steps first and then my question:

I have added this model and this fixture to my app :

Birthday:
  columns:
    testdate: date
 
Birthday:
  example:
    testdate: "2009-1-1"

I have generated the Birthday module. Then I’ve generated the filter
class (BirthdayFormFilter.class.php) and I have created a form filter
object in executeIndex():

$this->filter = new BirthdayFormFilter();

After that, i’ve added this lines to the index template:

<?php echo form_tag('birthday/filtrar') ?>
<?php echo $filter; ?>
<div><?php echo submit_tag('Filter') ?></div>
</form>

When i click the ‘Filter’ button i get this error:

500 | Internal Server Error | Doctrine_Connection_Mysql_Exception
SQLSTATE[HY093]: Invalid parameter number: number of bound variables
does not match number of tokens
stack trace
 
    * at ()
      in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/
lib/vendor/doctrine/Doctrine/Connection.php line 1086 ...
            1083.
            1084.         $name = 'Doctrine_Connection_' . $this-
 
&gt;driverName . '_Exception';
 
            1085.
            1086.         $exc  = new $name($e-&gt;getMessage(), (int)
$e-
 
&gt;getCode());
 
            1087.         if ( ! isset($e-&gt;errorInfo) || ! is_array
($e-
 
&gt;errorInfo)) {
 
            1088.             $e-&gt;errorInfo = array(null, null, null,
null);
            1089.         }
    * at Doctrine_Connection-&gt;rethrowException(object('PDOException'),
object('Doctrine_Connection_Statement'))
      in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/
lib/vendor/doctrine/Doctrine/Connection/Statement.php line 253 ...
             250.         } catch (Doctrine_Adapter_Exception $e) {
             251.         }
             252.
             253.         $this-&gt;_conn-&gt;rethrowException($e, $this);
             254.
             255.         return false;
             256.     }
    * at Doctrine_Connection_Statement-&gt;execute(array('month' =&gt; '1',
'day' =&gt; '2', 'year' =&gt; '2014'))
      in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/
lib/vendor/doctrine/Doctrine/Connection.php line 1014 ...
            1011.         try {
            1012.             if ( ! empty($params)) {
            1013.                 $stmt = $this-&gt;prepare($query);
            1014.                 $stmt-&gt;execute($params);
            1015.
            1016.                 return $stmt;
            1017.             } else {
    * at Doctrine_Connection-&gt;execute('SELECT b.id AS b__id, b.testdate AS
b__testdate FROM birthday b WHERE b.testdate &gt;= ? AND b.testdate &lt;= ?', array('month'
=&gt; '1', 'day' =&gt; '2', 'year' =&gt; '2014'))
      in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/
lib/vendor/doctrine/Doctrine/Query/Abstract.php line 992 ...
             989.             return $this-&gt;_conn-&gt;exec($query,
$params);
             990.         }
             991.
             992.         $stmt = $this-&gt;_conn-&gt;execute($query,
$params);
             993.         return $stmt;
             994.     }
 995.
    * at Doctrine_Query_Abstract-&gt;_execute(array('month' =&gt; '1', 'day'
=&gt; '2', 'year' =&gt; '2014'))
      in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/
lib/vendor/doctrine/Doctrine/Query/Abstract.php line 1036 ...
            1033.                 $result = $this-
 
&gt;_constructQueryFromCache($cached);
 
            1034.             }
            1035.         } else {
            1036.             $stmt = $this-&gt;_execute($params);
            1037.
            1038.             if (is_integer($stmt)) {
            1039.                 $result = $stmt;
    * at Doctrine_Query_Abstract-&gt;execute()
      in SF_ROOT_DIR/apps/frontend/modules/birthday/actions/
actions.class.php li

I know the error is produced because this:

Doctrine_Connection->execute('SELECT b.id AS b__id, b.testdate AS
b__testdate FROM birthday b WHERE b.testdate >= ? AND b.testdate
<= ?', array('month' => '1', 'day' => '2', 'year' => '2014'))

But if my steps are correct, why symfony is generating this useless clause? What am i doing wrong?Regards
Javi

Leave a Reply

Your email address will not be published. Required fields are marked *