INSERT
行の後にSELECT
. 回避策は、行をに追加することSELECT
です:
$insEvent_sql = "INSERT INTO event
(customer_id,
videography_package,
event_type,
event_shortdesc,
event_vanue,
event_start)
SELECT 'customer-id' AS customer_id,
'" . $safe_videography_package . "' AS videography_package,
'" . $safe_event_type . "' AS event_type,
'" . $safe_event_shortdesc . "' AS event_shortdesc,
'" . $safe_event_vanue . "' AS event_venu,
'" . $event_date . "' AS event_start
UNION ALL
SELECT customer_id, NULL, NULL, NULL, NULL, NULL
FROM customer
WHERE login_id = " . $_SESSION['SESS_LOGIN_ID'];
サンプルデータの使用:
$safe_videography_package = 'package1';
$safe_event_type = 'タイプ1';
$safe_event_shortdesc = '簡単な説明';
$safe_event_vanue = 'いくつかのイベント';
$event_date = '2012-05-05';
$_SESSION['SESS_LOGIN_ID'] = 1;
生産します:
INSERT INTO イベント
(顧客ID、
videography_package、
イベントタイプ、
event_shortdesc,
event_vanue,
event_start)
「customer-id」を customer_id として選択し、
'package1' AS videography_package,
'type1' AS event_type,
「簡単な説明」 AS event_shortdesc,
「いくつかの venu」 AS event_venu,
'2012-05-05' AS event_start
ユニオンオール
SELECT customer_id、NULL、NULL、NULL、NULL、NULL
お客様から
WHERE login_id = 1