Example #1
0
<?php

defined('DJA_PATH') || define('DJA_PATH', realpath(__DIR__ . '/../src'));
defined('DJA_APP_PATH') || define('DJA_APP_PATH', realpath(__DIR__ . '/../htdocs'));
/** @var $loader \Composer\Autoload\ClassLoader */
$loader = (require_once __DIR__ . '/../vendor/autoload.php');
/**
 * strrrraaaaangeee
 * PHPUnit_Extensions_Story
 */
//require_once '/Users/sasha/projects/php/phpunit/phpunit-story-master/PHPUnit/Extensions/Story/Autoload.php';
$dbConn = \Doctrine\DBAL\DriverManager::getConnection(array('driver' => 'pdo_pgsql', 'dbname' => 'sasha', 'user' => 'sasha', 'password' => '', 'host' => 'localhost'));
Dja\Db\Model\Metadata::setDefaultDbConnection($dbConn);
$log = new Doctrine\DBAL\Logging\DebugStack();
$dbConn->getConfiguration()->setSQLLogger($log);
SqlLog::$log = $log;
class UserModel extends Dja\Db\Model\Model
{
    protected static $dbtable = 'test_user';
    protected static $fields = ['user_id' => ['Auto'], 'username' => ['Char'], 'fullname' => ['Char'], 'slug' => ['Slug', 'prepopulate_field' => 'fullname'], 'email' => ['Email'], 'password' => ['Char'], 'date_added' => ['DateTime', 'autoInsert' => true], 'date_modified' => ['DateTime', 'autoUpdate' => true], 'is_active' => ['Bool', 'default' => true], 'ip' => ['Char', 'null' => true]];
    public function getIp()
    {
        return $this->_get('ip');
    }
    public function setIp($v)
    {
        if ($v != null) {
            $this->_set('ip', 'ip:' . $v);
        }
    }
}
Example #2
0
 public function testUsing()
 {
     $conn = Dja\Db\Model\Metadata::getDefaultDbConnection();
     $q = UserModel::objects()->limit(5)->using($conn);
     $q->count();
 }
Example #3
0
 public static function setUpBeforeClass()
 {
     self::$db = Dja\Db\Model\Metadata::getDefaultDbConnection();
 }