pomm-project / ModelManager

Model Manager for the Pomm database framework.
MIT License
66 stars 27 forks source link

Add subqueries #86

Closed GregJArnold closed 5 years ago

GregJArnold commented 5 years ago

This allows you to specify literal SQL in updates and creates. As an example, to update a row's timestamp $model->updateByPk([ 'id' => $id ], [ modifiedAt => [ 'NOW()' ] ]);

chanmix51 commented 5 years ago

Sorry, I just see your PR. The format you use to tell the API it is a literal SQL is the array but it might conflict with values being real arrays. (it appears this case is not tested since you did not make any test to fail).

IMHO, one way to do it would be to pass a LiteralSQLExpression instance containing the expression (to be implemented) that would be treated as such.

GregJArnold commented 5 years ago

That makes sense, and seems like the cleanest solution. I'll re-work it as such.