当前位置: 首页>>代码示例>>PHP>>正文


PHP RedBeanDatabase::getDatabaseType方法代码示例

本文整理汇总了PHP中RedBeanDatabase::getDatabaseType方法的典型用法代码示例。如果您正苦于以下问题:PHP RedBeanDatabase::getDatabaseType方法的具体用法?PHP RedBeanDatabase::getDatabaseType怎么用?PHP RedBeanDatabase::getDatabaseType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RedBeanDatabase的用法示例。


在下文中一共展示了RedBeanDatabase::getDatabaseType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testBackupAndRestoreDatabase

 public function testBackupAndRestoreDatabase()
 {
     chdir(COMMON_ROOT . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'commands');
     // Create new database (zurmo_temp).
     if (RedBeanDatabase::getDatabaseType() == 'mysql') {
         $this->assertTrue(DatabaseCompatibilityUtil::createDatabase('mysql', $this->temporaryDatabaseHostname, $this->temporaryDatabaseUsername, $this->temporaryDatabasePassword, $this->temporaryDatabasePort, $this->temporaryDatabaseName));
         $connection = @mysql_connect($this->temporaryDatabaseHostname . ':' . $this->temporaryDatabasePort, $this->temporaryDatabaseUsername, $this->temporaryDatabasePassword);
         $this->assertTrue(is_resource($connection));
         @mysql_select_db($this->temporaryDatabaseName);
         @mysql_query("create table temptable (temptable_id int(11) unsigned not null)", $connection);
         @mysql_query("insert into temptable values ('5')", $connection);
         @mysql_query("insert into temptable values ('10')", $connection);
         $result = @mysql_query("SELECT count(*) from temptable");
         $totalRows = mysql_fetch_row($result);
         @mysql_close($connection);
         $this->assertEquals(2, $totalRows[0]);
         $command = "php zurmocTest.php database backup {$this->databaseBackupTestFile} mysql ";
         $command .= "{$this->temporaryDatabaseHostname} {$this->temporaryDatabaseName} ";
         $command .= "{$this->temporaryDatabasePort} {$this->temporaryDatabaseUsername} {$this->temporaryDatabasePassword}";
         if (!IS_WINNT) {
             $command .= ' 2>&1';
         }
         exec($command, $output);
         sleep(2);
         $this->assertTrue(is_file($this->databaseBackupTestFile));
         //Drop database, and restore it from backup.
         $this->assertTrue(DatabaseCompatibilityUtil::createDatabase('mysql', $this->temporaryDatabaseHostname, $this->temporaryDatabaseUsername, $this->temporaryDatabasePassword, $this->temporaryDatabasePort, $this->temporaryDatabaseName));
         // Ensure that database don't exist
         $connection = @mysql_connect($this->temporaryDatabaseHostname . ':' . $this->temporaryDatabasePort, $this->temporaryDatabaseUsername, $this->temporaryDatabasePassword);
         $this->assertTrue(is_resource($connection));
         @mysql_select_db($this->temporaryDatabaseName, $connection);
         $result = @mysql_query("SELECT count(*) from temptable", $connection);
         $this->assertFalse($result);
         // Now restore database
         $command = "php zurmocTest.php database restore {$this->databaseBackupTestFile} mysql ";
         $command .= "{$this->temporaryDatabaseHostname} {$this->temporaryDatabaseName} ";
         $command .= "{$this->temporaryDatabasePort} {$this->temporaryDatabaseUsername} {$this->temporaryDatabasePassword}";
         if (!IS_WINNT) {
             $command .= ' 2>&1';
         }
         exec($command, $output);
         sleep(2);
         $connection = @mysql_connect($this->temporaryDatabaseHostname . ':' . $this->temporaryDatabasePort, $this->temporaryDatabaseUsername, $this->temporaryDatabasePassword);
         $this->assertTrue(is_resource($connection));
         $result = @mysql_select_db($this->temporaryDatabaseName, $connection);
         $this->assertTrue($result);
         $result = @mysql_query("SELECT count(*) from temptable", $connection);
         $this->assertTrue(is_resource($result));
         $totalRows = mysql_fetch_row($result);
         $result = @mysql_query("SELECT * from temptable", $connection);
         $rows1 = mysql_fetch_row($result);
         $rows2 = mysql_fetch_row($result);
         @mysql_close($connection);
         $this->assertEquals(2, $totalRows[0]);
         $this->assertEquals(5, $rows1[0]);
         $this->assertEquals(10, $rows2[0]);
     }
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:58,代码来源:DatabaseCommandTest.php

示例2: testMapHintTypeIntoDatabaseColumnType

 public function testMapHintTypeIntoDatabaseColumnType()
 {
     if (RedBeanDatabase::getDatabaseType() == 'mysql') {
         $databaseColumnType = DatabaseCompatibilityUtil::mapHintTypeIntoDatabaseColumnType('blob');
         $this->assertEquals('BLOB', $databaseColumnType);
         $databaseColumnType = DatabaseCompatibilityUtil::mapHintTypeIntoDatabaseColumnType('longblob');
         $this->assertEquals('LONGBLOB', $databaseColumnType);
         $databaseColumnType = DatabaseCompatibilityUtil::mapHintTypeIntoDatabaseColumnType('boolean');
         $this->assertEquals('TINYINT(1)', $databaseColumnType);
         $databaseColumnType = DatabaseCompatibilityUtil::mapHintTypeIntoDatabaseColumnType('date');
         $this->assertEquals('DATE', $databaseColumnType);
         $databaseColumnType = DatabaseCompatibilityUtil::mapHintTypeIntoDatabaseColumnType('datetime');
         $this->assertEquals('DATETIME', $databaseColumnType);
         $databaseColumnType = DatabaseCompatibilityUtil::mapHintTypeIntoDatabaseColumnType('string');
         $this->assertEquals('VARCHAR(255)', $databaseColumnType);
         $databaseColumnType = DatabaseCompatibilityUtil::mapHintTypeIntoDatabaseColumnType('text');
         $this->assertEquals('TEXT', $databaseColumnType);
         $databaseColumnType = DatabaseCompatibilityUtil::mapHintTypeIntoDatabaseColumnType('longtext');
         $this->assertEquals('LONGTEXT', $databaseColumnType);
         $databaseColumnType = DatabaseCompatibilityUtil::mapHintTypeIntoDatabaseColumnType('id');
         $this->assertEquals('INT(11) UNSIGNED', $databaseColumnType);
         try {
             $databaseColumnType = DatabaseCompatibilityUtil::mapHintTypeIntoDatabaseColumnType('invalidType');
             $this->fail();
         } catch (NotSupportedException $e) {
             // Do nothing
         }
     }
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:29,代码来源:DatabaseCompatibilityUtilTest.php

示例3: dropStoredFunctionsAndProcedures

 public static function dropStoredFunctionsAndProcedures()
 {
     assert('RedBeanDatabase::isSetup()');
     if (RedBeanDatabase::getDatabaseType() == 'mysql') {
         try {
             $rows = ZurmoRedBean::getAll("select routine_name, routine_type from information_schema.routines;");
             foreach ($rows as $row) {
                 ZurmoRedBean::exec("drop {$row['routine_type']} if exists {$row['routine_name']}");
             }
         } catch (Exception $e) {
             if (isset($row)) {
                 echo "Failed to drop {$row['routine_type']} {$row['routine_name']}.\n";
             }
             throw $e;
         }
         if (YII_DEBUG) {
             ZurmoRedBean::exec("drop procedure if exists write_log");
         }
     } else {
         throw new NotSupportedException();
     }
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:22,代码来源:ZurmoDatabaseCompatibilityUtil.php

示例4: createIndex

 protected static function createIndex($tableName, $indexName, $columns = array())
 {
     assert('RedBeanDatabase::isSetup()');
     assert('$tableName != ""');
     assert('$indexName != ""');
     assert('!empty($columns)');
     if (RedBeanDatabase::getDatabaseType() == 'mysql') {
         try {
             $rows = R::getAll("SHOW INDEX FROM {$tableName}");
             if (!empty($rows)) {
                 foreach ($rows as $row) {
                     // Delete only first index in sequence
                     if ($row['Key_name'] == $indexName && $row['Seq_in_index'] == '1') {
                         R::exec("DROP INDEX {$indexName} ON {$tableName}");
                     }
                 }
             }
             $columnsString = implode(",", $columns);
             // Not Coding Standard
             R::exec("ALTER TABLE {$tableName}  ADD INDEX {$indexName} ({$columnsString});");
         } catch (Exception $e) {
             echo "Failed to add {$indexName} on  {$tableName}.\n";
             throw $e;
         }
     } else {
         throw new NotSupportedException();
     }
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:28,代码来源:ZurmoDatabaseCompatibilityUtil.php

示例5: resolveUnsignedByHintType

 public static function resolveUnsignedByHintType($hint, $assumeSigned = false, $hintName = null)
 {
     if (RedBeanDatabase::getDatabaseType() == 'mysql') {
         $integerHintTypes = array_keys(static::resolveIntegerMaxAllowedValuesByType());
         if (in_array($hint, $integerHintTypes) && (!$assumeSigned || StringUtil::endsWith($hintName, '_id'))) {
             return "UNSIGNED";
         }
         return null;
     }
     throw new NotSupportedException();
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:11,代码来源:DatabaseCompatibilityUtil.php

示例6: mapHintTypeIntoDatabaseColumnType

 /**
  * Map hint type into database valid type
  * @param string $hintType
  * @throws NotSupportedException
  * @return string
  */
 public static function mapHintTypeIntoDatabaseColumnType($hintType, $length = null)
 {
     $databaseColumnType = '';
     if (RedBeanDatabase::getDatabaseType() == 'mysql') {
         if (isset($length) && $length > 0 && $length < 255) {
             if ($hintType == 'string') {
                 $databaseColumnType = "VARCHAR({$length})";
             }
         } else {
             switch ($hintType) {
                 case 'blob':
                     $databaseColumnType = "BLOB";
                     break;
                 case 'longblob':
                     $databaseColumnType = "LONGBLOB";
                     break;
                 case 'boolean':
                     $databaseColumnType = "TINYINT(1)";
                     break;
                 case 'date':
                     $databaseColumnType = "DATE";
                     break;
                 case 'datetime':
                     $databaseColumnType = "DATETIME";
                     break;
                 case 'string':
                     $databaseColumnType = "VARCHAR(255)";
                     break;
                 case 'text':
                     $databaseColumnType = "TEXT";
                     break;
                 case 'longtext':
                     $databaseColumnType = "LONGTEXT";
                     break;
                 case 'id':
                     $databaseColumnType = "INT(11) UNSIGNED";
                     break;
             }
         }
     } else {
         throw new NotSupportedException();
     }
     if ($databaseColumnType == '') {
         throw new NotSupportedException();
     }
     return $databaseColumnType;
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:53,代码来源:DatabaseCompatibilityUtil.php


注:本文中的RedBeanDatabase::getDatabaseType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。