views:

283

answers:

1

When i use the Zend_Form_Element_Select elements with multioptions i get this error when i pass the selected value to Zend_DB_Table to insert into the db

Message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'accounts_status ' in 'field list'

I have extracted some code snippets that i believe will go a long way into illustrating my problem.The *accounts_status* field DOES exist in my table

On my form construct have added the select element and options (I have left out the other elements)

    $optionsstatus = array(
           'active' => 'active',
           'pending' => 'pending'    
           );
    $optionsrole = array(
       'guest' => 'guest',
       'user' => 'user',
       'writer' => 'writer',
       'admin' => 'admin'    
       );

    $status = new Zend_Form_Element_Select('accounts_status');
                  $status->setLabel('Status')
           ->setRequired(true)    
           ->addMultiOptions($optionsstatus);
    $role = new Zend_Form_Element_Select('accounts_role');
                  $role->setLabel('Role')
           ->setRequired(true)
           ->addMultiOptions($optionsrole);

I use the *Zend_DB_table* to insert the post values from my controller

public function addaccount($username, $fullname, $email,
     $password,$status,$roles,$comments)
    {
     $data = array(
       'accounts_username' => $username,
       'accounts_fullname' => $fullname,
       'accounts_email' => $email,
       'accounts_password' => $password,    
       'accounts_status ' => $status,
       'accounts_roles' => $roles,    
       'accounts_comments ' => $comments,
     );
     $this->insert($data);
    }

In my controller i get the post values and send them to my model

$username = $form->getValue('accounts_username');
       $fullname = $form->getValue('accounts_fullname');
       $email = $form->getValue('accounts_email');
       $password = $form->getValue('accounts_password');
       $status = $form->getValue('accounts_status');
       $roles = $form->getValue('accounts_roles');
       $comments = $form->getValue('accounts_comments');
       $accounts = new Model_DbTable_Account();
       $accounts->addaccount($username, $fullname,$email,
       $password,$status,$roles,$comments);

This approach works for me except when am dealing with the Zend_Form_Element_Select elements.Am just wondering if there is a specific way of dealing with this select elements when it comes to CRUD operations.

A: 
Message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'accounts_status ' in 'field list'

Maybe I'm crazy, but looks to me like there's an extra space on that end of that 'accounts_status ' field name.

Typeoneerror
How do I get rid of that because clearly I am not introducing those "spaces" anywhere in my code.
davykiash
Thanks I have just seen it.
davykiash
np. sometimes you just need an extra pair of eyes :)
Typeoneerror