Ejemplo n.º 1
0
 /**
  * Returns an DB instance. Only instanciate the DB if needed, so if you have
  * caching layer it will avoid creating DB connections for nothing.
  *
  * @return \ManiaLib\Database\Connection
  */
 protected function db()
 {
     if (!$this->db) {
         $this->db = \ManiaLib\Database\Connection::getInstance();
     }
     $this->db->select($this->databaseName);
     return $this->db;
 }
 /**
  * Returns an DB instance. Only instanciate the DB if needed, so if you have
  * caching layer it will avoid creating DB connections for nothing.
  *
  * @return \ManiaLib\Database\Connection
  */
 protected function db()
 {
     if (!$this->db) {
         $this->db = \ManiaLib\Database\Connection::getInstance();
     }
     return $this->db;
 }
Ejemplo n.º 3
0
 protected function __construct()
 {
     $this->db = \ManiaLib\Database\Connection::getInstance();
     $this->dbName = \ManiaLib\Database\Config::getInstance()->database;
 }
Ejemplo n.º 4
0
 protected function createTable($tableName, $query, OutputInterface $output)
 {
     $connection = Connection::getInstance();
     if (!$this->checkItTableExists($tableName)) {
         $output->writeln(sprintf('<info>Creating %s table</info>', $tableName));
         $connection->execute($query);
         $output->writeln(sprintf('<success>Table %s created</success>', $tableName));
     } else {
         $output->writeln(sprintf('<info>Table %s already exists</info>', $tableName));
     }
 }