where condition
where condition
acarlomagno
Posts: 17Questions: 3Answers: 0
hello
I am using this example code in order to fill the combobox list:
if ( ! isset($_POST['action']) ) {
// Get a list of sites for the `select` list
$out['companies'] = $db
->select( 'companies', 'id as value, vcompany as label' )
->fetchAll();
}
How I insert a 'where' condition ?
antonello
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I tried:
$db ->select( 'companies', 'id as value, vcompany as label', $where = array($key='companies.id',$value='1'))
but I received this error:
Column not found: 1054 Unknown column '0' in 'where clause'
why ?
with this works fine ... is correct to use a raw sql ?
->sql('SELECT id as value, vcompany as label FROM companies WHERE id = 1 ' )
Yes you can use a raw SQL statement - that's why the
sql()
function is there :-).For the
select
statement with a condition, you would use something like:Allan
thanks Allan, but where I wrong in normal 'select' function ?
antonello
oops, you had already answered!