protected function pre_save(&$query)
{
$query->set(array('foreign_key' => 10));
}
is not working.Column count doesn't match value count at row 1 [ INSERT INTO `my_table` (`primary_key`, `foreign_key`) VALUES (null), (10) ]The query should be :
INSERT INTO `my_table` (`primary_key`, `foreign_key`) VALUES (null, 10)I made a very crappy workaround in the values method of the Database_Query_Builder_Insert class :
public function values(array $values)
{
if ( ! is_array($this->_values))
{
throw new \FuelException('INSERT INTO ... SELECT statements cannot be combined with INSERT INTO ... VALUES');
}
// Get all of the passed values
$values = func_get_args();
if (isset($this->_values) && !empty($this->_values)) {
$this->_values[0] = array_merge($this->_values[0], $values[0]);
} else {
$this->_values = array_merge($this->_values, $values);
}
return $this;
}
Indeed it works, but...
protected function pre_save(&$query)
{
$query->set(array('foreign_key' => 10));
}
in the pre_save method, the return query is :
INSERT INTO `my_table` (`primary_key`, `foreign_key`) VALUES (null), (10)instead of
INSERT INTO `my_table` (`primary_key`, `foreign_key`) VALUES (null, 10)
array(
0 => array('primary_key' => null)
)
maybe instead of
array('primary_key' => null)
array(
0 => array('primary_key' => null)
1 => array('foreign_key' => 10)
)
Sorry if my explanations are not so clear.It looks like you're new here. If you want to get involved, click one of these buttons!