【发布时间】:2014-02-03 16:33:22
【问题描述】:
我正在尝试将枚举的值放入<option value="$enum">$enum</option>,但到目前为止没有任何运气。
我真的不能说为什么,我得到的错误是“Catchable fatal error: Object of class PDOStatement could not be convert to string in C:\xampp\htdocs\sp-admin\form.php on line 58”
第 58 行是$result = str_replace(array("enum('", "')", "''"), array('', '', "'"), $result);
这是我的 php
$query = "SELECT column_type FROM information_schema.columns
WHERE table_name = 'files' AND column_name = 'cat_page_pos'";
$result = $db->prepare($query);
$result = str_replace(array("enum('", "')", "''"), array('', '', "'"), $result);
$arr = explode("','", $result);
return $arr;
请在这里给我提示
提前致谢
【问题讨论】:
-
请提供 $result 的打印件。
-
我什至无法尝试并开始弄清楚您 str_replace 正在尝试做什么。您能解释一下您要替换的是什么以及用什么替换吗?单引号和双引号的数量让我脑残。
-
@TheHumbleRat 这是我的打印 PDOStatement 对象([queryString] => SELECT column_type FROM information_schema.columns WHERE table_name = 'files' AND column_name = 'cat_page_pos')
-
不要使用information_schema.columns,尝试使用速度更快的DESC table_name