1

I have a Model_User class which is extending Zend_Db_Table_Row but when I try to insert a row like this:

    $user = new Model_User();

    $data = array(
        'user_login' => $form->getValue('username'),
        'user_password' => $this->saltPassword($form->getValue('password')),
        'user_email' => $form->getValue('email')
    );

    $newUser = $user->createRow($data);

I get an error: An error occurred, Application error (Actually does anyone know how to have more clear error messages? These are very vague)

My model class is like described in the solution of this post. (So I also have a Model_User_Table class which is extending Zend_Db_Table_Abstract)

Any ideas?

Community
  • 1
  • 1
  • 1
    To get clearer error messages, put Zend into development mode. The default production behavior is to silence error messages in order to make it harder for an attacker to use information about the failures your app generates in order to attack you. – Billy ONeal Dec 22 '10 at 15:47
  • How ecatly do I switch to development mode? I have several 'categories' in my application.ini Thanks for your help! –  Dec 22 '10 at 15:52

1 Answers1

0

Method createRow is defined for Zend_Db_Table_Abstract, not for Zend_Db_Table_Row_Abstract. Just change your code to

$user = new Model_User_Table();
$newUser = $user->createRow($data);
Vika
  • 3,275
  • 18
  • 16
  • But my Model_User should represent a single row from my user table and not my entire tablee (is what that link I posted said anyway) Does Zend_Db_Table_Row_Abstract have a similar method to createRow? Thanks! –  Dec 22 '10 at 15:51
  • Zend_Db_Table_Abstract::createRow() is returning an instance of Zend_Db_Table_Row_Abstract, so your $newUser object is actually representing a single row. – Vika Dec 22 '10 at 16:03
  • Ah right I see! One more question you could maybe help me with: How can I make $newUser a Model_User object in this case, so that I can call my user methods on this objects. As you said they're the same type, but I can't think of how to do it.. –  Dec 22 '10 at 16:10
  • Just add to your Model_User_Table class this: protected $_rowClass = 'Model_User'; – Vika Dec 22 '10 at 16:13