當前位置: 首頁>>代碼示例>>PHP>>正文


PHP JDatabase::getInstance方法代碼示例

本文整理匯總了PHP中JDatabase::getInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP JDatabase::getInstance方法的具體用法?PHP JDatabase::getInstance怎麽用?PHP JDatabase::getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在JDatabase的用法示例。


在下文中一共展示了JDatabase::getInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: removeBookings

 /**
  * удаление информации по бронированию с сайта, вубука и базы Визит-а
  */
 public function removeBookings($order_id)
 {
     $db_local = JDatabase::getInstance(VipLocalApi::getDbConnectOptions());
     $db = JFactory::getDBO();
     $booking_info = $this->getBookingInfo($db, $order_id);
     //echo'<pre>';var_dump($booking_info);echo'</pre>';die;
     if (!is_null($booking_info)) {
         if ($booking_info['k_zajav'] != 0) {
             // удаляем с локального сервера
             VipLocalApi::cancelReservation($db_local, $booking_info['k_zajav']);
         }
         $reservation_code = $booking_info['reservation_code'];
         if ($reservation_code == 0) {
             $reservation_code = intval($booking_info['wubook_answer']);
         }
         //echo'<pre>';var_dump($reservation_code);echo'</pre>';die;
         if ($reservation_code != 0) {
             //отменяем на вубуке
             WuBookApi::cancelReservation($reservation_code);
             //die;
         }
         //удаляем с сайта информацию о сроках бронирования
         $this->removeBookingInfo($db, $booking_info['id']);
     }
     //$this->removeOrder($db, $order_id);
     //$mainframe = JFactory::getApplication();
     //JError::raiseNotice(100, _JSHOP_ORDER_IS_CANCELED);
     //$mainframe->redirect(SEFLink('index.php?option=com_jshopping&controller=user&task=orders', 1, 1));
 }
開發者ID:aldegtyarev,項目名稱:vip-kvartira,代碼行數:32,代碼來源:remove_booking_on_cancel_order.php

示例3: __construct

 function __construct()
 {
     $params = $this->getParams();
     // bridge/phpbb path can be not set or doesn't exist, this would cause errors including configuration files
     if (!$params->get('bridge_path') || !JFolder::exists(JPATH_SITE . DS . $params->get('bridge_path')) || !$params->get('phpbb3_path') || !JFolder::exists(JPATH_SITE . DS . $params->get('phpbb3_path'))) {
         return;
     }
     $this->phpbb_path = $params->get('phpbb3_path');
     $this->bridge_path = $params->get('bridge_path');
     $this->bridge_params = $params;
     $this->link_format = $params->get('link_format', 'bridged');
     if (!JFile::exists(JPATH_ROOT . DS . $this->phpbb_path . DS . 'config.php')) {
         return;
     }
     //Include the phpBB3 configuration
     require JPATH_ROOT . DS . $this->phpbb_path . DS . 'config.php';
     // Config is incomplete
     if (!isset($dbms, $dbhost, $dbuser, $dbpasswd, $dbname, $table_prefix)) {
         return;
     }
     $options = array('driver' => $dbms, 'host' => $dbhost, 'user' => $dbuser, 'password' => $dbpasswd, 'database' => $dbname, 'prefix' => $table_prefix);
     $this->phpbb_db =& JDatabase::getInstance($options);
     if (JFile::exists(JPATH_ROOT . DS . $this->bridge_path . DS . 'configuration.php')) {
         //Include the bridge configuration
         require_once JPATH_ROOT . DS . $this->bridge_path . DS . 'includes' . DS . 'helper.php';
         //load phpBB3 elements
         JForumHelper::loadPHPBB3(JPATH_ROOT . DS . $this->bridge_path);
     }
 }
開發者ID:skyview059,項目名稱:e-learning-website,代碼行數:29,代碼來源:helper.php

