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


PHP JFactory::database方法代码示例

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


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

示例1: setupDatabaseDriverOverride

 function setupDatabaseDriverOverride()
 {
     //override only the override file exist
     if (file_exists(dirname(__FILE__) . '/falang_database.php')) {
         require_once dirname(__FILE__) . '/falang_database.php';
         $conf = JFactory::getConfig();
         $host = $conf->get('host');
         $user = $conf->get('user');
         $password = $conf->get('password');
         $db = $conf->get('db');
         $dbprefix = $conf->get('dbprefix');
         $driver = $conf->get('dbtype');
         $debug = $conf->get('debug');
         $options = array('driver' => $driver, "host" => $host, "user" => $user, "password" => $password, "database" => $db, "prefix" => $dbprefix, "select" => true);
         $db = new JFalangDatabase($options);
         $db->debug($debug);
         if ($db->getErrorNum() > 2) {
             JError::raiseError('joomla.library:' . $db->getErrorNum(), 'JDatabase::getInstance: Could not connect to database <br/>' . $db->getErrorMsg());
         }
         // replace the database handle in the factory
         JFactory::$database = null;
         JFactory::$database = $db;
         $test = JFactory::getDBO();
     }
 }
开发者ID:fur81,项目名称:zofaxiopeu,代码行数:25,代码来源:falangdriver.php

示例2: setUpBeforeClass

	public static function setUpBeforeClass()
	{
		jimport('joomla.database.database');
		jimport('joomla.database.table');

		// Load the config if available.
		@ include_once JPATH_TESTS . '/config.php';
		if (class_exists('JTestConfig')) {
			$config = new JTestConfig;
		}

		if (!is_object(self :: $dbo)) {
			$options = array (
				'driver' => isset ($config) ? $config->dbtype : 'mysql',
				'host' => isset ($config) ? $config->host : '127.0.0.1',
				'user' => isset ($config) ? $config->user : 'utuser',
				'password' => isset ($config) ? $config->password : 'ut1234',
				'database' => isset ($config) ? $config->db : 'joomla_ut',
				'prefix' => isset ($config) ? $config->dbprefix : 'jos_'
			);

			self :: $dbo = JDatabase :: getInstance($options);

			if (JError :: isError(self :: $dbo)) {
				//ignore errors
				define('DB_NOT_AVAILABLE', true);
			}
		}
		self :: $database = JFactory :: $database;
		JFactory :: $database = self :: $dbo;
	}
开发者ID:realityking,项目名称:JAJAX,代码行数:31,代码来源:JoomlaDatabaseTestCase.php

示例3: setUp

	/**
	 * Sets up the fixture.
	 *
	 * This method is called before a test is executed.
	 *
	 * @return  void
	 *
	 * @since   11.1
	 */
	protected function setUp()
	{
		parent::setUp();

		$this->saveFactoryState();

		JFactory::$database = $this->getMockDatabase();
	}
开发者ID:robschley,项目名称:joomla-platform,代码行数:17,代码来源:JAdapterInstanceTest.php

示例4: setUpDb

 private function setUpDb()
 {
     $dbo = JDatabaseDriver::getInstance(array('driver' => 'sqlite', 'database' => '/Users/rouven/Sites/jd12dk/guestbook.sqlite'));
     $dbo->setQuery('CREATE TABLE IF NOT EXISTS Comments (Id INTEGER PRIMARY KEY, Name TEXT, Email TEXT, Comment Text, Ip INTEGER, date TEXT)');
     $dbo->execute();
     // Inject database into JFactory
     JFactory::$database = $dbo;
 }
开发者ID:realityking,项目名称:jd12dk,代码行数:8,代码来源:web.php

示例5: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   3.0
  */
 protected function setUp()
 {
     parent::setUp();
     // Store the factory state so we can mock the necessary objects
     $this->saveFactoryState();
     JFactory::$database = $this->getMockDatabase('Mysqli');
     // Register the object
     $this->object = JSchemaChangeset::getInstance(JFactory::getDbo(), null);
 }
开发者ID:klas,项目名称:joomla-cms,代码行数:17,代码来源:JSchemaChangesetTest.php

示例6: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   3.1
  */
 protected function setUp()
 {
     parent::setUp();
     // Store the factory state so we can mock the necessary objects
     $this->saveFactoryState();
     // Set up our mock database
     JFactory::$database = $this->getMockDatabase('Mysqli');
     FinderIndexerHelper::$stemmer = FinderIndexerStemmer::getInstance('porter_en');
 }
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:17,代码来源:FinderIndexerTokenTest.php

示例7: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   3.1
  */
 protected function setUp()
 {
     parent::setUp();
     $this->saveFactoryState();
     JFactory::$application = $this->getMockCmsApp();
     JFactory::$database = $this->getMockDatabase();
     $this->backupServer = $_SERVER;
     $_SERVER['HTTP_HOST'] = 'example.com';
     $_SERVER['SCRIPT_NAME'] = '';
 }
开发者ID:eshiol,项目名称:joomla-cms,代码行数:18,代码来源:JFormFieldPasswordTest.php

