1

I tried update my digit in array to database in zend but i can't My code is:

$tab = array(1,2,3,4,5);
$varData = array('res' => $tab);
$varWhere = array("id = $idUser");      
$this->objDB->update('table_name', $varData, $varWhere);

In database my field "res" is type integer[]. How can i should do it ?

1
  • conflict with format array from [] on {} Commented Jun 12, 2014 at 13:45

1 Answer 1

1

It can't be done this way. You've got to prepare your $tab array to be ready to insert as a PostgreSQL array type.

For example:

$tab = array(1,2,3,4,5);
$tabValue = '{' . implode(',', $tab) . '}';
$varData = array('res' => $tabValue);
$varWhere = array('id = ?' => $idUser);      
$this->objDB->update('table_name', $varData, $varWhere);
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.