getDatabasePlatform() public method

Gets the DatabasePlatform for the connection.
public getDatabasePlatform ( ) : Doctrine\DBAL\Platforms\AbstractPlatform
return Doctrine\DBAL\Platforms\AbstractPlatform
Ejemplo n.º 1
0
 /**
  * Update status
  *
  * @param string $nonce
  * @param string $apiUrls
  *
  * @return int
  */
 public function updateStatus($nonce, $apiUrls)
 {
     // Truncate table
     $this->con->executeQuery($this->con->getDatabasePlatform()->getTruncateTableSQL($this->tables['status']));
     // Insert new row
     return $this->con->insert($this->tables['status'], array('nonce' => $nonce, 'noncets' => time(), 'apiurls' => $apiUrls, 'modified' => new \DateTime()), array(\PDO::PARAM_STR, \PDO::PARAM_INT, \PDO::PARAM_STR, 'datetime'));
 }
Ejemplo n.º 2
0
 protected function truncateTable($tableName)
 {
     if (!in_array($tableName, $this->truncatedTables)) {
         $query = $this->connection->getDatabasePlatform()->getTruncateTableSql($tableName, true);
         $this->connection->executeUpdate($query);
         $this->truncatedTables[] = $tableName;
     }
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function apply($fromAlias, $fromIdentifier, $resourcePrefix, array $requesterIdentifiers, $mask, array $orX = [])
 {
     $this->queryBuilder->leftJoin($fromAlias, $this->getAclSchema()->getPermissionsTableName(), 'acl_p', 'acl_p.resource = ' . $this->connection->getDatabasePlatform()->getConcatExpression(':acl_prefix', $fromAlias . '.' . $fromIdentifier));
     $orX[] = 'acl_p.requester IN (:acl_identifiers) AND :acl_mask = (acl_p.mask & :acl_mask)';
     $this->queryBuilder->andWhere(implode(' OR ', $orX));
     $this->queryBuilder->setParameter('acl_prefix', $resourcePrefix, \PDO::PARAM_STR)->setParameter('acl_identifiers', $requesterIdentifiers, Connection::PARAM_STR_ARRAY)->setParameter('acl_mask', $mask, \PDO::PARAM_INT);
     return $this->queryBuilder;
 }
Ejemplo n.º 4
0
 /**
  * Initializes a new instance of a class derived from AbstractCollectionPersister.
  *
  * @param \Doctrine\ORM\EntityManager $em
  */
 public function __construct(EntityManager $em)
 {
     $this->em = $em;
     $this->uow = $em->getUnitOfWork();
     $this->conn = $em->getConnection();
     $this->platform = $this->conn->getDatabasePlatform();
     $this->quoteStrategy = $em->getConfiguration()->getQuoteStrategy();
 }
 /**
  * Initialization of data required to run current command
  * @param InputInterface $input
  * @param OutputInterface $output
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     $this->kernelDir = $this->getContainer()->getParameter('kernel.root_dir');
     $this->entityManager = $this->getContainer()->get('doctrine.orm.entity_manager');
     $this->connection = $this->entityManager->getConnection();
     $this->dbPlatform = $this->connection->getDatabasePlatform();
     $this->output = $output;
 }
Ejemplo n.º 6
0
 public function dropTable()
 {
     $schema = $this->getTableSchema();
     $queries = $schema->toDropSql($this->connection->getDatabasePlatform());
     foreach ($queries as $query) {
         $this->connection->prepare($query)->execute();
     }
 }
Ejemplo n.º 7
0
 /**
  * Returns the system information:
  *  - cpu information
  *  - memory size
  *  - php version
  *  - php accelerator info
  *  - database related info.
  *
  * @return array
  */
 public function getSystemInfo()
 {
     $info = ezcSystemInfo::getInstance();
     $accelerator = false;
     if ($info->phpAccelerator) {
         $accelerator = ['name' => $info->phpAccelerator->name, 'url' => $info->phpAccelerator->url, 'enabled' => $info->phpAccelerator->isEnabled, 'versionString' => $info->phpAccelerator->versionString];
     }
     return ['cpuType' => $info->cpuType, 'cpuSpeed' => $info->cpuSpeed, 'cpuCount' => $info->cpuCount, 'memorySize' => $info->memorySize, 'phpVersion' => phpversion(), 'phpAccelerator' => $accelerator, 'database' => ['type' => $this->connection->getDatabasePlatform()->getName(), 'name' => $this->connection->getDatabase(), 'host' => $this->connection->getHost(), 'username' => $this->connection->getUsername()]];
 }
Ejemplo n.º 8
0
 /**
  * Configures DBAL types required in tests
  */
 protected function setUpDBALTypes()
 {
     if (Type::hasType('jsonb')) {
         Type::overrideType('jsonb', 'Boldtrn\\JsonbBundle\\Types\\JsonbArrayType');
     } else {
         Type::addType('jsonb', 'Boldtrn\\JsonbBundle\\Types\\JsonbArrayType');
     }
     $this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('JSONB', 'jsonb');
 }
 public function __construct(Version $version)
 {
     $config = $version->getConfiguration();
     $this->version = $version;
     $this->connection = $config->getConnection();
     $this->sm = $this->connection->getSchemaManager();
     $this->platform = $this->connection->getDatabasePlatform();
     $this->outputWriter = $config->getOutputWriter();
 }
Ejemplo n.º 10
0
 public function setUp()
 {
     $this->connection = \OC_DB::getConnection();
     if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
         $this->markTestSkipped("Test only relevant on MySql");
     }
     $dbPrefix = \OC::$server->getConfig()->getSystemValue("dbtableprefix");
     $this->tableName = uniqid($dbPrefix . "_enum_bit_test");
     $this->connection->exec("CREATE TABLE {$this->tableName}(b BIT,  e ENUM('1','2','3','4'))");
 }
