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


PHP JDatabaseDriver::execute方法代码示例

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


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

示例1: remove

 /**
  * Remove an extra image from database and file system.
  *
  * <code>
  * $imageId = 1;
  * $imagesFolder = "/.../folder";
  *
  * $image   = new CrowdFundingImageRemoverExtra(JFactory::getDbo(), $image, $imagesFolder);
  * $image->remove();
  * </code>
  */
 public function remove()
 {
     // Get the image
     $query = $this->db->getQuery(true);
     $query->select("a.image, a.thumb")->from($this->db->quoteName("#__crowdf_images", "a"))->where("a.id = " . (int) $this->imageId);
     $this->db->setQuery($query);
     $row = $this->db->loadObject();
     if (!empty($row)) {
         // Remove the image from the filesystem
         $file = JPath::clean($this->imagesFolder . DIRECTORY_SEPARATOR . $row->image);
         if (JFile::exists($file)) {
             JFile::delete($file);
         }
         // Remove the thumbnail from the filesystem
         $file = JPath::clean($this->imagesFolder . DIRECTORY_SEPARATOR . $row->thumb);
         if (JFile::exists($file)) {
             JFile::delete($file);
         }
         // Delete the record
         $query = $this->db->getQuery(true);
         $query->delete($this->db->quoteName("#__crowdf_images"))->where($this->db->quoteName("id") . " = " . (int) $this->imageId);
         $this->db->setQuery($query);
         $this->db->execute();
     }
 }
开发者ID:phpsource,项目名称:CrowdFunding,代码行数:36,代码来源:extra.php

示例2: onUserAfterDelete

 /**
  * Remove all sessions for the user name
  *
  * Method is called after user data is deleted from the database
  *
  * @param   array   $user    Holds the user data
  * @param   boolean $success True if user was successfully stored in the database
  * @param   string  $msg     Message
  *
  * @return  boolean
  *
  * @since   1.6
  */
 public function onUserAfterDelete($user, $success, $msg)
 {
     $userId = Joomla\Utilities\ArrayHelper::getValue($user, 'id', 0, 'int');
     if (!$success or !$userId) {
         return false;
     }
     // Remove profile images.
     $profile = new Socialcommunity\Profile\Profile($this->db);
     $profile->load(array('user_id' => $userId));
     if ($profile->getId()) {
         // Remove profile record.
         $query = $this->db->getQuery(true);
         $query->delete($this->db->quoteName('#__itpsc_profiles'))->where($this->db->quoteName('user_id') . '=' . (int) $userId);
         $this->db->setQuery($query);
         $this->db->execute();
         // Remove profile images.
         $params = JComponentHelper::getParams('com_socialcommunity');
         /** @var $params Joomla\Registry\Registry */
         jimport('Prism.libs.init');
         $filesystemHelper = new Prism\Filesystem\Helper($params);
         $mediaFolder = $filesystemHelper->getMediaFolder($userId);
         $filesystem = $filesystemHelper->getFilesystem();
         $profile->removeImages($filesystem, $mediaFolder);
     }
     return true;
 }
开发者ID:ITPrism,项目名称:SocialCommunityDistribution,代码行数:39,代码来源:socialcommunityuser.php

示例3: query

 /**
  * Execute the query
  *
  * @param  string                            $sql  The query (optional, it will use the setQuery one otherwise)
  * @return \mysqli_result|\resource|boolean        A database resource if successful, FALSE if not.
  *
  * @throws  \RuntimeException
  */
 public function query($sql = null)
 {
     if ($sql !== null) {
         $this->setQuery($sql);
     }
     return $this->_db->execute();
 }
开发者ID:bobozhangshao,项目名称:HeartCare,代码行数:15,代码来源:CmsDatabaseDriver.php