示例8: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   3.1
  */
 protected function setUp()
 {
     // Store the factory state so we can mock the necessary objects
     $this->saveFactoryState();
     // Set up our mock database
     $db = JFactory::getDbo();
     $db->name = 'mysqli';
     JFactory::$database = $db;
     FinderIndexerHelper::$stemmer = FinderIndexerStemmer::getInstance('porter_en');
 }
开发者ID:sural98,项目名称:joomla-cms,代码行数:18,代码来源:FinderIndexerTokenTest.php

示例9: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     // Store the factory state so we can mock the necessary objects
     $this->saveFactoryState();
     JFactory::$database = $this->getMockDatabase();
     // Set up our mock database
     $this->db = JFactory::getDbo();
     $this->db->name = 'mysqli';
     // Register the object
     $this->object = JSchemaChangeset::getInstance($this->db, null);
 }
开发者ID:karimzg,项目名称:joomla,代码行数:15,代码来源:JSchemaChangesetTest.php

示例10: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     parent::setUp();
     // Store the factory state so we can mock the necessary objects
     $this->saveFactoryState();
     JFactory::$application = $this->getMockCmsApp();
     JFactory::$database = $this->getMockDatabase('Mysqli');
     JFactory::$session = $this->getMockSession();
     // Register the object
     $this->object = FinderIndexer::getInstance();
 }
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:15,代码来源:FinderIndexerTest.php

示例11: restoreFactoryState

 /**
  * Sets the Factory pointers
  *
  * @return  void
  */
 protected function restoreFactoryState()
 {
     \JFactory::$application = $this->savedFactoryState['application'];
     \JFactory::$config = $this->savedFactoryState['config'];
     \JFactory::$dates = $this->savedFactoryState['dates'];
     \JFactory::$session = $this->savedFactoryState['session'];
     \JFactory::$language = $this->savedFactoryState['language'];
     \JFactory::$document = $this->savedFactoryState['document'];
     \JFactory::$acl = $this->savedFactoryState['acl'];
     \JFactory::$database = $this->savedFactoryState['database'];
     \JFactory::$mailer = $this->savedFactoryState['mailer'];
 }
开发者ID:Joal01,项目名称:fof,代码行数:17,代码来源:FOFTestCase.php

示例12: onAfterInitialise

 /**
  * Method to register a custom database driver
  *
  * @return void
  */
 public function onAfterInitialise()
 {
     $nenoLoader = JPATH_LIBRARIES . '/neno/loader.php';
     if (file_exists($nenoLoader)) {
         JLoader::register('NenoLoader', $nenoLoader);
         // Register the Class prefix in the autoloader
         NenoLoader::init();
         // Load custom driver.
         JFactory::$database = null;
         JFactory::$database = NenoFactory::getDbo();
     }
 }
开发者ID:andresmaeso,项目名称:neno,代码行数:17,代码来源:neno.php

示例13: loadDatabase

 /**
  * Allows the application to load a custom or default database driver.
  *
  * @param   JDatabaseDriver  $driver  An optional database driver object. If omitted, the application driver is created.
  *
  * @return  JApplicationBase This method is chainable.
  *
  * @since   12.1
  */
 public function loadDatabase(JDatabaseDriver $driver = null)
 {
     if ($driver === null) {
         $this->db = JDatabaseDriver::getInstance(array('driver' => $this->get('db_driver'), 'host' => $this->get('db_host'), 'user' => $this->get('db_user'), 'password' => $this->get('db_pass'), 'database' => $this->get('db_name'), 'prefix' => $this->get('db_prefix')));
         // Select the database.
         $this->db->select($this->get('db_name'));
     } else {
         $this->db = $driver;
     }
     // Set the database to our static cache.
     JFactory::$database = $this->db;
     return $this;
 }
开发者ID:yatan,项目名称:JiGS-PHP-RPG-engine,代码行数:22,代码来源:cli.php

示例14: __construct

 /**
  * Constructor: Deletes the default installation config file and recreates it with the good config file.
  *
  * @since  3.1
  */
 public function __construct()
 {
     // Overrides application config and set the configuration.php file so tokens and database works.
     JFactory::$config = null;
     JFactory::getConfig(JPATH_SITE . '/configuration.php');
     /*
      * JFactory::getDbo() gets called during app bootup, and because of the "uniqueness" of the install app, the config doesn't get read
      * correctly at that point.  So, we have to reset the factory database object here so that we can get a valid database configuration.
      * The day we have proper dependency injection will be a glorious one.
      */
     JFactory::$database = null;
     parent::__construct();
 }
开发者ID:klas,项目名称:joomla-cms,代码行数:18,代码来源:languages.php

示例15: doExecute

 /**
  * Entry point for CLI script
  *
  * @return  void
  *
  * @since   3.0
  */
 public function doExecute()
 {
     $nenoLoader = JPATH_LIBRARIES . '/neno/loader.php';
     if (file_exists($nenoLoader)) {
         JLoader::register('NenoLoader', $nenoLoader);
         // Register the Class prefix in the autoloader
         NenoLoader::init(false);
         // Load custom driver.
         JFactory::$database = null;
         JFactory::$database = NenoFactory::getDbo();
     }
     NenoTaskMonitor::runTask();
 }
开发者ID:javigomez,项目名称:neno,代码行数:20,代码来源:neno.php


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