Ejemplo n.º 1
0
 /**
  * setUpBeforeClass
  *
  * @return  void
  */
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     if (static::$dbo) {
         DatabaseAdapter::setInstance(new WindwalkerAdapter(static::$dbo));
     }
 }
Ejemplo n.º 2
0
 /**
  * Constructor.
  *
  * @param string                   $alias  Table alias.
  * @param string                   $table  Table name.
  * @param string|array             $pk     Primary key.
  * @param DatabaseAdapterInterface $db     Database adapter.
  */
 public function __construct($alias, $table, $pk = 'id', DatabaseAdapterInterface $db = null)
 {
     $this->db = $db ?: DatabaseAdapter::getInstance();
     $this->pk = $pk ?: $alias . '.' . $pk;
     $this->tables = new DataSet();
     $this->addTable($alias, $table);
     $this->prepare();
 }
Ejemplo n.º 3
0
 /**
  * Get table fields.
  *
  * @param string $table Table name.
  *
  * @return  array
  */
 protected function getFields($table = null)
 {
     $table = $table ?: $this->table;
     return $this->db->getFields($table);
 }
Ejemplo n.º 4
0
        adapter: mysql
        host: localhost
        name: testing_db
        user: root
        pass: ''
        port: 3306
        charset: utf8
YML;
$phinx = \Symfony\Component\Yaml\Yaml::parse($phinx);
$phinx['paths']['migrations'] = __DIR__ . '/../resources/migrations';
$phinx['environments']['production']['adapter'] = $config['database']['driver'];
$phinx['environments']['production']['host'] = $config['database']['host'];
$phinx['environments']['production']['name'] = $config['database']['name'];
$phinx['environments']['production']['user'] = $config['database']['user'];
$phinx['environments']['production']['pass'] = $config['database']['password'];
$phinx['environments']['production']['adapter'] = $config['database']['driver'];
$phinx['environments']['development']['host'] = $config['database']['host'];
$phinx['environments']['development']['name'] = $config['database']['name'];
$phinx['environments']['development']['user'] = $config['database']['user'];
$phinx['environments']['development']['pass'] = $config['database']['password'];
$phinx['environments']['production']['adapter'] = $config['database']['driver'];
$phinx['environments']['testing']['host'] = $config['database']['host'];
$phinx['environments']['testing']['name'] = $config['database']['name'];
$phinx['environments']['testing']['user'] = $config['database']['user'];
$phinx['environments']['testing']['pass'] = $config['database']['password'];
// Prepare Windwalker DB
$db = \Windwalker\Database\DatabaseFactory::getDbo($config['database']['driver'], $config['database']);
\Windwalker\DataMapper\Adapter\DatabaseAdapter::setInstance(new \Windwalker\DataMapper\Adapter\WindwalkerAdapter($db));
$db->setQuery('CREATE DATABASE IF NOT EXISTS ' . $db->qn($config['database']['name']))->execute();
$db->select($config['database']['name']);
return $phinx;
 /**
  * Registers the service provider with a DI container.
  *
  * @param   Container $container The DI container.
  *
  * @return  Container  Returns itself to support chaining.
  *
  * @since   1.0
  */
 public function register(Container $container)
 {
     DatabaseAdapter::setInstance(new JoomlaAdapter($container->get('db')));
 }