作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试更新我上传的文件,但直到现在
i get eror message "erorr number 1064".
这是我的模型
public function update_tool_document($context, $data ){
$header = "";
for($i=1;$i<=10;$i++){
$header .= ", doc_title_" . $i. " = '" . $data['doc']['title'][$i-1] . "'";
$header .= ", doc_display_" . $i. " = '" . $data['doc']['show'][$i-1] . "'";
$header .=", link_to_doc_file_" . $i. " = '".(($data['doc']['link'][$i-1] != "")?"'".$data['doc']['link'][$i-1]."'":"link_to_doc_file_".$i)."'";
}
$query = "UPDATE ms_tool_type_document SET $header
WHERE tool_code = '".$data['tool_code']."'";
$table = $context->db->query($query);
return $table;
}
link_to_doc_file 有什么问题。错误结果是这样的:错误号:1064
您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行的 ' doc_title_1 = 'Tesst', doc_display_1 = '', link_to_doc_file_1 = ''material/tuto' 附近使用的正确语法
UPDATE ms_tool_type_document SET , doc_title_1 = 'Tesst', doc_display_1 = '', link_to_doc_file_1 = ''material/tutorial-prestashop.pdf'', doc_title_2 = 'hahaha', doc_display_2 = '', link_to_doc_file_2 = ''material/201512101342_INVOICE-NKOPP.pdf'', doc_title_3 = '', doc_display_3 = '', link_to_doc_file_3 = 'link_to_doc_file_3', doc_title_4 = '', doc_display_4 = '', link_to_doc_file_4 = 'link_to_doc_file_4', doc_title_5 = '', doc_display_5 = '', link_to_doc_file_5 = 'link_to_doc_file_5', doc_title_6 = '', doc_display_6 = '', link_to_doc_file_6 = 'link_to_doc_file_6', doc_title_7 = '', doc_display_7 = '', link_to_doc_file_7 = 'link_to_doc_file_7', doc_title_8 = '', doc_display_8 = '', link_to_doc_file_8 = 'link_to_doc_file_8', doc_title_9 = '', doc_display_9 = '', link_to_doc_file_9 = 'link_to_doc_file_9', doc_title_10 = '', doc_display_10 = '', link_to_doc_file_10 = 'link_to_doc_file_10' WHERE tool_code = 'T00005'
Filename: C:\xampp\htdocs\lalalala\system\database\DB_driver.php
Line Number: 331
最佳答案
您可以使用事件记录编写更新查询:
$this->db->set('link_to_doc_file',$header);
$this->db->where('tool_code',$data['tool_code']);
$this->db->update('ms_tool_type_document');
确保将列设置为文本
以接受如此大的字符串
关于PHP MySQL Codeigniter 更新上传的数组文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34943635/
我有以下正则表达式 /[a-zA-Z0-9_-]/ 当字符串只包含从 a 到z 大小写、数字、_ 和 -。 我的代码有什么问题? 能否请您向我提供一个简短的解释和有关如何修复它的代码示例? //var
我是一名优秀的程序员,十分优秀!