Ejemplo n.º 11
0
 public function setUp()
 {
     $this->connection = \OC_DB::getConnection();
     if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
         $this->markTestSkipped("Test only relevant on Sqlite");
     }
     $dbPrefix = \OC::$server->getConfig()->getSystemValue("dbtableprefix");
     $this->tableName = uniqid($dbPrefix . "_enum_bit_test");
     $this->connection->exec("CREATE TABLE {$this->tableName}(t0 tinyint unsigned, t1 tinyint)");
 }
Ejemplo n.º 12
0
 /**
  * @param \Doctrine\DBAL\Schema\Schema $targetSchema
  * @return string
  */
 public function generateChangeScript(Schema $targetSchema)
 {
     $schemaDiff = $this->getDiff($targetSchema, $this->connection);
     $script = '';
     $sqls = $schemaDiff->toSql($this->connection->getDatabasePlatform());
     foreach ($sqls as $sql) {
         $script .= $this->convertStatementToScript($sql);
     }
     return $script;
 }
 /**
  * {@inheritdoc}
  */
 public function shouldBeRun()
 {
     $schemaManager = $this->connection->getSchemaManager();
     if (!$schemaManager->tablesExist('tl_member')) {
         return false;
     }
     $sql = $this->connection->getDatabasePlatform()->getListTableIndexesSQL('tl_member', $this->connection->getDatabase());
     $index = $this->connection->fetchAssoc($sql . " AND INDEX_NAME = 'username'");
     return '0' !== $index['Non_Unique'];
 }
Ejemplo n.º 14
0
 /**
  * @param array $row
  */
 private function processRow(array $row)
 {
     $fields = Type::getType(Type::TARRAY)->convertToPHPValue($row['data'], $this->connection->getDatabasePlatform());
     foreach ($fields as $field => $values) {
         $fieldType = $this->getFieldType($row['entity_id'], $field);
         $dataType = $this->normalizeDataTypeName($fieldType);
         $data = ['audit_id' => $row['id'], 'data_type' => $dataType, 'field' => $field, sprintf('old_%s', $dataType) => $this->parseValue($values['old']), sprintf('new_%s', $dataType) => $this->parseValue($values['new'])];
         $types = ['integer', 'string', 'string', $dataType, $dataType];
         $this->connection->insert('oro_audit_field', $data, $types);
     }
 }
Ejemplo n.º 15
0
 protected function setUp()
 {
     parent::setUp();
     $this->config = \OC::$server->getConfig();
     $this->connection = \OC::$server->getDatabaseConnection();
     if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) {
         $this->markTestSkipped('DB migration tests are not supported on OCI');
     }
     $this->manager = new \OC\DB\MDB2SchemaManager($this->connection);
     $this->tableName = strtolower($this->getUniqueID($this->config->getSystemValue('dbtableprefix', 'oc_') . 'test_'));
 }
