Ejemplo n.º 1
0
 /**
  * do database insert
  */
 function doInsert()
 {
     /* refill menu from post data */
     /* $this->menu->setMenuValues($_POST); */
     /* now test the menu values */
     if ($this->prepareForInsert()) {
         /* then get the data into the query */
         $iq = new InsertQuery($this->dbConn, $this->relation);
         $iq->setKeyColumns($this->keyColumns);
         $cnames = $this->menu->getColumnNames();
         // echo '<br> columnNames'.bvar_dump($cnames).'<br>';
         $arr = $this->menu->getColumnValues($cnames);
         if ($this->isTransactional) {
             $arr['trans_id'] = $this->dbConn->createTransactionId();
         }
         $iq->setSubmitvalueSet($arr);
         $iq->setUpdateSet($arr);
         // echo '<span style="color:red">'.bvar_dump($this->menu).'</span>';
         if ($iq->areKeyColumnsSet()) {
             /* allow insert */
             $query = $iq->getQuery();
             $this->dbMessage .= 'insert query' . $query;
             //echo $query;
             $result = doUpdate($this->dbConn, $query, $this->dbMessage);
             if ($result < 0) {
                 $this->dbMessage .= 'STE: Insert Failed with query ' . $query . ' db says: ' . $this->dbMessage;
                 $this->dbConn->Execute("ROLLBACK");
             } else {
                 $this->dbMessage .= ' added ' . $result . ' record(s) ';
                 $this->dbConn->transactionEnd();
             }
         } else {
             $this->dbMessage .= 'DB ERROR: Insert failed.<br>Not all keyColumns have been set';
             $this->dbConn->Execute("ROLLBACK");
         }
     }
 }