1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/redraiment-phpActiveRecord

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
В этом репозитории не указан файл с открытой лицензией (LICENSE). При использовании обратитесь к конкретному описанию проекта и его зависимостям в коде.
Клонировать/Скачать
test-join.php 1.4 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
redraiment Отправлено 08.07.2015 02:37 1837cf9
<?php
require_once('activerecord.php');
require_once('unit-test.php');
$db = DB::open('pgsql:host=127.0.0.1;dbname=test;', 'dba', '');
// Tables
$db->dropTable('zombies');
$db->dropTable('tweets');
$db->dropTable('comments');
$Zombie = $db->createTable('zombies',
'name varchar(64)'
);
$Tweet = $db->createTable('tweets',
'zombie_id integer',
'city_id integer',
'content varchar(128)'
);
$Comment = $db->createTable('comments',
'zombie_id integer',
'tweet_id integer',
'content varchar(128)'
);
$Zombie->hasMany('tweets')->by('zombie_id');
$Zombie->hasMany("received_comments")->by("tweet_id")->in("comments")->through("tweets");
$Zombie->hasAndBelongsToMany("commenters")->by("zombie_id")->in("zombies")->be("owner")->through("received_comments");
$Tweet->hasMany("comments")->by("tweet_id");
$ash = $Zombie->create("name:", "Ash");
$bob = $Zombie->create("name:", "Bob");
$jim = $Zombie->create("name:", "Jim");
$ashTweet = $ash->tweets->create("content:", "Hello from Ash");
$ashTweet->comments->create("zombie_id:", $bob->id, "content:", "Cool from Bob");
$ashTweet->comments->create("zombie_id:", $jim->id, "content:", "Cool from Jim");
foreach ($ash->commenters->all() as $commenter) {
echo "{$commenter->id}: {$commenter->name}\n";
}

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/redraiment-phpActiveRecord.git
git@api.gitlife.ru:oschina-mirror/redraiment-phpActiveRecord.git
oschina-mirror
redraiment-phpActiveRecord
redraiment-phpActiveRecord
master