コード例 #1
0
 public function crudDelete()
 {
     # Get a book to delete
     $book = Book::first();
     # Delete the book
     $book->delete();
     echo "This book has been deleted";
 }
コード例 #2
0
 public function test_dirty_attributes_with_mass_assignment()
 {
     $book = Book::first();
     $book->set_attributes(array('name' => 'rivers cuomo'));
     $this->assert_equals(array('name'), array_keys($book->dirty_attributes()));
 }
コード例 #3
0
 public function test_getter()
 {
     $book = Book::first();
     $this->assert_equals(strtoupper($book->name), $book->upper_name);
 }
コード例 #4
0
 public function testDirtyAttributesWithMassAssignment()
 {
     $book = Book::first();
     $book->setAttributes(array('name' => 'rivers cuomo'));
     $this->assertEquals(array('name'), array_keys($book->dirtyAttributes()));
 }
コード例 #5
0
ファイル: simple.php プロジェクト: aslijiasheng/jacksonslim
<?php

require_once dirname(__FILE__) . '/../../ActiveRecord.php';
// assumes a table named "books" with a pk named "id"
// see simple.sql
class Book extends ActiveRecord\Model
{
}
// initialize ActiveRecord
// change the connection settings to whatever is appropriate for your mysql server
ActiveRecord\Config::initialize(function ($cfg) {
    $cfg->set_model_directory('.');
    $cfg->set_connections(array('development' => 'mysql://*****:*****@127.0.0.1/test'));
});
print_r(Book::first()->attributes());
コード例 #6
0
 public function test_readonly_only_halt_on_write_method()
 {
     $book = Book::first(array('readonly' => true));
     $this->assert_true($book->is_readonly());
     try {
         $book->save();
         $this - fail('expected exception ActiveRecord\\ReadonlyException');
     } catch (ActiveRecord\ReadonlyException $e) {
     }
     $book->name = 'some new name';
     $this->assert_equals($book->name, 'some new name');
 }