示例4: getProfileFields

 protected function getProfileFields()
 {
     $settings = $this->loadSettings('facebook');
     $fields = array();
     $default = array((object) array('id' => 'xyz', 'name' => 'Configure DB Settings First'));
     if ($settings->get('db_table') == "") {
         return $default;
     } else {
         if ($settings->get('db_name') != "") {
             $options = array();
             $options['user'] = $settings->get('db_user');
             $options['password'] = $settings->get('db_password');
             $options['database'] = $settings->get('db_name');
             $dbo = JDatabase::getInstance($options);
         } else {
             $dbo = JFactory::getDBO();
         }
         $columns = $dbo->getTableColumns($settings->get('db_table'));
         if (!$columns) {
             return $default;
         }
         foreach ($columns as $key => $type) {
             $fields[] = (object) array('id' => $key, 'name' => $key);
         }
         return $fields;
     }
 }
開發者ID:q0821,項目名稱:esportshop,代碼行數:27,代碼來源:customdb.php

示例5: getMWDBO

 /**
  * Return a middleware database object
  *
  * @return     mixed
  */
 public static function getMWDBO()
 {
     static $instance;
     if (!is_object($instance)) {
         $config = Component::params('com_tools');
         $enabled = $config->get('mw_on');
         if (!$enabled && !App::isAdmin()) {
             return null;
         }
         $options['driver'] = $config->get('mwDBDriver');
         $options['host'] = $config->get('mwDBHost');
         $options['port'] = $config->get('mwDBPort');
         $options['user'] = $config->get('mwDBUsername');
         $options['password'] = $config->get('mwDBPassword');
         $options['database'] = $config->get('mwDBDatabase');
         $options['prefix'] = $config->get('mwDBPrefix');
         if ((!isset($options['password']) || $options['password'] == '') && (!isset($options['user']) || $options['user'] == '') && (!isset($options['database']) || $options['database'] == '')) {
             $instance = \App::get('db');
         } else {
             $instance = \JDatabase::getInstance($options);
             if ($instance instanceof Exception) {
                 $instance = \App::get('db');
             }
         }
     }
     if ($instance instanceof Exception) {
         return null;
     }
     return $instance;
 }
開發者ID:zooley,項目名稱:hubzero-cms,代碼行數:35,代碼來源:utils.php

示例6: getDBInstance

 /**
  * Get Database Default Settings
  */
 static function getDBInstance($driver = null, $host = null, $user = null, $password = null, $dbname = null, $prefix = null)
 {
     $app = JFactory::getApplication();
     $params = JComponentHelper::getParams('com_jmm');
     $dbsettings = $params->get('dbsettings');
     if ($dbsettings == 1) {
         $driver = $app->getCfg('dbtype');
         $host = $params->get('dbhost');
         $user = $params->get('dbusername');
         $password = $params->get('dbpass');
         if (isset($_REQUEST['dbname'])) {
             $dbname = JRequest::getVar('dbname');
         } else {
             $dbname = $params->get('dbname');
         }
         $prefix = $params->get('dbprefix');
     } else {
         if (!isset($driver)) {
             $driver = $app->getCfg('dbtype');
         }
         if (!isset($host)) {
             $host = $app->getCfg('host');
         }
         if (!isset($user)) {
             $user = $app->getCfg('user');
         }
         if (!isset($password)) {
             $password = $app->getCfg('password');
         }
         if (!isset($dbname)) {
             if (isset($_REQUEST['dbname'])) {
                 $dbname = JRequest::getVar('dbname');
             } else {
                 $dbname = $app->getCfg('db');
             }
         }
         if (!isset($prefix)) {
             $prefix = $app->getCfg('dbprefix');
         }
     }
     /**
      * If User Use Custom DB Configuration
      */
     $option = array();
     $option['driver'] = $driver;
     $option['host'] = $host;
     $option['user'] = $user;
     $option['password'] = $password;
     $option['database'] = $dbname;
     $option['prefix'] = $prefix;
     $db = JDatabase::getInstance($option);
     if ($dbname == '') {
         $dbLists = self::getDataBaseLists($db);
         if (count($dbLists) > 0) {
             JFactory::getApplication()->redirect('index.php?option=com_jmm&view=tables&dbname=' . $dbLists[0], 'DataBase Switched to ' . $dbLists[0]);
         }
     }
     return $db;
 }
