示例#1
0
 public function testInsertSucceedsWithExprValue()
 {
     $this->db->insert('dewdrop_test_fruits', array('name' => 'Kiwi', 'is_delicious' => 1, 'level_of_deliciousness' => new Expr(5)));
     $this->assertEquals(6, $this->db->lastInsertId());
     $this->assertEquals(5, $this->db->fetchOne('SELECT level_of_deliciousness
              FROM dewdrop_test_fruits
              WHERE dewdrop_test_fruit_id = 6'));
 }
示例#2
0
 public function testSavingNewRowPerformsAnInsert()
 {
     $row = $this->table->createRow();
     $row->set(array('name' => 'Grape', 'is_delicious' => 1, 'level_of_deliciousness' => 9));
     $row->save();
     $this->assertEquals(6, $row->get('dewdrop_test_fruit_id'));
     $this->assertEquals(6, $this->db->lastInsertId());
     $this->assertEquals('Grape', $row->get('name'));
 }
示例#3
0
 /**
  * Save multiple groups of fields to the database.
  *
  * @param array $groupConfig
  * @return void
  */
 protected function saveGroups(array $groupConfig)
 {
     $this->dbAdapter->beginTransaction();
     $this->deleteCurrentSettings();
     foreach ($groupConfig as $index => $group) {
         $groupId = null;
         if (self::UNGROUPED !== $index) {
             $this->dbAdapter->insert('dewdrop_field_groups', array('title' => $group['title'], 'sort_index' => $index));
             $groupId = $this->dbAdapter->lastInsertId();
         }
         $this->saveFields($group['fields'], $groupId);
     }
     $this->dbAdapter->commit();
 }