Ejemplo n.º 16
0
 public function setUp()
 {
     $this->connection = \OC_DB::getConnection();
     if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
         $this->markTestSkipped("Test only relevant on MySql");
     }
     $dbPrefix = \OC::$server->getConfig()->getSystemValue("dbtableprefix");
     $this->tableName = uniqid($dbPrefix . "_innodb_test");
     $this->connection->exec("CREATE TABLE {$this->tableName}(id INT) ENGINE MyISAM");
     $this->repair = new \OC\Repair\InnoDB();
 }
 private function createProducts($rows)
 {
     $products = array();
     foreach ($rows as $row) {
         $data = array();
         foreach ($this->fields as $field => $metadata) {
             $data[$field] = Type::getType($metadata['type'])->convertToPhpValue($row[$metadata['column']], $this->conn->getDatabasePlatform());
         }
         $products[] = new ShopProduct($data);
     }
     return $products;
 }
Ejemplo n.º 18
0
 public function setUp()
 {
     $this->connection = \OC_DB::getConnection();
     if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) {
         $this->markTestSkipped('DB migration tests are not supported on OCI');
     }
     if ($this->connection->getDatabasePlatform() instanceof SQLServerPlatform) {
         $this->markTestSkipped('DB migration tests are not supported on MSSQL');
     }
     $this->manager = new \OC\DB\MDB2SchemaManager($this->connection);
     $this->tableName = 'test_' . uniqid();
 }
Ejemplo n.º 19
0
 public function setUp()
 {
     $this->connection = \OC_DB::getConnection();
     $this->config = \OC::$server->getConfig();
     if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
         $this->markTestSkipped("Test only relevant on MySql");
     }
     $dbPrefix = $this->config->getSystemValue("dbtableprefix");
     $this->tableName = uniqid($dbPrefix . "_collation_test");
     $this->connection->exec("CREATE TABLE {$this->tableName}(text VARCHAR(16)) COLLATE utf8_unicode_ci");
     $this->repair = new TestCollationRepair($this->config, $this->connection);
 }
Ejemplo n.º 20
0
 protected function setUp()
 {
     parent::setUp();
     $this->connection = \OC_DB::getConnection();
     if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) {
         $this->markTestSkipped('DB migration tests are not supported on OCI');
     }
     if ($this->connection->getDatabasePlatform() instanceof SQLServerPlatform) {
         $this->markTestSkipped('DB migration tests are not supported on MSSQL');
     }
     $this->manager = new \OC\DB\MDB2SchemaManager($this->connection);
     $this->tableName = strtolower($this->getUniqueID('oc_test_'));
 }
Ejemplo n.º 21
0
 protected function setUp()
 {
     parent::setUp();
     $this->connection = \OC::$server->getDatabaseConnection();
     $this->config = \OC::$server->getConfig();
     if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
         $this->markTestSkipped("Test only relevant on Sqlite");
     }
     $dbPrefix = $this->config->getSystemValue('dbtableprefix', 'oc_');
     $this->tableName = $this->getUniqueID($dbPrefix . 'autoinc_test');
     $this->connection->exec('CREATE TABLE ' . $this->tableName . '("someid" INTEGER NOT NULL, "text" VARCHAR(16), PRIMARY KEY("someid"))');
     $this->repair = new \OC\Repair\SqliteAutoincrement($this->connection);
 }
 protected function setUp()
 {
     if (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers())) {
         self::markTestSkipped('This test requires SQLite support in your environment');
     }
     $this->con = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'memory' => true]);
     // import the schema
     $schema = new Schema($this->getOptions());
     foreach ($schema->toSql($this->con->getDatabasePlatform()) as $sql) {
         $this->con->exec($sql);
     }
     $this->sid = UserSecurityIdentity::fromAccount(new User('jimmy', 'jimmypass'));
     $this->aclProvider = $this->getProvider();
 }
 protected function _getConnection()
 {
     if (!isset(self::$_conn)) {
         self::$_conn = DriverManager::getConnection($this->_getDbParams(), new Configuration());
         self::$_conn->getEventManager()->addEventSubscriber(new ORMSchemaEventSubscriber());
         Configurator::configure(self::$_conn->getConfiguration());
         if (!Type::hasType('tsvector')) {
             Type::addType('tsvector', 'Doctrine\\DBAL\\Types\\TextType');
         }
         $platform = self::$_conn->getDatabasePlatform();
         $platform->registerDoctrineTypeMapping('tsvector', 'tsvector');
     }
     return self::$_conn;
 }
 protected function _getConnection()
 {
     if (!isset(self::$_conn)) {
         $dbParams = array('driver' => $GLOBALS['db_type'], 'user' => $GLOBALS['db_username'], 'password' => $GLOBALS['db_password'], 'host' => $GLOBALS['db_host'], 'dbname' => $GLOBALS['db_name'], 'port' => $GLOBALS['db_port']);
         self::$_conn = DriverManager::getConnection($dbParams, new Configuration());
         self::$_conn->getEventManager()->addEventSubscriber(new ORMSchemaEventSubscriber());
         Configurator::configure(self::$_conn->getConfiguration());
         if (!Type::hasType('tsvector')) {
             Type::addType('tsvector', 'Doctrine\\DBAL\\Types\\TextType');
         }
         $platform = self::$_conn->getDatabasePlatform();
         $platform->registerDoctrineTypeMapping('tsvector', 'tsvector');
     }
     return self::$_conn;
 }
