1
I need to pass a null value to a column (date type) of the mysql database, according to the following code:
$birthdate = null;
User::update()
->set('name', $name)
->set('email', $email)
->set('birthdate', $birthdate)
->where('id', $id)
->execute();
However this error is generated below:
It seems that hydrahon does not accept passing a null value in its update method().
My question would be: How would I insert that null, in the bank column, via the Hydrahon update() method ?
I will add the part of lib code that is pointed as the reason for the error:
public function set($param1, $param2 = null)
{
// do nothing if we get nothing
if (empty($param1))
{
return $this;
}
// when param 2 is not null we assume that only one set is passed
// like: set( 'name', 'Lu' ); instead of set( array( 'name' => 'Lu' ) );
if ( !is_null( $param2 ) )
{
$param1 = array( $param1 => $param2 );
}
// merge the new values with the existing ones.
$this->values = array_merge( $this->values, $param1 );
// return self so we can continue running the next function
return $this;
}
Thank you very much. Your reply helped me a lot and will help other users.
– Gato de Schrödinger
That was the real difference. ->Sep(['birthdate' => $birthdate])
– Gato de Schrödinger
I updated my answer, forgot the bonus
– Clément Baconnier