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- >driverName . '_Exception'; 1085. 1086. $exc = new $name($e->getMessage(), (int) $e- >getCode()); 1087. if ( ! isset($e->errorInfo) || ! is_array ($e- >errorInfo)) { 1088. $e->errorInfo = array(null, null, null, null); 1089. } * at Doctrine_Connection->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->_conn->rethrowException($e, $this); 254. 255. return false; 256. } * at Doctrine_Connection_Statement->execute(array('month' => '1', 'day' => '2', 'year' => '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->prepare($query); 1014. $stmt->execute($params); 1015. 1016. return $stmt; 1017. } else { * at 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')) in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/ lib/vendor/doctrine/Doctrine/Query/Abstract.php line 992 ... 989. return $this->_conn->exec($query, $params); 990. } 991. 992. $stmt = $this->_conn->execute($query, $params); 993. return $stmt; 994. } 995. * at Doctrine_Query_Abstract->_execute(array('month' => '1', 'day' => '2', 'year' => '2014')) in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/ lib/vendor/doctrine/Doctrine/Query/Abstract.php line 1036 ... 1033. $result = $this- >_constructQueryFromCache($cached); 1034. } 1035. } else { 1036. $stmt = $this->_execute($params); 1037. 1038. if (is_integer($stmt)) { 1039. $result = $stmt; * at Doctrine_Query_Abstract->execute() in SF_ROOT_DIR/apps/frontend/modules/birthday/actions/ actions.class.php liI 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