0

In my Application_Model_DbTable_User, I have the following function:

public function deleteUser($username)
{
    $this->delete('username = ' . (string) $username);
}

This function is being called from my AdminController, with this three lines of code.

$uname = $this->getRequest()->getParam('username');
$user = new Application_Model_DbTable_User();
$user->deleteUser($uname);

This error however, turns up.

Column not found: 1054 Unknown column 'test' in 'where clause'

With test being the user I am trying to delete.

This code is adapted from a previous code which deletes based on id, a INT field, which works perfectly fine. What am I doing wrong? I would be happy to give more detailed codes if needed. Thanks.

1 Answer 1

2

Your query isn't quoted:

$this->delete('username = ' . (string) $username);

This equates to:

WHERE username = test

If you use the where() method, it will do this for you:

$table->where('username = ?', $username);

Or (like the example in the docs):

$where = $table->getAdapter()->quoteInto('bug_id = ?', 1235);
$table->delete($where);
Sign up to request clarification or add additional context in comments.

1 Comment

it's better like that : $db = $this->getAdapter(); $table->where($db->quoteInto('username = ?', $username));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.