0

I'm using the Zend_db_table insert() method and get an error. The error is because I receiving data from POST as a string but the datatype for the table column is float. So it creates error when I try to insert string type into float column.

What's the proper way to resolve this?

Here's the model code:

class User_Model_Forms extends Zend_Db_Table_Abstract {
    public function save(array $data) {
        return $this->insert($data);
    }
    ...

Here's the controller code:

$form = new User_Form_Firstpart();
if ( $form->isValid($request->getPost()) ){
    $data = $form->getValues();
    $formModel = new User_Model_Forms();
    $formModel->save($data);

    ...

Here's the database table:

form table

1
  • 1
    Could you paste some example code? Commented Aug 27, 2011 at 12:11

1 Answer 1

1

Try converting the input to float before passing it to insert:

$this->insert(array(
    'someColumn' => (float) $the_value,
));

BTW don't forget to add a float validator to your form.

Sign up to request clarification or add additional context in comments.

Comments

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.