[英]str_replace and Replace is not working
I Want to execute this query but it doesn't print anything because of str_replace,I also used Replace in place of str_replace but it doesn't work for me.Where 我想执行此查询,但由于str_replace而无法打印任何内容,我也使用Replace代替了str_replace,但它对我不起作用。
$name = iFLY-San-Diego-Kids-Club
In database-- its like iFLY San Diego Kids Club
在数据库中-就像
iFLY San Diego Kids Club
please help anyone to get this. 请帮助任何人获得此信息。 Any help will be appreciated.
任何帮助将不胜感激。
Thanks in advance 提前致谢
$rs = $this->db->select('*')
->from('table')
->where('table.status', 'Active')
->where('table.id', $id)
->where('table.title', str_replace('-',' ',$name))
->get()->result();
}
Your query is perfect but instead of where
you can use like
clause like mentioned below. 您的查询是完美的,但不是可以在下面使用
like
子句的where
而是下面提到的。
->where('table.title', str_replace('-',' ',$name))
Replace with 用。。。来代替
->like('table.title', str_replace('-',' ',$name))
If you use like
then it will automatically add wildcard( %
) in your query. 如果使用
like
,它将在查询中自动添加通配符( %
)。
Let me know if it not works. 让我知道是否有效。
You can do this like 你可以这样做
$newname = str_replace("-","",$name);
$rs = $this->db->select('*')
->from('table')
->where('table.status', 'Active')
->where('table.id', $id)
->where('table.title', $newname)
->get()->result();
}
代替使用str_replace('-',' ',$name)
尝试str_replace('-','_',$name)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.