0

What's the correct syntax to select multiple rows through an array using Zend ? So basically fetch all the data that has name $a OR $b etc..depending on number of array elements. I can't figure it out.......

public function selectRow($array) 
{
    $data = $this->table->select()
                        ->where('name = ?', $array);
    return $this->table->fetchAll($data);
}

2 Answers 2

1

You have to use IN clause for that. So try,

$data = $this->table->select()
                    ->where('name IN (?)', $array);
Sign up to request clarification or add additional context in comments.

Comments

1

you can use orWhere() in the Zend_Db_Select. Check the manual Zend_Db_Select::where().

public function selectRow($array) 
{
    $data = $this->table->select()
                        ->where('name = ?', $array)
                        ->orWhere('address = ?', $anotherarray);
    return $this->table->fetchAll($data);
}
  • it would be better to use IN and NOT IN when the where condition contains array of values

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.