Welcome Guest, Not a member yet? Register   Sign In
BaseBuilder::testMode() instead getCompiled....()
#1

Hi all.
It seems to me that it would be more convenient to have unified SQL code generation if the place of the getComplied(Select/Update/etc) methods is to use the testMode() method.

Currently, depending on the method (update/delete/etc), using testMode() returns SQL code or true. Which, in my opinion, causes a light butthurt due to the ambiguity of behavior.

The BaseBuilder::testMode() method, for example, could affect the BaseConnection class and, depending on the passed value, the SQL code is returned or executed.

PHP Code:
$db->table('table')->update(...); // normal behavior
$db->table('table')->testMode()->update(...); // return sql 

$db->table('table')->insertBatch(...); // normal behavior
$db->table('table')->testMode()->insertBatch(...); // return sql 

$db->query(...); // normal behavior
$db->testMode()->query(...); // return sql 
Reply
#2

I am not a fan of methods that change behavior,
but in this case, the proposed APIs seem more consistent and better.
Reply
#3

(This post was last modified: 07-28-2022, 06:13 AM by MGatner.)

What about a wrapping class that works sort of like ReflectionClass and can be used with any Connection to extract various debug info, like resultant SQL?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB