Exemplo n.º 1
0
 protected function prepareFetchObjects(array $data)
 {
     $stmt = $this->createMock(\PDOStatement::class);
     $stmt->method('fetchAll')->willReturn($data);
     $this->driver->method('query')->willReturn($stmt);
     return $this->database->fetchObjectsWithJoin('SELECT column1, column2 FROM `table`', $this->metadata, $this->joinedMetadata);
 }
Exemplo n.º 2
0
 /**
  * Handler for CMSAPI database version manipulating
  *
  * @param string $toVersion Version to switch to
  *
  * @return string Current database version
  */
 public function migrator($toVersion = null)
 {
     // If something passed - change database version to it
     if (func_num_args()) {
         // Save current version to special db table
         $this->database->execute("ALTER TABLE  `" . dbMySQLConnector::$prefix . "cms_version`\n                CHANGE  `version`  `version` VARCHAR( 15 ) CHARACTER SET utf8\n                COLLATE utf8_general_ci NOT NULL DEFAULT  '" . $toVersion . "';");
         die('Database successfully migrated to [' . $toVersion . ']');
     } else {
         // Return current database version
         $version_row = $this->database->fetch('SHOW COLUMNS FROM `' . dbMySQLConnector::$prefix . 'cms_version`');
         if (isset($version_row[0]['Default'])) {
             return $version_row[0]['Default'];
         } else {
             return 0;
         }
     }
 }