Ejemplo n.º 1
0
 public function __construct()
 {
     if (is_null($this->table)) {
         $database = Connection::getConfig($this->connection);
         $this->table = $database['prefix'] . Inflector::underscore(get_class($this));
     }
     $this->loadBehaviors($this->behaviors);
 }
Ejemplo n.º 2
0
 /**
  * 构造方法
  *
  * @param Connection $connection
  * @param string|null $databaseName 数据库名,默认使用连接中的数据库
  */
 public function __construct(Connection $connection, $databaseName = null)
 {
     $this->connection = $connection;
     $this->dbConfig = $connection->getConfig();
     if (!$databaseName) {
         $databaseName = $this->dbConfig['dbname'];
     }
     $this->explainSchema($databaseName);
 }
Ejemplo n.º 3
0
function install_models(Connection $connection, $package, $models)
{
    $factory = RelationFactory::getInstance();
    $factory->prepareRelations($package, $models);
    $models = $factory->getRelations($connection->getConfig()->getType());
    foreach ($models as $model) {
        if (!install_model($connection, $model)) {
            return false;
        }
    }
    return true;
}
Ejemplo n.º 4
0
<?php

Connection::add(array('development' => array('driver' => 'MySql', 'host' => 'localhost', 'user' => 'root', 'password' => '', 'database' => 'spaghetti', 'prefix' => ''), 'production' => array('driver' => 'MySql', 'host' => 'localhost', 'user' => 'root', 'password' => '', 'database' => 'spaghetti', 'prefix' => ''), 'test' => array('driver' => 'MySql', 'host' => 'localhost', 'user' => 'root', 'password' => '', 'database' => 'spaghetti', 'prefix' => '')));
$env = Config::read('App.environment');
Connection::add('default', Connection::getConfig($env));
Ejemplo n.º 5
0
 public function __construct(Connection $connection)
 {
     $this->connection = $connection;
     $params = $connection->getConfig();
     parent::__construct($params);
 }