Welcome Guest, Not a member yet? Register   Sign In
Is it possible to select two cells with one query?
#1

Hi,
I have these two queries:
PHP Code:
$id $db->table('discount')->getWhere(['discount_assignment_id' => $id'active' => 1])->getFirstRow()->id ?: null;
$name $db->table('discount')->getWhere(['discount_assignment_id' => $id'active' => 1])->getFirstRow()->name ?: null

I'm trying something like this, but it doesn't work. Is there another way?
PHP Code:
$tmp $db->table('discount')->getWhere(['discount_assignment_id' => $id'active' => 1])->getFirstRow()->{id,name} ?: null

Thanks.
Reply
#2

1. getFirstRow() return areay or null
2. this is php.
ehat do you want with ->{id, name}?}
Reply
#3

what?
Reply
#4

Is the thing you need where, orWhere or join ?? documentation
Reply
#5

as long as it work, doesn't matter
Code:
$result = $db->table('discount')->getWhere(['discount_assignment_id' => $id, 'active' => 1])->getFirstRow();
$id =  $result->id ?? null;
$name = $result->name ?? null;
Reply




Theme © iAndrew 2016 - Forum software by © MyBB