示例4: delete

	/**
	 * Method to delete a row from the database table by primary key value.
	 *
	 * @param   int|array  $pk  An optional primary key value (or array of key=>value pairs) to delete.  If not set the instance property value is used.
	 *
	 * @return  boolean  True on success.
	 *
	 * @link    http://docs.joomla.org/JTable/delete
	 * @throws  UnexpectedValueException
	 */
	public function delete($pk = null)
	{
		$k = $this->_tbl_key;
		$pk = (is_null($pk)) ? $this->{$k} : $pk;

		// If no primary key is given, return false.
		if ($pk === null)
		{
			throw new UnexpectedValueException('Null primary key not allowed.');
		}

		// Turn pk into array.
		if (!is_array($pk))
		{
			$pk = array($k => (int) $pk);
		}

		// Delete the row by primary key.
		$query = $this->_db->getQuery(true);
		$query->delete();
		$query->from($this->_tbl);

		foreach ($pk as $key=>$value)
		{
			$query->where($key . ' = ' . $this->_db->quote($value));
		}

		$this->_db->setQuery($query);

		// Delete items.
		$this->_db->execute();

		return true;
	}
开发者ID:BillVGN,项目名称:PortalPRP,代码行数:44,代码来源:map.php

示例5: hit

 /**
  * Register a hit on a record
  *
  * @param   integer  $oid  The primary key value of the record
  * @param   boolean  $log  Should I log the hit?
  *
  * @return  boolean  True on success
  */
 public function hit($oid = null, $log = false)
 {
     if (!$this->onBeforeHit($oid, $log)) {
         return false;
     }
     // If there is no hits field, just return true.
     $hits_field = $this->getColumnAlias('hits');
     if (!in_array($hits_field, $this->getKnownFields())) {
         return true;
     }
     $k = $this->_tbl_key;
     $pk = is_null($oid) ? $this->{$k} : $oid;
     // If no primary key is given, return false.
     if ($pk === null) {
         $result = false;
     } else {
         // Check the row in by primary key.
         $query = $this->_db->getQuery(true);
         $query->update($this->_tbl);
         $query->set($this->_db->qn($hits_field) . ' = (' . $this->_db->qn($hits_field) . ' + 1)');
         $query->where($this->_tbl_key . ' = ' . $this->_db->q($pk));
         $this->_db->setQuery($query);
         $this->_db->execute();
         // Set table values in the object.
         $this->hits++;
         $result = true;
     }
     if ($result) {
         $result = $this->onAfterHit($oid);
     }
     return $result;
 }
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:40,代码来源:table.php

示例6: storeVotes

 protected function storeVotes()
 {
     $query = $this->db->getQuery(true);
     $query->update($this->db->quoteName("#__uideas_items"))->set($this->db->quoteName("votes") . "=" . (int) $this->votes)->where($this->db->quoteName("id") . "=" . (int) $this->id);
     $this->db->setQuery($query);
     $this->db->execute();
 }
开发者ID:pippogsm,项目名称:UserIdeas,代码行数:7,代码来源:item.php

示例7: updateObject

 protected function updateObject()
 {
     $query = $this->db->getQuery(true);
     $query->update($this->db->quoteName("#__vc_transactions"))->set($this->db->quoteName("units") . "=" . $this->db->quote($this->units))->set($this->db->quoteName("txn_id") . "=" . $this->db->quote($this->txn_id))->set($this->db->quoteName("txn_amount") . "=" . $this->db->quote($this->txn_amount))->set($this->db->quoteName("txn_currency") . "=" . $this->db->quote($this->txn_currency))->set($this->db->quoteName("txn_status") . "=" . $this->db->quote($this->txn_status))->set($this->db->quoteName("txn_date") . "=" . $this->db->quote($this->txn_date))->set($this->db->quoteName("service_provider") . "=" . $this->db->quote($this->service_provider))->set($this->db->quoteName("currency_id") . "=" . $this->db->quote($this->currency_id))->set($this->db->quoteName("sender_id") . "=" . $this->db->quote($this->sender_id))->set($this->db->quoteName("receiver_id") . "=" . $this->db->quote($this->receiver_id))->where($this->db->quoteName("id") . "=" . (int) $this->id);
     $this->db->setQuery($query);
     $this->db->execute();
 }
开发者ID:bellodox,项目名称:VirtualCurrency,代码行数:7,代码来源:transaction.php

