我无法让 php postgrenew_address
使用以下代码从 php 数组中插入一行:
$customer_id = '2319';
$use_frequency = 1;
$sth = $dbh->prepare("
INSERT INTO address
('storeid',
'classtypeid',
'modifiedbyuser',
'modifiedbycomputer',
'modifieddate',
'seqid',
'issystem',
'isactive',
'streetaddress1',
'streetaddress2',
'city',
'state',
'county',
'postalcode',
'country',
'formattedtext',
'taxclassid',
'isvalidated',
'validatedaddress',
'hasvalidationerror',
'validationerror',
'customer_id',
'use_frequency')
VALUES ( NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
:address_1,
:address_2,
:city,
:state,
NULL,
:zip,
:country,
:formatted_text,
NULL,
NULL,
NULL,
NULL,
NULL,
:customer_id,
:use_frequency");
$sth->execute(array(
':address_1' => $new_address['address_1'],
':address_2' => $new_address['address_2'],
':city' => $new_address['city'],
':state' => $new_address['state'],
':zip' => $new_address['zip'],
':country' =>$new_address['country'],
':formatted_text' => $formatted_text,
':customer_id' => $customer_id,
':use_frequency' => $use_frequency
);
$sth->execute();
表中的最后一列是id
,serial
所以我省略了它,认为它会自动递增,但如果我错了,请告诉我。
我收到错误消息:
致命错误:未捕获的异常 'PDOException' 带有消息 'SQLSTATE[42601]:语法错误:7 错误:在“'storeid'”或附近出现语法错误 LINE 3: ('storeid', ^' in
print_r($new_address);
向我展示:
Array (
[0] => stdClass Object (
[customer_id] => 9319
)
[1] => stdClass Object (
[address_1] => 1515 example st
)
[2] => stdClass Object (
[address_2] => box 1
)
[3] => stdClass Object (
[city] => town
)
[4] => stdClass Object (
[state] => ST
)
[5] => stdClass Object (
[zip] => 12345
)
[6] => stdClass Object (
[country] => US
)
)
感谢您的任何建议!