-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bind type ignored if the value is non-scalar #2752
Comments
Try casting the value before assigning the property: $robots->date = (string) $date; |
Closed as not a bug |
This still seems like a bug, or at least a missing piece of functionality. Consider these two cases below. Here we have a custom
Here we have case 1, where we set a property (i.e. DB field) to the
This produces a SQL error because the field value for
However, if we force a cast during the assignment of the property, like this:
Then, the value is properly bound and the SQL produced is:
But, why do we need to force a cast to string during assignment of the property? The whole point is for us to be able to interact with the property as a DateTime_Custom object, and then Phalcon converts it to a string (by the As @cvsguimaraes noted, though, the bind type within the |
@ldennison Could you please open a new separated issue with code to reproduce |
Done, at #13058. |
Here's my context: after a model fetch, when the column type is
DATETIME
, the value gets automatically converted to a customDateTime
class. ThisDateTime
implements the magic method__toString
so it can be used as a string value too.When saving the value back to db, the implicit conversion works fine but the value isn't bound to the query and the quotes are missing. This MySQL query was generated by calling
$user->save();
:I've checked
$this->modelsMetadata->getBindTypes($user);
and the bind type forlast_notified
is indeedBIND_PARAM_STR
.The text was updated successfully, but these errors were encountered: