コード例 #1
0
ファイル: Common.php プロジェクト: jorgenils/zend-framework
 function testInsert()
 {
     $row = array('title' => 'News Item 3', 'subTitle' => 'Sub title 3', 'body' => 'This is body 1', 'date_created' => '2006-05-03 13:13:13');
     $rows_affected = $this->_db->insert(self::TableName, $row);
     $last_insert_id = $this->_db->lastInsertId();
     $this->assertEquals('3', (string) $last_insert_id);
     // correct id has been set
 }
コード例 #2
0
ファイル: Database.php プロジェクト: pansot2/PadCMS-backend
 protected function insert()
 {
     $bind = array();
     foreach ($this->databaseControls as $control) {
         if (!$control instanceof Volcano_Component_Control_Database_ReadOnly) {
             $bind[$control->getDbField()] = $control->getDbValue();
         }
     }
     try {
         $result = $this->db->insert($this->tableName, $bind);
         $this->primaryKeyValue = $this->db->lastInsertId();
     } catch (Zend_Db_Exception $e) {
         $this->errors[] = $this->localizer->translate("Database Error: %1\$s", $e->getMessage());
         return false;
     }
     foreach ($this->databaseControls as $control) {
         if ($control instanceof Volcano_Component_Control_Database_File || $control instanceof Volcano_Component_Control_File) {
             if (!$control->move($this->primaryKeyValue)) {
                 $this->delete();
                 return false;
             }
         }
     }
     return "insert";
 }
コード例 #3
0
ファイル: Ibm.php プロジェクト: mehulsbhatt/hashmark
 /**
  * Inserts a table row with specified data.
  * Special handling for PDO_IBM
  * remove empty slots
  *
  * @param mixed $table The table to insert data into.
  * @param array $bind Column-value pairs.
  * @return int The number of affected rows.
  */
 public function insert($table, array $bind)
 {
     $this->_connect();
     $newbind = array();
     if (is_array($bind)) {
         foreach ($bind as $name => $value) {
             if ($value !== null) {
                 $newbind[$name] = $value;
             }
         }
     }
     return parent::insert($table, $newbind);
 }
コード例 #4
0
ファイル: Ibm.php プロジェクト: jorgenils/zend-framework
 /**
  *  Inserts a table row with specified data.
  *	Special handling for PDO_IBM
  * remove empty slots
  *
  * @param mixed $table The table to insert data into.
  * @param array $bind Column-value pairs.
  * @return int The number of affected rows.
  */
 public function insert($table, array $bind)
 {
     $newbind = array();
     if (is_array($bind)) {
         foreach ($bind as $name => $value) {
             if (!is_null($value)) {
                 $newbind[$name] = $value;
             }
         }
     }
     return parent::insert($table, $newbind);
 }