Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mysql列子字符串()_Mysql_Substring_Substr - Fatal编程技术网

mysql列子字符串()

mysql列子字符串(),mysql,substring,substr,Mysql,Substring,Substr,在下面的函数中,我正在为字段$field实现子字符串,但我得到 Error Notice: Error: Unknown column 'EBook_at' in 'field list' 我知道在上没有类似于EBook\u的专栏,但是如何在$field子串 预期输出: /image/56789011/5678901145678 public function prependText($adjustment) { $prepend_text = $adjustment[0];

在下面的函数中,我正在为字段
$field
实现子字符串,但我得到

Error Notice: Error: Unknown column 'EBook_at' in 'field list'
我知道在上没有类似于
EBook\u的专栏,但是如何在$field子串

预期输出:

/image/56789011/5678901145678

public function prependText($adjustment) {
    $prepend_text = $adjustment[0];     
    $field = $adjustment[1];        
    $this->db->query('UPDATE ' . DB_PREFIX . "hj_import SET `" . $field . "` = CONCAT( '" . $this->db->escape($prepend_text) . "'," . SUBSTR($field,0,8) . "`, `" . $field . "` )");
}

通过使用以下查询修复该问题:

$this->db->query('UPDATE ' . DB_PREFIX . "hj_import SET `" . $field . "` = CONCAT( '" . $this->db->escape($prepend_text) . "', substr($field, 1, 8 ),'/',`" . $field . "` )");

转储查询的内容,并在使用它之前查看concat和substr正在做什么。在你的问题中没有任何样本值,很难猜测到底发生了什么。考虑到你连接的三个值都在php变量中。我建议将它们放在php中,而不是mysql中,这样会使代码更干净,并有助于解决类似这样的小问题。看来你的报价中有不一致的地方。