Answer the question
In order to leave comments, you need to log in
Sampling data with enumeration. Yii2?
Good afternoon. I have a problem. There is this sample:
$ser_spec = ServiceSpec::find()->where(['specialist_id' => $specialist['id']])->asArray()->all();
Array
(
[0] => Array
(
[id] => 1
[service_id] => 1
[specialist_id] => 1
)
[1] => Array
(
[id] => 8
[service_id] => 2
[specialist_id] => 1
)
[2] => Array
(
[id] => 9
[service_id] => 3
[specialist_id] => 1
)
)
Answer the question
In order to leave comments, you need to log in
Set up links in the models and follow the example as here
You will get a link call: $model->serSpec Extract
from the documentation
class Customer extends ActiveRecord
{
public function getOrders()
{
return $this->hasMany(Order::className(), ['customer_id' => 'id']);
}
}
class Order extends ActiveRecord
{
public function getCustomer()
{
return $this->hasOne(Customer::className(), ['id' => 'customer_id']);
}
}
// SELECT * FROM `customer` WHERE `id` = 123
$customer = Customer::findOne(123);
// SELECT * FROM `order` WHERE `customer_id` = 123
// $orders - это массив объектов Order
$orders = $customer->orders;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question