示例8: delete

 /**
  * Delete a record
  *
  * @param   integer $oid  The primary key value of the item to delete
  *
  * @throws  UnexpectedValueException
  *
  * @return  boolean  True on success
  */
 public function delete($oid = null)
 {
     if ($oid) {
         $this->load($oid);
     }
     $k = $this->_tbl_key;
     $pk = !$oid ? $this->{$k} : $oid;
     // If no primary key is given, return false.
     if (!$pk) {
         throw new UnexpectedValueException('Null primary key not allowed.');
     }
     // Execute the logic only if I have a primary key, otherwise I could have weird results
     if (!$this->onBeforeDelete($oid)) {
         return false;
     }
     // Delete the row by primary key.
     $query = $this->_db->getQuery(true);
     $query->delete();
     $query->from($this->_tbl);
     $query->where($this->_tbl_key . ' = ' . $this->_db->q($pk));
     $this->_db->setQuery($query);
     $this->_db->execute();
     $result = $this->onAfterDelete($oid);
     return $result;
 }
开发者ID:deenison,项目名称:joomla-cms,代码行数:34,代码来源:table.php

示例9: hit

	/**
	 * Method to increment the hits for a row if the necessary property/field exists.
	 *
	 * @return bool True on success.
	 *
	 * @internal param mixed $pk An optional primary key value to increment. If not set the instance property value is used.
	 *
	 * @since    K4.0
	 */
	public function hit()
	{
		$pk = null;

		// If there is no hits field, just return true.
		if (!property_exists($this, 'hits'))
		{
			return true;
		}

		$k= static::$tbl_keys;
		$pk = (is_null($pk)) ? $this->$k : $pk;

		// If no primary key is given, return false.
		if ($pk === null)
		{
			return false;
		}

		// Check the row in by primary key.
		$query = static::$db->getQuery(true);
		$query->update(static::$tbl);
		$query->set(static::$db->quoteName('hits') . ' = (' . static::$db->quoteName('hits') . ' + 1)');
		$query->where(static::$tbl_key . ' = ' . static::$db->quote($pk));
		static::$db->setQuery($query);
		static::$db->execute();

		// Set table values in the object.
		$this->hits++;

		return true;
	}
开发者ID:BillVGN,项目名称:PortalPRP,代码行数:41,代码来源:object.php

示例10: storeInDatabase

 /**
  * Stores the login data into the database
  *
  * @param   array $data Array holding data to be stored.
  *
  * @return bool
  * @since   1.0
  */
 public function storeInDatabase($data)
 {
     $query = $this->db->getQuery(true);
     $columns = array('userid', 'username', 'ip', 'timestamp');
     $values = $this->db->quote(array($data['userid'], $data['username'], $data['ip'], $data['timestamp']));
     $query->insert($this->db->quoteName('#__userlogin_tracking'))->columns($this->db->quoteName($columns))->values(implode(',', $values));
     $this->db->setQuery($query);
     try {
         $this->db->execute();
     } catch (Exception $e) {
         throw $e;
         // Do nothing
         return false;
     }
     return true;
 }
开发者ID:Bakual,项目名称:plg_userlogintracking_v1.0.0,代码行数:24,代码来源:userlogintracking.php

示例11: unmap

 /**
  * Unmap two contnet
  *
  * @param   string  $content_id1  The id of content 1
  * @param   string  $content_id2  The id of content 2
  *
  * @return  void
  *
  * @since   1.0
  */
 public function unmap($content_id1, $content_id2 = null)
 {
     $contentType = $this->state->get('content.type');
     // Check if the content type is set.
     if (empty($contentType)) {
         // Get the content type for the id.
         if (!is_null($content_id2)) {
             $results = $this->getTypes($content_id2);
             // Assert that the content type was found.
             if (empty($results[$content_id2])) {
                 throw new UnexpectedValueException(sprintf('%s->getItem() could not find the content type for item %s.', get_class($this), $content_id2));
             }
             // Set the content type alias.
             $contentType = $results[$content_id2]->type;
         } else {
             throw new UnexpectedValueException(sprintf('%s->getItem() could not find the content type for item %s.', get_class($this), $content_id2));
         }
     }
     $query = $this->db->getQuery(true);
     $query->clear();
     $query->delete();
     $query->from($this->db->quoteName('#__content_' . $contentType . '_map'));
     $query->where($this->db->quoteName('content_id') . '=' . $content_id1);
     if (!is_null($content_id2)) {
         $query->where($this->db->quoteName('tag_id') . '=' . $content_id2);
     }
     $this->db->setQuery($query);
     try {
         $this->db->execute();
     } catch (Exception $er) {
         return false;
     }
     return true;
 }
