function insert() { pitch("Dodeye.core.db.Insert"); $data = $this->request->getParam($this->type); $xml = simplexml_load_string($data); $array_val = ToArray($xml); $row_key = key($array_val); $row1_key = key($array_val[$row_key]); $Insert = new Insert(); $Insert->into($this->table); //@NOTE: peple might send multiple insert if (is_numeric($row1_key)) { //there are may rows $tbl_cols = array_keys($array_val[$row_key][$row1_key]); $Insert->columns($tbl_cols); $sql = $this->dbcon->prepare($Insert->bindable_sql()); // foreach ($tbl_cols as $key =>$val) // $sql->bindParam($key,$val); } else { //single entry $tbl_cols = array_keys($array_val[$row_key]); $Insert->columns($tbl_cols); $sql = $this->dbcon->prepare($Insert->bindable_sql()); foreach ($tbl_cols as $key => $val) { $sql->bindParam($key + 1, $array_val[$row_key][$val]); } //$rs = $sql->execute(); if ($rs) { print "true"; } else { print "false"; } } //$sql exit; }
/** * @covers Zend\Db\Sql\Insert::columns */ public function testColumns() { $this->insert->columns(array('foo', 'bar')); $this->assertEquals(array('foo', 'bar'), $this->readAttribute($this->insert, 'columns')); }