Using PHP active record ORMs without database connection

150 views Asked by At

Is it possible to use such ORMs as Propel or Yii's ActiveRecord without database connection?

There's a Yii2 project in which I need PHP not to communicate to database directly but via the UNIX socket. Best case scenario is extending/rewriting Yii's Model::class and being able to execute any CRUD method in a way that it'd generate a plain SQL and send it in the socket. I've looked through Yii's Model::class, Query::class and QueryBuilder::class source codes and it looks like they always need an instance of database connection.

Right now, for me, it seems like it's not even possible.

A worse (but still good, though) scenario is using Propel. I know it has a toString() method when building queries, but, as far as I know, it's not possible to use it in methods of models generated by Propel (like $user->getPhotos(), etc.).

Now I'm wondering whether it's even possible and, perhaps, there different kind of tools for this?

0

There are 0 answers