dynamic where clause server side

dynamic where clause server side

mm789000mm789000 Posts: 25Questions: 2Answers: 0

Hi,

How can i do a dynamic where clause ?

I have a form with search fields , and i want to construct the where clause only with populate fields.

Regards.

Replies

  • mm789000mm789000 Posts: 25Questions: 2Answers: 0

    I try something like this :

    ->where( function ( $q ) use ( $sql_dyn ) {
    $q
    ->where( 'my_table.flag','O' ,'='.$sql_dyn );
    } )

    But doesn't work.

  • mm789000mm789000 Posts: 25Questions: 2Answers: 0

    I found a way like this ( like clause on every search fields ) :

    where( 'my_table.field_1',"%".$_SESSION['search_field_1']."%" , 'LIKE' )

    it work. But i'm not really please because it is a big table.

    Regards

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    Why are you not pleased with it? If you want a LIKE %term% search, then that is the correct way to do it.

    Allan

Sign In or Register to comment.