开发者ID:prox91,项目名称:joomla-dev,代码行数:44,代码来源:base.php

示例12: updateAmount

 /**
  * Update the amount of the account.
  *
  * <code>
  *  // Get user account by account ID
  *  $accountId = 1;
  *
  *  $account   = new VirtualCurrencyAccount();
  *  $account->setDb(JFactory::getDbo());
  *  $account->load($accountId);
  *
  *  // Increase the amount and store the new value.
  *  $account->increaseAmount(50);
  *  $account->updateAmount();
  * </code>
  */
 public function updateAmount()
 {
     $query = $this->db->getQuery(true);
     $query->update($this->db->quoteName("#__vc_accounts"))->set($this->db->quoteName("amount") . "=" . $this->db->quote($this->amount))->where($this->db->quoteName("id") . "=" . (int) $this->id);
     $this->db->setQuery($query);
     $this->db->execute();
 }
开发者ID:bellodox,项目名称:VirtualCurrency,代码行数:23,代码来源:account.php

示例13: createUser

 /**
  * Create user record in database.
  *
  * <code>
  * $data = array(
  *    "id"     => 1,
  *    "name"   => "John Dow",
  *    "state"  => 1,
  * );
  *
  * $user    = new IdentityProofUser(JFactory::getDbo());
  * $user->bind($data);
  * $user->createUser();
  * </code>
  */
 public function createUser()
 {
     $query = $this->db->getQuery(true);
     $query->insert($this->db->quoteName("#__identityproof_users"))->set($this->db->quoteName("id") . "=" . $this->db->quote($this->id))->set($this->db->quoteName("state") . "=" . $this->db->quote($this->state));
     $this->db->setQuery($query);
     $this->db->execute();
 }
开发者ID:xop32,项目名称:Proof-of-Identity,代码行数:22,代码来源:user.php

示例14: mergeStructure

 /**
  * Merges the incoming structure definition with the existing structure.
  *
  * @return  void
  *
  * @note    Currently only supports XML format.
  * @since   13.1
  * @throws  RuntimeException on error.
  */
 public function mergeStructure()
 {
     $prefix = $this->db->getPrefix();
     $tables = $this->db->getTableList();
     if ($this->from instanceof SimpleXMLElement) {
         $xml = $this->from;
     } else {
         $xml = new SimpleXMLElement($this->from);
     }
     // Get all the table definitions.
     $xmlTables = $xml->xpath('database/table_structure');
     foreach ($xmlTables as $table) {
         // Convert the magic prefix into the real table name.
         $tableName = (string) $table['name'];
         $tableName = preg_replace('|^#__|', $prefix, $tableName);
         if (in_array($tableName, $tables)) {
             // The table already exists. Now check if there is any difference.
             if ($queries = $this->getAlterTableSql($xml->database->table_structure)) {
                 // Run the queries to upgrade the data structure.
                 foreach ($queries as $query) {
                     $this->db->setQuery((string) $query);
                     $this->db->execute();
                 }
             }
         } else {
             // This is a new table.
             $sql = $this->xmlToCreate($table);
             $this->db->setQuery((string) $sql);
             $this->db->execute();
         }
     }
 }
开发者ID:adjaika,项目名称:J3Base,代码行数:41,代码来源:importer.php

示例15: updateFunds

 /**
  * Update project funds record.
  *
  * <code>
  * $projectId = 1;
  * $finds = 50;
  *
  * $project   = new CrowdFundingProject(JFactory::getDbo());
  * $project->load($projectId);
  * $project->addFunds($finds);
  * $project->updateFunds();
  * </code>
  */
 public function updateFunds()
 {
     $query = $this->db->getQuery(true);
     $query->update($this->db->quoteName("#__crowdf_projects"))->set($this->db->quoteName("funded") . "=" . $this->db->quote($this->funded))->where($this->db->quoteName("id") . "=" . $this->db->quote($this->id));
     $this->db->setQuery($query);
     $this->db->execute();
 }
开发者ID:phpsource,项目名称:CrowdFunding,代码行数:20,代码来源:project.php


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