Answer the question
In order to leave comments, you need to log in
YII2 how to select by values in fields?
Hello
There is a need to select data with the same field values from the database
like:
SELECT * FROM `pedigrees` WHERE `sire`=733 AND `dam`=731
public function getSiblings(){
$sibling = Pedigrees::find()
->where(['sire' => 'sire', 'dam' => 'dam'])
->all();
return $sibling;
->where(['sire' => '733', 'dam' => '731'])
Answer the question
In order to leave comments, you need to log in
Did it like this:
public function getSiblings(){
$sire = Pedigrees::find()->where(['LIKE', 'sire', $this->sire])->all();
$dam = Pedigrees::find()->where(['LIKE', 'dam', $this->dam])->all();
$sibling = Pedigrees::find()
->where(['sire' => $sire, 'dam' => $dam])
->all();
return $sibling;
public function getSiblings($sire, $dam){
$sibling = Pedigrees::find()
->where(['sire' => $sire, 'dam' => $dam])
->all();
return $sibling;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question