我的代码,哪里出问题了?
public function actionInsert() {
$single_date_at =(new Query())
->select('date_at')
->from('single_events');
$single_event_id =(new Query())
->select('id')
->from('single_events');
$user_date_at =(new Query())
->select('birthday')
->from('user');
$user_event_id =(new Query())
->select('id')
->from('user');
$holiday_date_at =(new Query())
->select(['concat(month, - day)'])
->from('holiday');
$holiday_event_id =(new Query())
->select('id')
->from('holiday');
//$date = strtotime($date_at);
//$formatForView = date("yyyy-mm-dd", $date);
if(!empty($single_date_at and $single_event_id)) {
(new Query())->createCommand()->insert('notifications_events',
[
'date_at' => $single_date_at,
'event_id' => $single_event_id,
'type' => 'single_event',
'message' => '',
])
->execute();
}
if(!empty($user_date_at and $user_event_id)) {
(new Query())->createCommand()->insert('notifications_events',
[
'date_at' => $user_date_at,
'event_id' => $user_event_id,
'type' => 'birthday',
'message' => '',
])
->execute();
}
if(!empty($holiday_date_at and $holiday_event_id)) {
(new Query())->createCommand()->insert('notifications_events',
[
'date_at' => $holiday_date_at,
'event_id' => $holiday_event_id,
'type' => 'holiday',
'message' => '',
])
->execute();
}
}
当我运行此代码时,出现错误
SQLSTATE [21000]:违反基数:1242子查询返回多于1行 正在执行的SQL是:插入
notifications_events
(date_at
,event_id
,type
,message
)值({{{ 1}}),(从birthday
中选择user
),“生日”,“)”
请帮忙,我需要返回多行,limit(1)在那里是无效的决定