Editor->where() - escaped on false

Editor->where() - escaped on false

FleiFlei Posts: 7Questions: 4Answers: 0

Looks like the false string does not work!

I try to make it Dynamik:

    $go=array("datum","<","NOW()",false);

    $editor->where( $go[0], $go[2],$go[1],$go[3] );

in log i see:
WHERE datum < :where_0
but the NOW() have no effect!

I log with

file_put_contents( '/tmp/editor_sql', $sql."\n", FILE_APPEND );

in Database/Driver/Mysql/Query.php in end of function _prepare

I also tried:

$editor->where( function ( $q ) {
    $q->where( $go[0], $go[2],$go[1],$go[3] );
} );

but shure- there is no var in the function - Error: Undefined variable: go in /.....

when i try:

$editor->where( function ( $q ) {
   $q->where( 'datum', 'NOW()', '<', false );
} );

it works!

$editor->where( 'datum', 'NOW()', '<', false );

does not work also??

Any Idea?
Thanks Thomas

Answers

  • FleiFlei Posts: 7Questions: 4Answers: 0

    After trying hours i have now this solutions:

    $go=array("datum","<","NOW()",false);
    if ($go[3]=="false")
    {
        $editor->where( function ( $q ) {
            GLOBAL $go;
            $q->where( $go[0],$go[2],$go[1],false );
        } );
    }else
    {
        $editor->where( $go[0],$go[2],$go[1] );
    }
    

    not the best solution but a workaround that works.
    Thanks
    Thomas

  • allanallan Posts: 54,909Questions: 1Answers: 8,606 Site admin

    Error: Undefined variable: go in /.....

    You are missing the use statement for your anonymous function. Because of PHP's unusual scoping you need to add use ( $go ) to your anonymous function to have $go available inside it.

    Allan

This discussion has been closed.