where in -clause on server side

where in -clause on server side

tuxietuxie Posts: 6Questions: 3Answers: 0

Hi,

Is it possible to use where in -clause on server side? I need where clause like this:

$data = Editor::inst( $db, 'wall_info', 'id' )
            ->fields(
                Field::inst( 'id' ),
                Field::inst( 'name' ),
            )
        ->where('id','(238,239,400,500)','in')
            ->process( $_POST )
            ->data();

I'm using MariaDB and normal query for example: select name from tablexz where id in (238,239,400,500); works fine from commandline.

Appreciate if You could help me on this one.

BR, Toni

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    edited December 2014 Answer ✓

    Hi Toni,

    Currently no, I'm afraid there isn't. It is something that I'm going to be looking at adding in future, but at the moment you would need to use or statements to do this.

    In the 1.4 beta which just going to release later today you will be able to use a closure to make more complex conditions such as the or statements:

    ->where( function ( $query ) {
      $query->or_where( 'id', '238' );
      $query->or_where( 'id', '239' );
      ...
    } )
    

    Not ideal I realise, but it will perform the same action, and if you have the information in an array you could use a little loop.

    As I say, this ability to use a closure function will be in the 1.4 beta released later today.

    Allan

  • tuxietuxie Posts: 6Questions: 3Answers: 0

    Cheers! Thank you for the fast reply.

This discussion has been closed.