Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- (...)
- $query = '
- SELECT SQL_CALC_FOUND_ROWS
- k.id,
- k.name,
- FROM
- kantoren AS k
- WHERE
- ' . (! empty($this->vars['name']) ? 'AND k.name LIKE ?' : '1') . '
- GROUP BY
- k.id
- ORDER BY
- k.name';
- $tokens = array();
- foreach ($this->vars as $key => $var) {
- if (!empty($var)) $tokens[] = $var;
- }
- $this->results = Zend_Registry::get('database')->query($query, $tokens);
- /*
- If I have this:
- $this->vars['name'] = "a%";
- ... I get a mysql error, because it's missing the quotes around it. (needs to be LIKE "a%", actualy is LIKE a%)
- If I have this:
- $this->vars['name'] = " 'a%' ";
- ... I get a mysql error, because the quotation mark gets shashed (LIKE \'a%\')
- */
Add Comment
Please, Sign In to add comment