PHP JDatabase примеры использования

PHP JDatabase - 30 примеров найдено. Это лучшие примеры PHP кода для JDatabase, полученные из open source проектов. Вы можете ставить оценку каждому примеру, чтобы помочь нам улучшить качество примеров.
Пример #1
0
 /**
  * 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);
 }
Пример #2
0
 /**
  * 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);
 }
Пример #3
0
 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;
     }
 }
Пример #4
0
	/**
	 * 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.'
		);
	}
Пример #5
0
 /**
  * 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);
     }
 }
Пример #6
0
	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;
	}
Пример #7
0
 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;
 }
Пример #8
0
 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);
     }
 }
Пример #9
0
 public function getNewItemid($id)
 {
     $query = 'SELECT k2_item_id,new_item_id,item_type from #__k2_recipe_map where k2_item_id =  ' . $id . ';';
     $query_set = $this->dbo->setQuery($query);
     $newitem = $this->dbo->loadObject();
     return $newitem;
 }
Пример #10
0
 public function getBrands()
 {
     $query = "SELECT a.group_id,u.*, ku.userName, ku.description, ku.image, ku.url FROM `#__user_usergroup_map` as a LEFT JOIN #__users as u ON u.id = a.user_id LEFT JOIN #__k2_users as ku ON ku.userID = a.user_id where a.group_id = 13;";
     $query_set = $this->dbo->setQuery($query);
     $items = $this->dbo->loadObjectList();
     return $items;
 }
Пример #11
0
 /**
  * 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);
     }
 }
 /**
  * удаление информации по бронированию с сайта, вубука и базы Визит-а
  */
 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));
 }
 /**
  * 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;
 }
Пример #14
0
 /**
  * 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;
 }
Пример #15
0
 /**
  * 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;
 }
Пример #16
0
 public function getK2Categories()
 {
     //$query = "SELECT * from #__k2_categories WHERE trash != 1 and published = 1 and extraFieldsGroup = 1 order by id;" ;
     $query = "SELECT * from #__k2_categories WHERE trash != 1 and published = 1 order by id;";
     $query_set = $this->dbo->setQuery($query);
     $categories = $this->dbo->loadObjectList();
     return $categories;
 }
 /**
  * отправляется запрос в базу локального сервера для окончательной проверки доступности для бронирования
  */
 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));
     }
 }
Пример #18
0
	public function getElementScripts(){
		$retArray = array();
		$this->db->setQuery("Select id, package, name, title, description, type From #__facileforms_scripts Where published = 1 And type = 'Element Validation'");
		$retArray['validation'] = $this->db->loadObjectList();
		$this->db->setQuery("Select id, package, name, title, description, type From #__facileforms_scripts Where published = 1 And type = 'Element Action'");
		$retArray['action'] = $this->db->loadObjectList();
		$this->db->setQuery("Select id, package, name, title, description, type From #__facileforms_scripts Where published = 1 And type = 'Element Init'");
		$retArray['init'] = $this->db->loadObjectList();;
		return $retArray;
	}
Пример #19
0
 /**
  * Count items.
  *
  * @return int
  */
 public function count()
 {
     $query = clone $this->query;
     $this->build($query);
     $query->select('COUNT(*)');
     $this->db->setQuery($query);
     $count = (int) $this->db->loadResult();
     KunenaError::checkDatabaseError();
     return $count;
 }
