I am trying to update a row partially .... just change its "status" column however the "update" method of the Phalcon\Mvc\Model fails because some of the other columns are "required" in the database and it seems like the "update" method inserts nulls for those.
Here is what my model looks like
class MyModel extends \Phalcon\Mvc\Model
{
public function getSource() {
return 'table_name';
}
public function initialize()
{
$this->setConnectionService('dbconn');
$this->useDynamicUpdate(true);
}
public function myUpdate(array $data)
{
$this->update($data);
}
The variable $data above in the myUpdate function contains the following
array('id'=>2, 'status'=>0)
I am using onValidationFails hook to print_r() the messages and I get the following:
Array
(
[0] => Phalcon\Mvc\Model\Message Object
(
[_type:protected] => PresenceOf
[_message:protected] => firstname is required
[_field:protected] => firstname
[_model:protected] =>
)
[1] => Phalcon\Mvc\Model\Message Object
(
[_type:protected] => PresenceOf
[_message:protected] => lastname is required
[_field:protected] => lastname
[_model:protected] =>
)
[2] => Phalcon\Mvc\Model\Message Object
(
[_type:protected] => PresenceOf
[_message:protected] => username is required
[_field:protected] => username
[_model:protected] =>
)
[3] => Phalcon\Mvc\Model\Message Object
(
[_type:protected] => PresenceOf
[_message:protected] => password is required
[_field:protected] => password
[_model:protected] =>
)
)
What do I need to do in order to update only the status column while leaving the other ones intact?!