forrest79 / phpgsql

Simple and fast PHP database library for PostgreSQL with auto converting DB types to PHP and fluent interface for SQL query writing.
Other
11 stars 3 forks source link

Immutable query fluent #34

Open forrest79 opened 1 year ago

forrest79 commented 1 year ago

It could be nice to have Fluent\Query and Fluent\QueryImmutable that is always returning clone of this. First tests show that it is about 2x slower (0.0000069836s vs 0.0000030076) - so still really quick.

Prepare this on PHP 8.1 - on Query we can have typed properties for simple scalar types. Complex types can be in array as it is now and on the clone, we can iterate this array deep and clone every object we found.

I'm thinking, regular Fluent\Query can have some $this->this() function with return $this and on Fluent\QueryInterface it will be overwritten to something like return clone $this.