我试图插入一个mysql查询本身到一个表字段中(当某些条件满足时执行一系列查询),但是每当查询中有任何特殊字符时,就会将其转换为它的相应的实体。插入特殊字符时的问题CodeIgniter
例如,如果Iam将此查询插入到表中,则报价将变为“'” ,>至& gt;和空间到&#。是否有任何方法插入查询,并以正确的形式显示。
"select
case item_id
when 206 then '1 Column'
when 255 then '2 Columns'
end as split,
# case oi.product_id
# when 24 then 'XXXX'
# when 28 then 'CCCC'
# when 30 then 'EEEE'
# else 'Something Else'
# end as product,
case oi.price_id
when 72 then 'UYT - Single Pay'
when 73 then 'UYT - Single Pay'
when 74 then 'UYT - Single Pay'
else 'Upsell'
end as product,
count(distinct(al.cust_id)) as the_count
from logtable al
where item_id in (206,255) and
activity_dts > '2012-01-31 19:15:00' and
o.order_is_refunded = 0 and
t.response_code = 1 and
t.response_reasontext not like '%testmode%'
group by 1,2;"
请给我建议或我在这里丢失任何东西。我的CI安装使用的字符集是UTF-8。
你的意思是你将整个查询作为“字符串”插入到mysql表列中?而不是特性和特定专业人员的伎俩? – Shaheer 2012-02-24 05:30:34
是的。整个查询作为字段类型的字符串是text.I使用CI的活动记录来执行查询。但是,当我试图从phpmyadmin中插入查询到通常的插入到语句中时,它工作。任何想法 ? – 2012-02-24 05:36:03