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


PHP JDatabase类代码示例

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


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

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

示例2: testTruncateTable

	/**
	 * Tests the JDatabase::truncateTable method.
	 *
	 * @return  void
	 *
	 * @since   12.1
	 */
	public function testTruncateTable()
	{
		$this->assertNull(
			$this->db->truncateTable('#__dbtest'),
			'truncateTable should not return anything if successful.'
		);
	}
开发者ID:robschley,项目名称:joomla-platform,代码行数:14,代码来源:JDatabaseTest.php

示例3:

 /**
  * Database object constructor
  *
  * @param	array	List of options used to configure the connection
  * @since	1.5
  * @see		JDatabase
  */
 function __construct($options)
 {
     $host = array_key_exists('host', $options) ? $options['host'] : 'localhost';
     $user = array_key_exists('user', $options) ? $options['user'] : '';
     $password = array_key_exists('password', $options) ? $options['password'] : '';
     $database = array_key_exists('database', $options) ? $options['database'] : '';
     $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : 'jos_';
     $select = array_key_exists('select', $options) ? $options['select'] : true;
     // Perform a number of fatality checks, then return gracefully
     if (!function_exists('mysql_connect')) {
         $this->_errorNum = 1;
         $this->_errorMsg = 'The MySQL adapter "mysql" is not available.';
         return;
     }
     // Connect to the server
     if (!($this->_connection = @mysql_connect($host, $user, $password, true))) {
         $this->_errorNum = 2;
         $this->_errorMsg = 'Could not connect to MySQL';
         return;
     }
     // Finalize initialisation
     parent::__construct($options);
     // select the database
     if ($select) {
         $this->select($database);
     }
 }
开发者ID:joebushi,项目名称:joomla,代码行数:34,代码来源:mysql.php

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

示例5: __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

示例6:

 /**
  * Database object constructor
  *
  * @param	array	List of options used to configure the connection
  * @since	1.5
  * @see		JDatabase
  */
 function __construct($options)
 {
     $host = array_key_exists('host', $options) ? $options['host'] : 'localhost';
     $user = array_key_exists('user', $options) ? $options['user'] : '';
     $password = array_key_exists('password', $options) ? $options['password'] : '';
     $database = array_key_exists('database', $options) ? $options['database'] : '';
     $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : 'jos_';
     $select = array_key_exists('select', $options) ? $options['select'] : true;
     // Perform a number of fatality checks, then return gracefully
     if (!function_exists('mysql_connect')) {
         $this->_errorNum = 1;
         $this->_errorMsg = JText::_('JLIB_DATABASE_ERROR_ADAPTER_MYSQL');
         return;
     }
     // Connect to the server
     if (!($this->_connection = @mysql_connect($host, $user, $password, true))) {
         $this->_errorNum = 2;
         $this->_errorMsg = JText::_('JLIB_DATABASE_ERROR_CONNECT_MYSQL');
         return;
     }
     // Finalize initialisation
     parent::__construct($options);
     // Set sql_mode to non_strict mode
     mysql_query("SET @@SESSION.sql_mode = '';", $this->_connection);
     // select the database
     if ($select) {
         $this->select($database);
     }
 }
开发者ID:akksi,项目名称:jcg,代码行数:36,代码来源:mysql.php

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

示例8: getOptions

 /**
  * Method to get the list of database options.
  *
  * This method produces a drop down list of available databases supported
  * by JDatabase drivers that are also supported by the application.
  *
  * @return  array    The field option objects.
  *
  * @since   11.3
  * @see		JDatabase
  */
 protected function getOptions()
 {
     // Initialize variables.
     // This gets the connectors available in the platform and supported by the server.
     $available = JDatabase::getConnectors();
     /**
      * This gets the list of database types supported by the application.
      * This should be entered in the form definition as a comma separated list.
      * If no supported databases are listed, it is assumed all available databases
      * are supported.
      */
     $supported = $this->element['supported'];
     if (!empty($supported)) {
         $supported = explode(',', $supported);
         foreach ($supported as $support) {
             if (in_array($support, $available)) {
                 $options[$support] = ucfirst($support);
             }
         }
     } else {
         foreach ($available as $support) {
             $options[$support] = ucfirst($support);
         }
     }
     // This will come into play if an application is installed that requires
     // a database that is not available on the server.
     if (empty($options)) {
         $options[''] = JText::_('JNONE');
     }
     return $options;
 }
开发者ID:jimyb3,项目名称:mathematicalteachingsite,代码行数:42,代码来源:databaseconnection.php

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

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

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

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

 /**
  * Method to get the content types.
  *
  * @return  array  An array of JContentType objects.
  *
  * @since   12.1
  * @throws  RuntimeException
  */
 public function getTypes()
 {
     $types = array();
     // Get the cache store id.
     $storeId = $this->getStoreId('getTypes');
     // Attempt to retrieve the types from cache first.
     $cached = $this->retrieve($storeId);
     // Check if the cached value is usable.
     if (is_array($cached)) {
         return $cached;
     }
     // Build the query to get the content types.
     $query = $this->db->getQuery(true);
     $query->select('a.*');
     $query->from($query->qn('#__content_types') . ' AS a');
     // Get the content types.
     $this->db->setQuery($query);
     $results = $this->db->loadObjectList();
     // Reorganize the type information.
     foreach ($results as $result) {
         // Create a new JContentType object.
         $type = $this->factory->getType();
         // Bind the type data.
         $type->bind($result);
         // Add the type, keyed by alias.
         $types[$result->alias] = $type;
     }
     // Store the types in cache.
     return $this->store($storeId, $types);
 }
开发者ID:prox91,项目名称:joomla-dev,代码行数:38,代码来源:helper.php

示例14: doExecute

 /**
  * Execute the application.
  *
  * @return  void
  */
 public function doExecute()
 {
     // Get the query builder class from the database and set it up
     // to select everything in the 'db' table.
     $query = $this->dbo->getQuery(true)->select('*')->from($this->dbo->qn('db'));
     // Push the query builder object into the database connector.
     $this->dbo->setQuery($query);
     // Get all the returned rows from the query as an array of objects.
     $rows = $this->dbo->loadObjectList();
     // Just dump the value returned.
     var_dump($rows);
 }
开发者ID:cuongnd,项目名称:etravelservice,代码行数:17,代码来源:ecr_comname.php

示例15: getK2Users

 public function getK2Users()
 {
     $query = "SELECT id, userID, userName, description, image, url from #__k2_users ;";
     $query_set = $this->dbo->setQuery($query);
     $items = $this->dbo->loadObjectList();
     return $items;
 }
开发者ID:rutvikd,项目名称:ak-recipes,代码行数:7,代码来源:migrate_k2_users.php


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