開發者ID:jenia-buianov,項目名稱:all_my_sites,代碼行數:62,代碼來源:jmmcommon.php

示例7: __construct

 /**
  * Class constructor.
  *
  * This constructor invokes the parent JCli class constructor,
  * and then creates a connector to the database so that it is
  * always available to the application when needed.
  *
  * @return  void
  *
  * @since   11.3
  * @throws  JDatabaseException
  */
 public function __construct()
 {
     // Call the parent __construct method so it bootstraps the application class.
     parent::__construct();
     jimport('joomla.database.database');
     // Note, this will throw an exception if there is an error
     // creating the database connection.
     $this->dbo = JDatabase::getInstance(array('driver' => $this->get('dbDriver'), 'host' => $this->get('dbHost'), 'user' => $this->get('dbUser'), 'password' => $this->get('dbPass'), 'database' => $this->get('dbName'), 'prefix' => $this->get('dbPrefix')));
 }
開發者ID:robschley,項目名稱:joomla-platform-examples,代碼行數:21,代碼來源:run.php

示例8: chekBookingBeforeSave

 /**
  * отправляется запрос в базу локального сервера для окончательной проверки доступности для бронирования
  */
 public function chekBookingBeforeSave(&$order, &$cart)
 {
     $db_local = JDatabase::getInstance(VipLocalApi::getDbConnectOptions());
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $adv_user = JSFactory::getUser();
     $adv_user = JSFactory::getTable('usershop', 'jshop');
     $adv_user->load($user->id);
     $order->country = $adv_user->country;
     $order->f_name = $adv_user->f_name;
     $order->l_name = $adv_user->l_name;
     $order->email = $adv_user->email;
     $order->phone = $adv_user->phone;
     //		echo'<pre>';print_r($user);echo'</pre>';//die;
     //		echo'<pre>';print_r($adv_user);echo'</pre>';//die;
     //		echo'<pre>';print_r($order);echo'</pre>';die;
     $product_id_local = $cart->products[0]['ean'];
     $product_id = $cart->products[0]['product_id'];
     $category_id = $cart->products[0]['category_id'];
     $booking_date_info = $cart->products[0]['free_attributes_value'];
     //$date_from = '31-10-2015';
     $date_from = str_replace('/', '-', $booking_date_info[0]->value);
     $date_to = str_replace('/', '-', $booking_date_info[1]->value);
     //проверяем только локальный сервер, так как на WuBook-е установлена нотификация каждого нового бронирования.
     $object_is_free_on_local = $this->chekBookingOnLocal($db_local, $product_id_local, $date_from, $date_to);
     //$object_is_free_on_local = true;
     //повторно проверяем по базе сайта, чтобы никто не забронил номер пока пользователь "копается"
     $object_is_free_on_site = $this->chekBookingOnSite($db, $product_id, $date_from, $date_to);
     if ($object_is_free_on_local == true && $object_is_free_on_site == true) {
         //заменяем разделитеть даты
         $date_from = str_replace('/', '-', $date_from);
         $date_to = str_replace('/', '-', $date_to);
         //			echo'<pre>';print_r($product_id_local);echo'</pre>';//die;
         //			echo'<pre>';print_r($date_from);echo'</pre>';//die;
         //			echo'<pre>';print_r($date_to);echo'</pre>';//die;
         //			echo'<pre>';print_r($order);echo'</pre>';die;
         //			echo'<pre>';print_r($db_local);echo'</pre>';die;
         $k_zajav = VipLocalApi::addBookingOnLocalServer($db_local, $product_id_local, $date_from, $date_to, $order, VipLocalApi::ON_BOOKING_FROM_SITE_PRIM_PREFIX);
         //echo'<pre>';var_dump($k_zajav);echo'</pre>';die;
         $session = JFactory::getSession();
         $session->set("k_zajav", $k_zajav);
     } else {
         $cart->clear();
         $mainframe = JFactory::getApplication();
         JError::raiseNotice(100, _JSHOP_OBJECT_IS_ALREADY_BOOKED);
         $contextfilter = "jshoping.list.front.product.cat." . $category_id;
         $date_from_ = $mainframe->getUserStateFromRequest($contextfilter . 'dfrom', 'dfrom', date('d/m/Y'));
         $date_to_ = $mainframe->getUserStateFromRequest($contextfilter . 'dto', 'dto', date('d/m/Y', time() + 60 * 60 * 24));
         if ($date_from_ == '') {
             $date_from_ = date('d/m/Y');
         }
         if ($date_to_ == '') {
             $date_to_ = date('d/m/Y', time() + 60 * 60 * 24);
         }
         $mainframe->redirect(SEFLink('index.php?option=com_jshopping&view=category&layout=category&task=view&category_id=' . $category_id . '&dfrom=' . $date_from_ . '&dto=' . $date_to_, 1, 1));
     }
 }
