If you’re a Zend Framework developer, you’d know the built-in Zend_Db_Table methods insert(), update(), etc.
However the general approach there is like is said:
$data = array();
$data['key'] = $value;
$model = new ModelName();
$model->insert($data);
// that's very basic example, but in general this is
// the way it works. |
$data = array();
$data['key'] = $value;
$model = new ModelName();
$model->insert($data);
// that's very basic example, but in general this is
// the way it works.
What happens if one of the column have to be an MySQL expression!? In example you’ve a date field and you’d like to insert something like the MySQL’s method NOW().
The solution is simply call a Zend_Db_Expr.
$data = array();
$data['key'] = $value;
$data['date'] = new Zend_Db_Expr('NOW()');
$model = new ModelName();
$model->insert($data);
// now the date column will be NOWed :) |
$data = array();
$data['key'] = $value;
$data['date'] = new Zend_Db_Expr('NOW()');
$model = new ModelName();
$model->insert($data);
// now the date column will be NOWed :)