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


PHP Piwik::createDatabase方法代码示例

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


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

示例1: setUp

 /**
  * Setup the database and create the base tables for all tests
  */
 public function setUp()
 {
     parent::setUp();
     try {
         Piwik::createConfigObject();
         Piwik_Config::getInstance()->setTestEnvironment();
         $dbConfig = Piwik_Config::getInstance()->database;
         $dbName = $dbConfig['dbname'];
         $dbConfig['dbname'] = null;
         Piwik::createDatabaseObject($dbConfig);
         Piwik::dropDatabase();
         Piwik::createDatabase($dbName);
         Piwik::disconnectDatabase();
         Piwik::createDatabaseObject();
         Piwik::createTables();
         Piwik::createLogObject();
         Piwik_PluginsManager::getInstance()->loadPlugins(array());
     } catch (Exception $e) {
         $this->fail("TEST INITIALIZATION FAILED: " . $e->getMessage());
     }
     include "DataFiles/SearchEngines.php";
     include "DataFiles/Languages.php";
     include "DataFiles/Countries.php";
     include "DataFiles/Currencies.php";
     include "DataFiles/LanguageToCountry.php";
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:29,代码来源:DatabaseTestCase.php

示例2: setUpBeforeClass

 public static function setUpBeforeClass($dbName = false, $createEmptyDatabase = true, $createConfig = true)
 {
     try {
         Piwik::$piwikUrlCache = '';
         if ($createConfig) {
             self::createTestConfig();
         }
         if ($dbName === false) {
             $dbName = Piwik_Config::getInstance()->database['dbname'];
         }
         self::connectWithoutDatabase();
         if ($createEmptyDatabase) {
             Piwik::dropDatabase();
         }
         Piwik::createDatabase($dbName);
         Piwik::disconnectDatabase();
         // reconnect once we're sure the database exists
         Piwik_Config::getInstance()->database['dbname'] = $dbName;
         Piwik::createDatabaseObject();
         Piwik::createTables();
         Piwik::createLogObject();
         Piwik_PluginsManager::getInstance()->loadPlugins(array());
     } catch (Exception $e) {
         self::fail("TEST INITIALIZATION FAILED: " . $e->getMessage());
     }
     include "DataFiles/SearchEngines.php";
     include "DataFiles/Languages.php";
     include "DataFiles/Countries.php";
     include "DataFiles/Currencies.php";
     include "DataFiles/LanguageToCountry.php";
     Piwik::createAccessObject();
     Piwik_PostEvent('FrontController.initAuthenticationObject');
     // We need to be SU to create websites for tests
     Piwik::setUserIsSuperUser();
     // Load and install plugins
     $pluginsManager = Piwik_PluginsManager::getInstance();
     $plugins = $pluginsManager->readPluginsDirectory();
     $pluginsManager->loadPlugins($plugins);
     if ($createEmptyDatabase) {
         $pluginsManager->installLoadedPlugins();
     }
     $_GET = $_REQUEST = array();
     $_SERVER['HTTP_REFERER'] = '';
     // Make sure translations are loaded to check messages in English
     Piwik_Translate::getInstance()->loadEnglishTranslation();
     Piwik_LanguagesManager_API::getInstance()->setLanguageForUser('superUserLogin', 'en');
     // List of Modules, or Module.Method that should not be called as part of the XML output compare
     // Usually these modules either return random changing data, or are already tested in specific unit tests.
     self::setApiNotToCall(self::$defaultApiNotToCall);
     self::setApiToCall(array());
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:51,代码来源:IntegrationTestCase.php

示例3: __construct

 function __construct($title = '')
 {
     parent::__construct($title);
     print "The test class extends Test_Database: the test Piwik database is created once in the constructor, and all tables are truncated at the end of EACH unit test method.<br>";
     Piwik::createConfigObject();
     Piwik::createDatabaseObject();
     Zend_Registry::get('config')->setTestEnvironment();
     Zend_Registry::get('config')->disableSavingConfigurationFileUpdates();
     Piwik::createLogObject();
     Piwik::dropDatabase();
     Piwik::createDatabase();
     Piwik::disconnectDatabase();
     Piwik::createDatabaseObject();
     Piwik::createTables();
 }
开发者ID:klando,项目名称:pgpiwik,代码行数:15,代码来源:Database.test.php

示例4: databaseSetup

 function databaseSetup()
 {
     $this->checkPreviousStepIsValid(__FUNCTION__);
     // case the user hits the back button
     $_SESSION['skipThisStep']['firstWebsiteSetup'] = false;
     $_SESSION['skipThisStep']['displayJavascriptCode'] = false;
     $view = new Piwik_Install_View($this->pathView . 'databaseSetup.tpl', $this->getInstallationSteps(), __FUNCTION__);
     $this->skipThisStep(__FUNCTION__);
     $view->showNextStep = false;
     require_once "FormDatabaseSetup.php";
     $form = new Piwik_Installation_FormDatabaseSetup();
     if ($form->validate()) {
         $dbInfos = array('host' => $form->getSubmitValue('host'), 'username' => $form->getSubmitValue('username'), 'password' => $form->getSubmitValue('password'), 'dbname' => $form->getSubmitValue('dbname'), 'tables_prefix' => $form->getSubmitValue('tables_prefix'), 'adapter' => Zend_Registry::get('config')->database->adapter, 'port' => Zend_Registry::get('config')->database->port);
         if (($portIndex = strpos($dbInfos['host'], ':')) !== false) {
             $dbInfos['port'] = substr($dbInfos['host'], $portIndex + 1);
             $dbInfos['host'] = substr($dbInfos['host'], 0, $portIndex);
         }
         try {
             try {
                 Piwik::createDatabaseObject($dbInfos);
             } catch (Zend_Db_Adapter_Exception $e) {
                 // database not found, we try to create  it
                 if (ereg('[1049]', $e->getMessage())) {
                     $dbInfosConnectOnly = $dbInfos;
                     $dbInfosConnectOnly['dbname'] = null;
                     Piwik::createDatabaseObject($dbInfosConnectOnly);
                     Piwik::createDatabase($dbInfos['dbname']);
                     $_SESSION['databaseCreated'] = true;
                 }
             }
             $mysqlVersion = Piwik::getMysqlVersion();
             $minimumMysqlVersion = Zend_Registry::get('config')->General->minimum_mysql_version;
             if (version_compare($mysqlVersion, $minimumMysqlVersion) === -1) {
                 throw new Exception(vsprintf("Your MySQL version is %s but Piwik requires at least %s.", array($mysqlVersion, $minimumMysqlVersion)));
             }
             $_SESSION['db_infos'] = $dbInfos;
             $this->redirectToNextStep(__FUNCTION__);
         } catch (Exception $e) {
             $view->errorMessage = $e->getMessage();
         }
     }
     $view->addForm($form);
     $view->infos = $this->getSystemInformation();
     echo $view->render();
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:45,代码来源:Controller.php

示例5: __construct

 function __construct($title = '')
 {
     parent::__construct($title);
     try {
         Piwik::createConfigObject();
         Piwik_Config::getInstance()->setTestEnvironment();
         Piwik::createDatabaseObject();
         Piwik::createLogObject();
         Piwik::dropDatabase();
         Piwik::createDatabase();
         Piwik::disconnectDatabase();
         Piwik::createDatabaseObject();
         Piwik::createTables();
         Piwik_PluginsManager::getInstance()->installLoadedPlugins();
     } catch (Exception $e) {
         echo $e->getMessage();
         echo "<br/><b>TEST INITIALIZATION FAILED!";
         throw $e;
     }
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:20,代码来源:Database.test.php

示例6: createDatabaseObject

 /**
  * Creates database object based on form data.
  * 
  * @return array The database connection info. Can be passed into Piwik::createDatabaseObject.
  */
 public function createDatabaseObject()
 {
     $dbname = $this->getSubmitValue('dbname');
     if (empty($dbname)) {
         throw new Exception("No database name");
     }
     $adapter = $this->getSubmitValue('adapter');
     $port = Piwik_Db_Adapter::getDefaultPortForAdapter($adapter);
     $dbInfos = array('host' => $this->getSubmitValue('host'), 'username' => $this->getSubmitValue('username'), 'password' => $this->getSubmitValue('password'), 'dbname' => $dbname, 'tables_prefix' => $this->getSubmitValue('tables_prefix'), 'adapter' => $adapter, 'port' => $port);
     if (($portIndex = strpos($dbInfos['host'], '/')) !== false) {
         // unix_socket=/path/sock.n
         $dbInfos['port'] = substr($dbInfos['host'], $portIndex);
         $dbInfos['host'] = '';
     } else {
         if (($portIndex = strpos($dbInfos['host'], ':')) !== false) {
             // host:port
             $dbInfos['port'] = substr($dbInfos['host'], $portIndex + 1);
             $dbInfos['host'] = substr($dbInfos['host'], 0, $portIndex);
         }
     }
     try {
         @Piwik::createDatabaseObject($dbInfos);
     } catch (Zend_Db_Adapter_Exception $e) {
         $db = Piwik_Db_Adapter::factory($adapter, $dbInfos, $connect = false);
         // database not found, we try to create  it
         if ($db->isErrNo($e, '1049')) {
             $dbInfosConnectOnly = $dbInfos;
             $dbInfosConnectOnly['dbname'] = null;
             @Piwik::createDatabaseObject($dbInfosConnectOnly);
             @Piwik::createDatabase($dbInfos['dbname']);
             // select the newly created database
             @Piwik::createDatabaseObject($dbInfos);
         } else {
             throw $e;
         }
     }
     return $dbInfos;
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:43,代码来源:FormDatabaseSetup.php

示例7: databaseSetup

	/**
	 * Installation Step 3: Database Set-up
	 */
	function databaseSetup()
	{
		$this->checkPreviousStepIsValid( __FUNCTION__ );

		// case the user hits the back button
		$this->session->skipThisStep = array(
			'firstWebsiteSetup' => false,
			'displayJavascriptCode' => false,
		);

		$view = new Piwik_Installation_View(
						$this->pathView . 'databaseSetup.tpl',
						$this->getInstallationSteps(),
						__FUNCTION__
					);
		$this->skipThisStep( __FUNCTION__ );

		$view->showNextStep = false;

		$form = new Piwik_Installation_FormDatabaseSetup();

		if($form->validate())
		{
			$adapter = $form->getSubmitValue('adapter');
			$port = Piwik_Db_Adapter::getDefaultPortForAdapter($adapter);

			$dbInfos = array(
				'host'          => $form->getSubmitValue('host'),
				'username'      => $form->getSubmitValue('username'),
				'password'      => $form->getSubmitValue('password'),
				'dbname'        => $form->getSubmitValue('dbname'),
				'tables_prefix' => $form->getSubmitValue('tables_prefix'),
				'adapter'       => $adapter,
				'port'          => $port,
			);

			if(($portIndex = strpos($dbInfos['host'], '/')) !== false)
			{
				// unix_socket=/path/sock.n
				$dbInfos['port'] = substr($dbInfos['host'], $portIndex);
				$dbInfos['host'] = '';
			}
			else if(($portIndex = strpos($dbInfos['host'], ':')) !== false)
			{
				// host:port
				$dbInfos['port'] = substr($dbInfos['host'], $portIndex + 1 );
				$dbInfos['host'] = substr($dbInfos['host'], 0, $portIndex);
			}

			try{
				try {
					@Piwik::createDatabaseObject($dbInfos);
					$this->session->databaseCreated = true;
				} catch (Zend_Db_Adapter_Exception $e) {
					$db = Piwik_Db_Adapter::factory($adapter, $dbInfos, $connect = false);

					// database not found, we try to create  it
					if($db->isErrNo($e, '1049'))
					{
						$dbInfosConnectOnly = $dbInfos;
						$dbInfosConnectOnly['dbname'] = null;
						@Piwik::createDatabaseObject($dbInfosConnectOnly);
						@Piwik::createDatabase($dbInfos['dbname']);
						$this->session->databaseCreated = true;
					}
					else
					{
						throw $e;
					}
				}

				Piwik::checkDatabaseVersion();
				$this->session->databaseVersionOk = true;

				$this->session->db_infos = $dbInfos;
				$this->redirectToNextStep( __FUNCTION__ );
			} catch(Exception $e) {
				$view->errorMessage = $e->getMessage();
			}
		}
		$view->addForm($form);

		echo $view->render();
	}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:87,代码来源:Controller.php


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