1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
<?php require_once __DIR__ . '/../../ActiveRecord.php';
class Book extends ActiveRecord\Model { // explicit table name since our table is not "books" static $table_name = 'simple_book';
// explicit pk since our pk is not "id" static $primary_key = 'book_id';
// explicit connection name since we always want production with this model static $connection = 'production';
// explicit database name will generate sql like so => db.table_name static $db = 'test'; }
$connections = array( 'development' => 'mysql://invalid', 'production' => 'mysql://test:test@127.0.0.1/test' );
// initialize ActiveRecord ActiveRecord\Config::initialize(function($cfg) use ($connections) { $cfg->set_model_directory('.'); $cfg->set_connections($connections); });
print_r(Book::first()->attributes()); ?>
|