Filtering Query WHERE
Filtering Query WHERE
Hello,
I want to filter my Query Select. I want to Select only id_operador < 40
This is my code:
[code]
$out['operadores'] = $db
->select( 'operadores', 'id_operador as value, nombre_operador as label', array("id_operador" => "40"))
->fetchAll();
[/code]
But this, only filter the id_operador = 40. I want id_operador < 40.
How I do please??
Thank you!
I want to filter my Query Select. I want to Select only id_operador < 40
This is my code:
[code]
$out['operadores'] = $db
->select( 'operadores', 'id_operador as value, nombre_operador as label', array("id_operador" => "40"))
->fetchAll();
[/code]
But this, only filter the id_operador = 40. I want id_operador < 40.
How I do please??
Thank you!
This discussion has been closed.
Replies
Allan
Use the where method. Note that you need to use query to build the query rather than select (as select is just a shortcut which returns a result).[/quote]
I try this, but it´s not work:
[code]
$out['operadores'] = $db
->select( 'operadores', 'id_operador as value, nombre_operador as label')
->where( 'id_operador','40','<' )
->fetchAll();
[/code]
I saw that the method is this:
[code]
public function where ( $key=null, $value=null, $op='=' )
[/code]
Thank you again!
Thanks
$db
->query( 'select', 'operadores' )
->fields( 'id_operador as value', 'nombre_operador as label' )
->where( 'id_operador','40','<' )
->exec()
->fetchAll();
[/code]
Ordering can be done with the `order` method: http://editor.datatables.net/docs/current/php/class-DataTables.Database.Query.html#_order
Allan
[code]
if ( !isset($_POST['action']) ) {
$out['operadores'] = $db
->query( 'select', 'operadores' )
->fields( 'id_operador as value', 'nombre_operador as label' )
->where( 'id_operador','40','<' )
->exec()
->fetchAll();
}
[/code]
But not work, this is the error:
Fatal error: Call to undefined method DataTables\Database\DriverMysqlQuery::fields() in php/table.competitive_prices.php on line 82
Why?
Thank you
Try this
[code]
$out['operadores'] = $db
->query( 'select', 'operadores' )
->get( 'id_operador as value, nombre_operador as label' )
->where( 'id_operador','40','<' )
->exec()
->fetchAll();
}
[/code]
Allan
Call to undefined method DataTables\Editor::order()
The Editor class doesn't have an `order` method: http://editor.datatables.net/docs/current/php/class-DataTables.Editor.html
Do you perhaps what to do an `order` on a `Query` instance: http://editor.datatables.net/docs/current/php/class-DataTables.Database.Query.html#_order ?
Allan