開發者ID:aldegtyarev,項目名稱:vip-kvartira,代碼行數:60,代碼來源:check_booking_on_confirm_order.php

示例9: setUp

	/**
	 * Sets up the fixture, for example, opens a network connection.
	 * This method is called before a test is executed.
	 *
	 * @return void
	 */
	protected function setUp()
	{
		$this->db = JDatabase::getInstance(
			array(
				'driver' => 'nosql',
				'database' => 'europa',
				'prefix' => '&',
			)
		);
	}
開發者ID:robschley,項目名稱:joomla-platform,代碼行數:16,代碼來源:JDatabaseTest.php

示例10: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   11.1
  */
 protected function setUp()
 {
     @(include_once JPATH_TESTS . '/config_mysql.php');
     if (class_exists('JMySQLTestConfig')) {
         $config = new JMySQLTestConfig();
     } else {
         $this->markTestSkipped('There is no mysql test config file present.');
     }
     $this->object = JDatabase::getInstance(array('driver' => $config->dbtype, 'database' => $config->db, 'host' => $config->host, 'user' => $config->user, 'password' => $config->password));
     parent::setUp();
 }
開發者ID:GMaup,項目名稱:joomla-platform,代碼行數:19,代碼來源:JDatabaseMySQLTest.php

示例11: array

 /**
  * Method to get a JDatabase object.
  *
  * @param	string	$driver		The database driver to use.
  * @param	string	$host		The hostname to connect on.
  * @param	string	$user		The user name to connect with.
  * @param	string	$password	The password to use for connection authentication.
  * @param	string	$database	The database to use.
  * @param	string	$prefix		The table prefix to use.
  * @param	boolean $select		True if the database should be selected.
  *
  * @return	JDatabase
  * @since	1.0
  */
 public static function &getDBO($driver, $host, $user, $password, $database, $prefix, $select = true)
 {
     static $db;
     if (!$db) {
         // Build the connection options array.
         $options = array('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $prefix, 'select' => $select);
         // Get a database object.
         $db = JDatabase::getInstance($options);
     }
     return $db;
 }
開發者ID:brojask,項目名稱:colegio-abogados-joomla,代碼行數:25,代碼來源:database.php

示例12: exists

 /**
  * Determines if phpbb exists on the site
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function exists()
 {
     $file = JPATH_ROOT . '/' . $this->path . '/config.php';
     if (!JFile::exists($file)) {
         return false;
     }
     require_once $file;
     $options = array('driver' => $dbms, 'host' => $dbhost, 'user' => $dbuser, 'password' => $dbpasswd, 'database' => $dbname, 'prefix' => $table_prefix);
     $this->db = JDatabase::getInstance($options);
     return true;
 }
開發者ID:knigherrant,項目名稱:decopatio,代碼行數:19,代碼來源:client.php

示例13: getDB

 /**
  * Return DB object
  * Returns the $database object to trinity 
  */
 public static function getDB()
 {
     if (!isset(self::$db)) {
         $db = JDatabase::getInstance(self::getDBOptions());
         if ($db instanceof Exception) {
             jexit('Database Error: ' . (string) $db);
         } else {
             self::$db = $db;
         }
     }
     return self::$db;
 }
開發者ID:Jougito,項目名稱:DynWeb,代碼行數:16,代碼來源:jtrinitycoredb.php

示例14: up

 /**
  * Up
  **/
 public function up()
 {
     $rparams = $this->getParams('com_register');
     if (!empty($rparams)) {
         $values = $rparams->toArray();
         $this->db->setQuery("SELECT * FROM `#__extensions` WHERE `type`='component' AND `element`='com_members' LIMIT 1");
         if ($data = $this->db->loadAssoc()) {
             $component = new \JTableExtension($this->db);
             $component->bind($data);
             $mparams = new \Hubzero\Config\Registry($component->params);
             foreach ($values as $key => $value) {
                 $mparams->set($key, $value);
             }
             $component->params = $mparams->toString();
             $component->store();
         }
     }
     // Get the default menu identifier
     //$this->db->setQuery("SELECT menutype FROM `#__menu` WHERE home='1' LIMIT 1;");
     //$menutype = $this->db->loadResult();
     $this->db->setQuery("SELECT extension_id FROM `#__extensions` WHERE `type`='component' AND `element`='com_members'");
     $component = $this->db->loadResult();
     // Check if there's a menu item for com_register
     $this->db->setQuery("SELECT id FROM `#__menu` WHERE `alias`='register' AND `path`='register'");
     //" AND menutype=" . $this->db->quote($menutype));
     if ($id = $this->db->loadResult()) {
         // There is!
         // So, just update its link
         $this->db->setQuery("UPDATE `#__menu` SET `link`='index.php?option=com_members&view=register&layout=create', `component_id`=" . $this->db->quote($component) . " WHERE `id`=" . $this->db->quote($id));
         $this->db->query();
     } else {
         $this->db->setQuery("SELECT menutype FROM `#__menu` WHERE `home`='1' LIMIT 1;");
         $menutype = $this->db->loadResult();
         $this->db->setQuery("SELECT ordering FROM `#__menu` WHERE `menutype`=" . $this->db->quote($menutype) . " ORDER BY ordering DESC LIMIT 1");
         $ordering = intval($this->db->loadResult());
         $ordering++;
         // No menu item for com_register so we need to create one for the new com_members controler
         $query = "INSERT INTO `#__menu` (`id`, `menutype`, `title`, `alias`, `note`, `path`, `link`, `type`, `published`, `parent_id`, `level`, `component_id`, `ordering`, `checked_out`, `checked_out_time`, `browserNav`, `access`, `img`, `template_style_id`, `params`, `lft`, `rgt`, `home`, `language`, `client_id`)\n";
         $query .= "VALUES ('', '{$menutype}', 'Register', 'register', '', 'register', 'index.php?option=com_members&view=register&layout=create', 'component', 1, 1, 1, {$component}, {$ordering}, 0, '0000-00-00 00:00:00', 0, 1, '', 0, '', 0, 0, 0, '*', 0);";
         $this->db->setQuery($query);
         $this->db->query();
         // If we have the nested set class available, use it to rebuild lft/rgt
         if (class_exists('JTableNested') && method_exists('JTableNested', 'rebuild')) {
             // Use the MySQL driver for this
             $config = \JFactory::getConfig();
             $database = \JDatabase::getInstance(array('driver' => 'mysql', 'host' => $config->getValue('host'), 'user' => $config->getValue('user'), 'password' => $config->getValue('password'), 'database' => $config->getValue('db')));
             $table = new \JTableMenu($database);
             $table->rebuild();
             unset($database);
         }
     }
     $this->deleteComponentEntry('register');
 }
開發者ID:mined-gatech,項目名稱:hubzero-cms,代碼行數:56,代碼來源:Migration20140528145010ComRegister.php

示例15: __construct

 function __construct($options = array(), $driver_options = null)
 {
     //$this->adapter = \JFactory::getDBO();
     $params = array();
     $params['driver'] = $options['type'];
     $params['host'] = $options['host'];
     $params['user'] = $options['user'];
     $params['password'] = $options['pass'];
     $params['database'] = $options['name'];
     $params['prefix'] = $options['prefix'];
     $this->adapter = \JDatabase::getInstance($params);
 }
開發者ID:vstorm83,項目名稱:propertease,代碼行數:12,代碼來源:joomla.php


注:本文中的JDatabase::getInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。