title: Insert array into Postgres array using PHP prepared statement
body: <p>I know there have been similar questions but I just can’t get this to work.</p>
  
  <p>I  have a Postgres database with a of type <code>int[]</code>.  I'm using a prepared statement to do my insert.  I keep getting this error:</p>
  
  <blockquote>
    <p>"<br />\n<b>Warning</b>:  pg_execute(): Query failed: ERROR:  malformed array literal: &quot;}&quot;[1, 0, 0, 0]&quot;]&quot;\nDETAIL:  Array value must start with &quot;{&quot; or dimension information. "</p>
  </blockquote>
  
  <p>Here is how I'm doing my array:</p>
  
  <pre><code>$aeidarr = array();
  if (isset($_POST['aeid'])){
      $aeid[] = $_POST['aeid'];
      foreach ($aeid as $aevalue){
          array_push($aeidarr, $aevalue);
      }
  } else{
      array_push($aeidarr, -1);
  }
  </code></pre>
  
  <p>Here is my prepared statement:</p>
  
  <pre><code>$insertentranceoptionsprep = pg_prepare($conn, 'insert_entranceoptions', "insert into entrances_options(uacctid, eid, aeid, eoautodoor) values ($1,$2,$3,$4);");
  $insertentranceoptionsex = pg_execute($conn, 'insert_entranceoptions', array($acctid, $eid, $aeidarr, $eoautodoor));
  </code></pre>
  
  <p>I'm sure I am doing something dumb.  But I would appreciate any help.</p>