How do I select for something with a colon with Zend_Db_Select?
I have a query where I need to select text with a colon inside, basically it looks like this:
$select = $this->db->select()
->from('table')
->where(sprintf('tag = "%s"','foursquare:venue=12345'));
Now when I run this, I get the exception "Invalid bind-variable name :venue" which is obviously because the Mysqli adapter doesn't allow bind variables. The thing is now - I don't even want to use this as bind variable, I want to fire that query pretty much exactly like this. How can I prevent Zend_Db_Select fro开发者_C百科m trying to do it's thing? There is an open issue for the framework (#1398) which is really old and unfixed, so I guess most people find a workaround. Probably a really simple one and I'm just too stupid to see it.
Any hints?
Why are you using sprintf? You're overriding the built-in quoting mechanism that would normally handle this situation for you:
$select = $this->db->select()
->from('table')
->where('tag = ?', $tag);
精彩评论