简体   繁体   中英

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 from 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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM