我用 php mysqli SELECT 检索了一些数据库条目。
一些条目包含单引号(即:L'avant du bâtiment)。这会产生解析错误并破坏我的网页。
这是查询:
$themes = ee()->db->select('field_id_46')
->from('channel_data_field_46')
->get();
if ($themes->num_rows() > 0)
{
foreach($themes->result_array() as $row)
{
$themesConcat = $row['field_id_46'];
echo $themesConcat;
}
}
如何去掉 field_id_46 条目中的引号?
请注意,db 类属于 ExpressionEngine CMS 核心,不应对其进行修改。
您可以使用str_replace()
功能进行字符替换。
修改后的代码如下:
echo str_replace("'", "", $themesConcat);
希望这对你有帮助。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句