Ejemplo n.º 25
0
 /**
  * Initializes a new <tt>BasicEntityPersister</tt> that uses the given EntityManager
  * and persists instances of the class described by the given ClassMetadata descriptor.
  *
  * @param Doctrine\ORM\EntityManager $em
  * @param Doctrine\ORM\Mapping\ClassMetadata $class
  */
 public function __construct(EntityManager $em, ClassMetadata $class)
 {
     $this->_em = $em;
     $this->_class = $class;
     $this->_conn = $em->getConnection();
     $this->_platform = $this->_conn->getDatabasePlatform();
 }
Ejemplo n.º 26
0
 /**
  * Poll across the complete execution table to find suspended workflows ready for execution.
  * 
  * @param int $limit
  * @param int $offset
  * @return array
  */
 public function pollSuspendedExecutionIds($limit = null, $offset = null)
 {
     $platform = $this->conn->getDatabasePlatform();
     $query = 'SELECT execution_id FROM ' . $this->options->executionTable() . ' ' . 'WHERE execution_next_poll_date < ?';
     if ($limit) {
         $query = $platform->modifyLimitQuery($query, $limit, $offset);
     }
     $stmt = $this->conn->prepare($query);
     $stmt->bindParam(1, date_create('now')->format($platform->getDateTimeFormatString()));
     $stmt->execute();
     $executionIds = array();
     while ($executionId = $stmt->fetchColumn()) {
         $executionIds[] = $executionId;
     }
     return $executionIds;
 }
Ejemplo n.º 27
0
 /**
  * Creates a new <tt>Statement</tt> for the given SQL and <tt>Connection</tt>.
  *
  * @param string                    $sql  The SQL of the statement.
  * @param \Doctrine\DBAL\Connection $conn The connection on which the statement should be executed.
  */
 public function __construct($sql, Connection $conn)
 {
     $this->sql = $sql;
     $this->stmt = $conn->getWrappedConnection()->prepare($sql);
     $this->conn = $conn;
     $this->platform = $conn->getDatabasePlatform();
 }
Ejemplo n.º 28
0
 /**
  * @param string $query
  * @param array|Doctrine\Common\Collections\ArrayCollection $params
  * @param array $types
  * @param string $source
  *
  * @return array
  */
 protected function dumpQuery($query, $params, array $types = [], $source = NULL)
 {
     if ($params instanceof ArrayCollection) {
         $tmp = [];
         $tmpTypes = [];
         foreach ($params as $key => $param) {
             if ($param instanceof Doctrine\ORM\Query\Parameter) {
                 $tmpTypes[$param->getName()] = $param->getType();
                 $tmp[$param->getName()] = $param->getValue();
                 continue;
             }
             $tmp[$key] = $param;
         }
         $params = $tmp;
         $types = $tmpTypes;
     }
     // query
     $s = '<p><b>Query</b></p><table><tr><td class="nette-Doctrine2Panel-sql">';
     $s .= self::highlightQuery(static::formatQuery($query, $params, $types, $this->connection ? $this->connection->getDatabasePlatform() : NULL));
     $s .= '</td></tr></table>';
     $e = NULL;
     if ($source && is_array($source)) {
         list($file, $line) = $source;
         $e = '<p><b>File:</b> ' . self::editorLink($file, $line) . '</p>';
     }
     // styles and dump
     return $this->renderStyles() . '<div class="nette-inner tracy-inner nette-Doctrine2Panel">' . $e . $s . '</div>';
 }
Ejemplo n.º 29
0
 /**
  * @param Schema $targetSchema
  * @param \Doctrine\DBAL\Connection $connection
  * @return \Doctrine\DBAL\Schema\SchemaDiff
  */
 protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection)
 {
     $platform = $connection->getDatabasePlatform();
     $platform->registerDoctrineTypeMapping('tinyint unsigned', 'integer');
     $platform->registerDoctrineTypeMapping('smallint unsigned', 'integer');
     return parent::getDiff($targetSchema, $connection);
 }
 protected function createDB()
 {
     $schema = new Schema($this->tableNames);
     foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
         $this->connection->exec($sql);
     }
 }