如何使用prestashop 1.6中的模块将数据插入数据库

如何使用prestashop 1.6中的模块将数据插入数据库,prestashop,prestashop-1.6,Prestashop,Prestashop 1.6,我试图在数据库中插入数据,但无法工作。请任何人帮助我 函数saveDate() { if(Tools::getIsset('savedate')) { $value1=Tools::getValue('value1'); $value2=Tools::getValue('value2'); $res=Db::getInstance()->insert('ps_customer',数组( “lastname”=>$value1, “firstname”=>$value2, )); 如果($res)

我试图在数据库中插入数据,但无法工作。请任何人帮助我

函数saveDate()
{
if(Tools::getIsset('savedate'))
{
$value1=Tools::getValue('value1');
$value2=Tools::getValue('value2');
$res=Db::getInstance()->insert('ps_customer',数组(
“lastname”=>$value1,
“firstname”=>$value2,
));
如果($res)
返回$this->displayConfirmation($this->l('datesaved'));
其他的
返回$this->displayError($this->l(‘保存日期时发生错误’);
}
}
您的查询不起作用,因为您没有提供创建客户对象所需的所有字段

以下是客户对象的定义:

/**
*@请参阅ObjectModel::$definition
*/
公共静态$definition=array(
'表'=>'客户',
“主要”=>“id_客户”,
“字段”=>数组(
'secure\u key'=>array('type'=>self::type\u STRING,'validate'=>isMd5','copy\u post'=>false),
'lastname'=>array('type'=>self::type_STRING,'validate'=>isName','required'=>true,'size'=>32),
'firstname'=>array('type'=>self::type_STRING,'validate'=>isName','required'=>true,'size'=>32),
'email'=>array('type'=>self::type_STRING,'validate'=>'isEmail','required'=>true,'size'=>128),
“passwd”=>array('type'=>self::type_STRING,'validate'=>isPasswd','required'=>true,'size'=>32),
'last_passwd_gen'=>array('type'=>self::type_STRING,'copy_post'=>false),
'id\u gender'=>array('type'=>self::type\u INT,'validate'=>isUnsignedId'),
“生日”=>array('type'=>self::type_DATE,'validate'=>isBirthDate'),
“时事通讯”=>array('type'=>self::type\u BOOL,'validate'=>isBool'),
“时事通讯日期添加”=>array('type'=>self::type\u date,'copy\u post'=>false),
“ip_注册_时事通讯”=>array('type'=>self::type_STRING,'copy_post'=>false),
'optin'=>array('type'=>self::type\u BOOL,'validate'=>isBool'),
“网站”=>array('type'=>self::type\u STRING,'validate'=>'isUrl'),
'company'=>array('type'=>self::type\u STRING,'validate'=>'isGenericName'),
'siret'=>array('type'=>self::type_STRING,'validate'=>'isSiret'),
'ape'=>array('type'=>self::type\u STRING,'validate'=>'isApe'),
“未付金额”=>array('type'=>self::type\u FLOAT,'validate'=>isFloat','copy\u post'=>false),
'show_public_prices'=>array('type'=>self::type_BOOL','validate'=>isBool','copy_post'=>false),
'id\u risk'=>array('type'=>self::type\u INT,'validate'=>isUnsignedInt','copy\u post'=>false),
“最大付款天数”=>array('type'=>self::type\u INT,'validate'=>'isUnsignedInt','copy\u post'=>false),
'active'=>array('type'=>self::type\u BOOL','validate'=>isBool','copy\u post'=>false),
'deleted'=>array('type'=>self::type\u BOOL','validate'=>isBool','copy\u post'=>false),
'note'=>array('type'=>self::type_HTML,'validate'=>isCleanHtml,'size'=>65000,'copy_post'=>false),
'is_guest'=>array('type'=>self::type_BOOL','validate'=>isBool','copy_post'=>false),
'id\u shop'=>array('type'=>self::type\u INT,'validate'=>isUnsignedId','copy\u post'=>false),
'id\u shop\u group'=>array('type'=>self::type\u INT,'validate'=>isUnsignedId','copy\u post'=>false),
'id\u default\u group'=>array('type'=>self::type\u INT,'copy\u post'=>false),
'id\u lang'=>array('type'=>self::type\u INT,'validate'=>isUnsignedId','copy\u post'=>false),
'date\u add'=>array('type'=>self::type\u date','validate'=>isDate','copy\u post'=>false),
'date\u upd'=>array('type'=>self::type\u date','validate'=>isDate','copy\u post'=>false),
),
);
您需要至少提供标记为
'required'=>true的每个字段
您的查询不起作用,因为您没有提供创建客户对象所需的所有字段

以下是客户对象的定义:

/**
*@请参阅ObjectModel::$definition
*/
公共静态$definition=array(
'表'=>'客户',
“主要”=>“id_客户”,
“字段”=>数组(
'secure\u key'=>array('type'=>self::type\u STRING,'validate'=>isMd5','copy\u post'=>false),
'lastname'=>array('type'=>self::type_STRING,'validate'=>isName','required'=>true,'size'=>32),
'firstname'=>array('type'=>self::type_STRING,'validate'=>isName','required'=>true,'size'=>32),
'email'=>array('type'=>self::type_STRING,'validate'=>'isEmail','required'=>true,'size'=>128),
“passwd”=>array('type'=>self::type_STRING,'validate'=>isPasswd','required'=>true,'size'=>32),
'last_passwd_gen'=>array('type'=>self::type_STRING,'copy_post'=>false),
'id\u gender'=>array('type'=>self::type\u INT,'validate'=>isUnsignedId'),
“生日”=>array('type'=>self::type_DATE,'validate'=>isBirthDate'),
“时事通讯”=>array('type'=>self::type\u BOOL,'validate'=>isBool'),
'时事通讯\u日期\u添加