Interesting.. i modified the method to use quoteInto and it works now.

  function exists($field, $value) {
    $where = $this->getAdapter()->quoteInto($field . ' = ?', $value);
    return $this->fetchAll($where)->exists();
  }

Maybe my method was just wrong in the first place, but $where accepts a string or a array so i wonder why it didn't work aswell.

Would be nice if someone could explain it, so i am able to understand what i have "fixed" here.. :-)

Thanks!


Kjell Bublitz schrieb:
Hello, i am using 1.02.

Here is the method from a my User model:

  function exists($field, $value) {
    return $this->fetchAll(array($field => $value))->exists();
  }

This is what i set as $where (params for the above method):

  array(1) {
    ["user_name"] => string(7) "carzaib"
  }

In the class Zend_Db_Table_Abstract:

This is what actually goes to $select->where($key, $val);

  string(9) "user_name"
  string(7) "carzaib"

A snippet from the Abstract.php

  // $key is the condition with placeholder,
  // and $val is quoted into the condition
  $select->where($key, $val);

And here comes the final query:

SELECT `users`.`user_id`, `users`.`user_name`, `users`.`user_pass`, `users`.`user_mail`, `users`.`created_on` FROM `users` WHERE (user_name)

The where-clause is not complete.

What am i missing?

--
Kjell Bublitz


--
Kjell Bublitz

Reply via email to