public function testConnectToInvalidDatabaseShouldNotCreateDbFile()
 {
     try {
         ActiveRecord\Connection::instance("sqlite://" . self::InvalidDb);
         $this->assertFalse(true);
     } catch (ActiveRecord\DatabaseException $e) {
         $this->assertFalse(file_exists(__DIR__ . "/" . self::InvalidDb));
     }
 }
 public function test_connection_info()
 {
     $info = ActiveRecord\Connection::parse_connection_url('mysql://*****:*****@127.0.0.1:3306/dbname');
     $this->assert_equals('mysql', $info->protocol);
     $this->assert_equals('user', $info->user);
     $this->assert_equals('pass', $info->pass);
     $this->assert_equals('127.0.0.1', $info->host);
     $this->assert_equals(3306, $info->port);
     $this->assert_equals('dbname', $info->db);
 }
 public function test_set_charset()
 {
     $connection_string = ActiveRecord\Config::instance()->get_connection($this->connection_name);
     $conn = ActiveRecord\Connection::instance($connection_string . '?charset=utf8');
     $this->assert_equals("SET NAMES 'utf8'", $conn->last_query);
 }
Example #4
0
 /**
  * @expectedException ActiveRecord\DatabaseException
  */
 public function test_connect_to_invalid_database()
 {
     ActiveRecord\Connection::instance("{$this->conn->protocol}://test:test@127.0.0.1/" . self::InvalidDb);
 }
Example #5
0
<?php

require "../../vendor/php-activerecord/php-activerecord/ActiveRecord.php";
date_default_timezone_set('America/Sao_Paulo');
$cfg = ActiveRecord\Config::instance();
$cfg->set_model_directory('../../app/models');
// $cfg->set_connections(array('development' => 'mysql://*****:*****@localhost/mudam510_base;charset=utf8'));
// $cfg->set_connections(array('development' => 'mysql://*****:*****@localhost/bitfa068_mudamuda;charset=utf8'));
$cfg->set_connections(array('development' => 'mysql://*****:*****@localhost/mudamuda;charset=utf8'));
ActiveRecord\Connection::$datetime_format = 'Y-m-d H:i:s';
Example #6
0
<?php

header('Content-Type: text/html; charset=utf-8');
define('PATH_LIBS', $_SERVER['DOCUMENT_ROOT'] . '/../libs/');
define('SERVER_DIR', $_SERVER['DOCUMENT_ROOT'] . '/../');
require PATH_LIBS . 'flight/Flight.php';
error_reporting(E_ERROR);
require PATH_LIBS . 'phpactiverecord/ActiveRecord.php';
ActiveRecord\Config::initialize(function ($cfg) {
    $cfg->set_model_directory($_SERVER['DOCUMENT_ROOT'] . '/../app/Models');
    $cfg->set_connections(array('development' => 'mysql://*****:*****@localhost/vzapertiru_quest?charset=utf8'));
});
ActiveRecord\Connection::$datetime_format = 'Y-m-d';
ActiveRecord\Connection::$date_format = 'Y.m.d';
ActiveRecord\Serialization::$DATETIME_FORMAT = 'Y-m-d';
ActiveRecord\DateTime::$DEFAULT_FORMAT = 'Y-m-d';
Flight::set('flight.views.path', SERVER_DIR . 'view/template/');
require $_SERVER['DOCUMENT_ROOT'] . '/../config/classes.php';
Auth::getInstance()->init();
require SERVER_DIR . 'config/routes.php';
Flight::start();
Example #7
0
 public static function initialize($func)
 {
     self::$config = $func();
     self::$db = ActiveRecord\Connection::getInstance(self::$config['connectionString'], self::$config['user'], self::$config['password']);
     self::$db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
 }
Example #8
0
<?php

if (!isset($search) && !is_array($search) && !isset($model) && !class_exists($model)) {
    exit;
}
$s = ActiveRecord\Connection::instance();
$model = new $model();
$columns = $model->table()->columns;
foreach ($search as $filter) {
    if (!isset($columns[$filter['field']])) {
        continue;
    }
    switch ($filter['type']) {
        case 'text':
            if (isset($filter['class'])) {
                $class = $filter['class'];
            } elseif (isset($columns[$filter['field']]->lenght) && $columns[$filter[$field]]->type != 2) {
                if ($columns[$filter['field']]->lenght < 12) {
                    $class = "small";
                } elseif ($columns[$filter['field']]->lenght < 19) {
                    $class = "small";
                } else {
                    $class = "large";
                }
            } else {
                $class = "small";
            }
            $form[] = '<input type="text" placeholder="' . $filter['label'] . '" class="input-' . $class . ' search-query" style="margin-right: 10px">';
            break;
        case 'list':
            if (strpos($filter['field'], '_id')) {
Example #9
0
 public function test_set_charset()
 {
     $connection_string = ActiveRecord\Config::instance()->get_connection($this->connection_name);
     $conn = ActiveRecord\Connection::instance($connection_string . '?charset=utf8');
     $this->assert_equals(';charset=utf8', $conn->dsn_params);
 }
 public function testSetCharset()
 {
     $connectionString = ActiveRecord\Config::instance()->getConnection($this->connectionName);
     $conn = ActiveRecord\Connection::instance($connectionString . '?charset=utf8');
     $this->assertEquals(';charset=utf8', $conn->dsnParams);
 }
 public function testSetCharset()
 {
     $connectionString = ActiveRecord\Config::instance()->getConnection($this->connectionName);
     $conn = ActiveRecord\Connection::instance($connectionString . '?charset=utf8');
     $this->assertEquals('SET NAMES ?', $conn->lastQuery);
 }
 public function test_parse_connection_url_with_unix_sockets()
 {
     $info = ActiveRecord\Connection::parse_connection_url('mysql://*****:*****@unix(/tmp/mysql.sock)/database');
     $this->assert_equals('/tmp/mysql.sock', $info->host);
 }