示例#1
0
 public function testFetchNew()
 {
     $this->initConnection();
     $bookstore = $this->dbDiffer('bookstore');
     $bookstore->snapshot();
     $entity = Authors::fetchNew();
     $entity->set("first_name", "Kowalski");
     $id = $entity->save();
     $bookstore->snapshot();
     $this->assertEquals($id, 4);
     $this->assertEquals($bookstore->numOfCreated(), 1);
     $this->assertEquals($bookstore->numOfChanged(), 1);
 }
示例#2
0
    });
});
$array = $select->fetchAll();
$array = $select->fetchOne();
$array = $select->fetchCol();
$array = $select->fetchRow();
$entity = $select->first();
$collection = $select->all();
// operations on entity
$author1 = Authors::select()->equal('author_id', 1)->first();
$author1->set('first_name', 'John');
// UPDATE
$author1->save();
// DELETE
// $author1->delete();
$authorNew = Authors::fetchNew();
$authorNew->set('first_name', 'John');
$authorNew->set('last_name', 'Matthew');
// INSERT
$authorNew->save();
// Collection
$authors = Authors::select()->order('authors.author_id', 'DESC')->all();
foreach ($authors as $author) {
    $authorNew->set('first_name', 'John');
    $authors->save();
}
// or short
$authors->set('first_name', 'John')->save();
// or delete all authors
// $authors->delete();
// joins