Пример #20
0
 /**
  * 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;
 }
Пример #21
0
 /**
  * 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();
 }
Пример #22
0
 /**
  * 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;
 }
Пример #23
0
 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);
 }
 /**
  * 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');
 }
Пример #25
0
 /**
  * Tests the JDatabase::quoteName method.
  *
  * @return  void
  *
  * @since   11.4
  */
 public function testQuoteName()
 {
     $this->assertThat($this->db->quoteName('test'), $this->equalTo('[test]'), 'Tests the left-right quotes on a string.');
     $this->assertThat($this->db->quoteName('a.test'), $this->equalTo('[a].[test]'), 'Tests the left-right quotes on a dotted string.');
     $this->assertThat($this->db->quoteName(array('a', 'test')), $this->equalTo(array('[a]', '[test]')), 'Tests the left-right quotes on an array.');
     $this->assertThat($this->db->quoteName(array('a.b', 'test.quote')), $this->equalTo(array('[a].[b]', '[test].[quote]')), 'Tests the left-right quotes on an array.');
     $this->assertThat($this->db->quoteName(array('a.b', 'test.quote'), array(null, 'alias')), $this->equalTo(array('[a].[b]', '[test].[quote] AS [alias]')), 'Tests the left-right quotes on an array.');
     $this->assertThat($this->db->quoteName(array('a.b', 'test.quote'), array('alias1', 'alias2')), $this->equalTo(array('[a].[b] AS [alias1]', '[test].[quote] AS [alias2]')), 'Tests the left-right quotes on an array.');
     $this->assertThat($this->db->quoteName((object) array('a', 'test')), $this->equalTo(array('[a]', '[test]')), 'Tests the left-right quotes on an object.');
     ReflectionHelper::setValue($this->db, 'nameQuote', '/');
     $this->assertThat($this->db->quoteName('test'), $this->equalTo('/test/'), 'Tests the uni-quotes on a string.');
 }
Пример #26
0
 /**
  * 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;
 }
 /**
  * @param $field
  * @param $data
  */
 protected function stringMatch($field, $data)
 {
     $wheres = array();
     foreach ($data as $match) {
         $match = trim($match);
         if (!empty($match)) {
             $wheres[] = $field . ' LIKE ' . $this->db->quote('%' . $this->db->escape($match, true) . '%');
         }
     }
     if (!empty($wheres)) {
         $this->filter_where[] = '(' . implode(' OR ', $wheres) . ')';
     }
 }
Пример #28
0
 public function loadK2ItemsMap()
 {
     $db = $this->dbo;
     $query = "select * from #__k2_recipe_map  ;";
     $query_set = $this->dbo->setQuery($query);
     $items = $this->dbo->loadObjectList();
     $this->k2_items_maps = array();
     foreach ($items as $key => $item) {
         $obj = new stdClass();
         $obj->item_type = $item->item_type;
         $obj->new_item_id = $item->new_item_id;
         $this->k2_items_maps[$item->k2_item_id] = $obj;
     }
 }
Пример #29
0
 function getAllAmount(&$params)
 {
     global $mainframe;
     jimport('joomla.database.database');
     jimport('joomla.database.table');
     $conf =& JFactory::getConfig();
     $host = $conf->getValue('config.host');
     $driver = $conf->getValue('config.dbtype');
     $options = array('driver' => $driver, 'host' => $params->get('dbhost'), 'user' => $params->get('dbuser'), 'password' => $params->get('dbpass'), 'database' => $params->get('dbname'), 'prefix' => "");
     $db =& JDatabase::getInstance($options);
     $query = "SELECT count(joborder.joborder_id) AS count FROM joborder,extra_field,user,company WHERE field_name LIKE('Job Orders') AND  extra_field.data_item_id = joborder.joborder_id AND joborder.status = 'active' AND joborder.entered_by = user.user_id  AND joborder.company_id = company.company_id AND joborder.public = '1'";
     $db->setQuery($query);
     $lists = $db->loadResult();
     return $lists;
 }
Пример #30
0
 function __construct()
 {
     parent::__construct();
     //pull settings from admin
     $db =& JFactory::getDBO();
     $db->setQuery("SELECT * From #__catonesettings limit 1");
     $SETTINGS = $db->loadObject();
     jimport('joomla.database.database');
     jimport('joomla.database.table');
     $conf =& JFactory::getConfig();
     // TODO: Cache on the fingerprint of the arguments
     $driver = $conf->getValue('config.dbtype');
     $optionDb = array('driver' => $driver, 'host' => $SETTINGS->OC_Database_host, 'user' => $SETTINGS->OC_Database_Username, 'password' => $SETTINGS->OC_Database_password, 'database' => $SETTINGS->OC_Database_Name, 'prefix' => "");
     $this->CatsDb =& JDatabase::getInstance($optionDb);
 }