gpt4 book ai didi

php - 我如何排除表字段MYSQL

转载 作者:行者123 更新时间:2023-11-29 00:49:04 25 4
gpt4 key购买 nike

抱歉奇怪的标题,但如果用户类型是 2 或 3,我会遇到一个小问题,那么我需要用户不能插入或更新一些字段,而不是创建一些插入查询下面列出了一些我不需要更新的字段。

AMStatus,HQStatus,approvedforsite

public function databaseinsert($data)
{
$this->data = $data;
switch($this->data['action']){
case "newlead":
$this->insert("customer_detail",
"TradingName,Street,City,State,PostCode,Industry,SubCategories,Membership,LeadStatus,AMStatus,HQStatus,approvedforsite,Salutation,FirstName,LastName,Website,Company,ABN_ACNNumber,Phone,Mobile,Notes,Description",
"'{$this->data['tradingname']}',
'{$this->data['street']}',
'{$this->data['suburb']}',
'{$this->data['state']}',
'{$this->data['postcode']}',
'{$this->data['category']}',
'{$this->data['subcategory']}',
'{$this->data['membership']}',
'{$this->data['salestatus']}',
'{$this->data['managerstatus']}',
'{$this->data['hqstatus']}',
'{$this->data['publishtoweb']}',
'{$this->data['title']}',
'{$this->data['firstname']}',
'{$this->data['lastname']}',
'{$this->data['webaddress']}',
'{$this->data['companyname']}',
'{$this->data['abnacn']}',
'{$this->data['phonenumber']}',
'{$this->data['mobile']}',
'{$this->data['notes']}',
'{$this->data['businessdescription']}'
");
break;
}

}

最佳答案

您需要在脚本中通过应用条件来处理数据库字段和值。并在将它们应用到 $this->insert 函数之前根据不同的用户类型制作两者的字符串。

类似下面的内容:

if($usertype=='yourtype')
{
$fieldsstr="TradingName,Street,City.................";
$valuestr=$this->data['tradingname'].",".$this->data['field2'].",".......

}
else
$fieldsstr="TradingName,Street.................";
$valuestr=$this->data['tradingname'].",".$this->data['field2'].",".......

}

$this->insert("customer_detail",$fieldsstr,$valuestr);

关于php - 我如何排除表字段MYSQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9269626/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com