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


PHP JDatabaseDriver::updateObject方法代码示例

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


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

示例1: store

	public function store($updateNulls = false)
	{
		if ($this->exists())
		{
			$ret = static::$db->updateObject(static::$tbl, $this, static::$tbl_keys, $updateNulls);
		}
		else
		{
			$ret = static::$db->insertObject(static::$tbl, $this, static::$tbl_keys);
		}

		if (static::$locked)
		{
			$this->unlock();
		}

		if (!$ret)
		{
			$this->setError(get_class($this) . '::store failed - ' . static::$db->getErrorMsg());

			return false;
		}

		$this->_exists = true;

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

示例2: doUpdate

 /**
  * Do update action.
  *
  * @param mixed $dataset    Data set contain data we want to update.
  * @param array $condFields The where condition tell us record exists or not, if not set,
  *                          will use primary key instead.
  *
  * @throws \Exception
  * @return  mixed Updated data set.
  */
 protected function doUpdate($dataset, array $condFields)
 {
     $this->db->transactionStart(true);
     try {
         foreach ($dataset as &$data) {
             $entity = new Entity($this->getFields($this->table), $data);
             $this->db->updateObject($this->table, $entity, $condFields);
         }
     } catch (\Exception $e) {
         $this->db->transactionRollback(true);
         throw $e;
     }
     $this->db->transactionCommit(true);
     return $dataset;
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:25,代码来源:DataMapper.php

示例3: store

 /**
  * Method to store a row in the database from the FOFTable instance properties.
  * If a primary key value is set the row with that primary key value will be
  * updated with the instance property values.  If no primary key value is set
  * a new row will be inserted into the database with the properties from the
  * FOFTable instance.
  *
  * @param   boolean  $updateNulls  True to update fields even if they are null.
  *
  * @return  boolean  True on success.
  */
 public function store($updateNulls = false)
 {
     if (!$this->onBeforeStore($updateNulls)) {
         return false;
     }
     $k = $this->_tbl_key;
     if ($this->{$k} == 0) {
         $this->{$k} = null;
     }
     // Create the object used for inserting/updating data to the database
     $fields = $this->getTableFields();
     $properties = $this->getKnownFields();
     $keys = array();
     foreach ($properties as $property) {
         // 'input' property is a reserved name
         if (isset($fields[$property])) {
             $keys[] = $property;
         }
     }
     $updateObject = array();
     foreach ($keys as $key) {
         $updateObject[$key] = $this->{$key};
     }
     $updateObject = (object) $updateObject;
     // If a primary key exists update the object, otherwise insert it.
     if ($this->{$k}) {
         $result = $this->_db->updateObject($this->_tbl, $updateObject, $this->_tbl_key, $updateNulls);
     } else {
         $result = $this->_db->insertObject($this->_tbl, $updateObject, $this->_tbl_key);
     }
     if ($result !== true) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $this->bind($updateObject);
     if ($this->_locked) {
         $this->_unlock();
     }
     $result = $this->onAfterStore();
     return $result;
 }
开发者ID:deenison,项目名称:joomla-cms,代码行数:52,代码来源:table.php

示例4: store

 /**
  * Method to store a row in the database from the JTable instance properties.
  * If a primary key value is set the row with that primary key value will be
  * updated with the instance property values.  If no primary key value is set
  * a new row will be inserted into the database with the properties from the
  * JTable instance.
  *
  * @param   boolean  $updateNulls  True to update fields even if they are null.
  *
  * @return  boolean  True on success.
  *
  * @link    http://docs.joomla.org/JTable/store
  * @since   11.1
  */
 public function store($updateNulls = false)
 {
     // Initialise variables.
     $k = $this->_tbl_key;
     if (!empty($this->asset_id)) {
         $currentAssetId = $this->asset_id;
     }
     // The asset id field is managed privately by this class.
     if ($this->_trackAssets) {
         unset($this->asset_id);
     }
     // If a primary key exists update the object, otherwise insert it.
     if ($this->{$k}) {
         $this->_db->updateObject($this->_tbl, $this, $this->_tbl_key, $updateNulls);
     } else {
         $this->_db->insertObject($this->_tbl, $this, $this->_tbl_key);
     }
     // If the table is not set to track assets return true.
     if (!$this->_trackAssets) {
         return true;
     }
     if ($this->_locked) {
         $this->_unlock();
     }
     /*
      * Asset Tracking
      */
     $parentId = $this->_getAssetParentId();
     $name = $this->_getAssetName();
     $title = $this->_getAssetTitle();
     $asset = self::getInstance('Asset', 'JTable', array('dbo' => $this->getDbo()));
     $asset->loadByName($name);
     // Re-inject the asset id.
     $this->asset_id = $asset->id;
     // Check for an error.
     $error = $asset->getError();
     if ($error) {
         $this->setError($error);
         return false;
     }
     // Specify how a new or moved node asset is inserted into the tree.
     if (empty($this->asset_id) || $asset->parent_id != $parentId) {
         $asset->setLocation($parentId, 'last-child');
     }
     // Prepare the asset to be stored.
     $asset->parent_id = $parentId;
     $asset->name = $name;
     $asset->title = $title;
     if ($this->_rules instanceof JAccessRules) {
         $asset->rules = (string) $this->_rules;
     }
     if (!$asset->check() || !$asset->store($updateNulls)) {
         $this->setError($asset->getError());
         return false;
     }
     // Create an asset_id or heal one that is corrupted.
     if (empty($this->asset_id) || $currentAssetId != $this->asset_id && !empty($this->asset_id)) {
         // Update the asset_id field in this table.
         $this->asset_id = (int) $asset->id;
         $query = $this->_db->getQuery(true);
         $query->update($this->_db->quoteName($this->_tbl));
         $query->set('asset_id = ' . (int) $this->asset_id);
         $query->where($this->_db->quoteName($k) . ' = ' . (int) $this->{$k});
         $this->_db->setQuery($query);
         $this->_db->execute();
     }
     return true;
 }
开发者ID:ranwaldo,项目名称:joomla-platform,代码行数:82,代码来源:table.php

示例5: store

 /**
  * Method to store a row in the database from the JTable instance properties.
  * If a primary key value is set the row with that primary key value will be
  * updated with the instance property values.  If no primary key value is set
  * a new row will be inserted into the database with the properties from the
  * JTable instance.
  *
  * @param   boolean  $updateNulls  True to update fields even if they are null.
  *
  * @return  boolean  True on success.
  *
  * @link    https://docs.joomla.org/JTable/store
  * @since   11.1
  */
 public function store($updateNulls = false)
 {
     $result = true;
     $k = $this->_tbl_keys;
     // Implement JObservableInterface: Pre-processing by observers
     $this->_observers->update('onBeforeStore', array($updateNulls, $k));
     $currentAssetId = 0;
     if (!empty($this->asset_id)) {
         $currentAssetId = $this->asset_id;
     }
     // The asset id field is managed privately by this class.
     if ($this->_trackAssets) {
         unset($this->asset_id);
     }
     // If a primary key exists update the object, otherwise insert it.
     if ($this->hasPrimaryKey()) {
         $this->_db->updateObject($this->_tbl, $this, $this->_tbl_keys, $updateNulls);
     } else {
         $this->_db->insertObject($this->_tbl, $this, $this->_tbl_keys[0]);
     }
     // If the table is not set to track assets return true.
     if ($this->_trackAssets) {
         if ($this->_locked) {
             $this->_unlock();
         }
         /*
          * Asset Tracking
          */
         $parentId = $this->_getAssetParentId();
         $name = $this->_getAssetName();
         $title = $this->_getAssetTitle();
         $asset = self::getInstance('Asset', 'JTable', array('dbo' => $this->getDbo()));
         $asset->loadByName($name);
         // Re-inject the asset id.
         $this->asset_id = $asset->id;
         // Check for an error.
         $error = $asset->getError();
         if ($error) {
             $this->setError($error);
             return false;
         } else {
             // Specify how a new or moved node asset is inserted into the tree.
             if (empty($this->asset_id) || $asset->parent_id != $parentId) {
                 $asset->setLocation($parentId, 'last-child');
             }
             // Prepare the asset to be stored.
             $asset->parent_id = $parentId;
             $asset->name = $name;
             $asset->title = $title;
             if ($this->_rules instanceof JAccessRules) {
                 $asset->rules = (string) $this->_rules;
             }
             if (!$asset->check() || !$asset->store($updateNulls)) {
                 $this->setError($asset->getError());
                 return false;
             } else {
                 // Create an asset_id or heal one that is corrupted.
                 if (empty($this->asset_id) || $currentAssetId != $this->asset_id && !empty($this->asset_id)) {
                     // Update the asset_id field in this table.
                     $this->asset_id = (int) $asset->id;
                     $query = $this->_db->getQuery(true)->update($this->_db->quoteName($this->_tbl))->set('asset_id = ' . (int) $this->asset_id);
                     $this->appendPrimaryKeys($query);
                     $this->_db->setQuery($query)->execute();
                 }
             }
         }
     }
     // Implement JObservableInterface: Post-processing by observers
     $this->_observers->update('onAfterStore', array(&$result));
     return $result;
 }
开发者ID:klas,项目名称:joomla-cms,代码行数:85,代码来源:table.php

示例6: store

 /**
  * Method to store a row in the database from the JTable instance properties.
  *
  * If a primary key value is set the row with that primary key value will be updated with the instance property values.
  * If no primary key value is set a new row will be inserted into the database with the properties from the JTable instance.
  *
  * @param   boolean  $updateNulls  True to update fields even if they are null.
  *
  * @return  boolean  True on success.
  *
  * @since   11.1
  */
 public function store($updateNulls = false)
 {
     $result = true;
     $k = $this->_tbl_keys;
     // Pre-processing by observers
     $event = AbstractEvent::create('onTableBeforeStore', ['subject' => $this, 'updateNulls' => $updateNulls, 'k' => $k]);
     $this->getDispatcher()->dispatch('onTableBeforeStore', $event);
     $currentAssetId = 0;
     if (!empty($this->asset_id)) {
         $currentAssetId = $this->asset_id;
     }
     // The asset id field is managed privately by this class.
     if ($this->_trackAssets) {
         unset($this->asset_id);
     }
     // We have to unset typeAlias since updateObject / insertObject will try to insert / update all public variables...
     $typeAlias = $this->typeAlias;
     unset($this->typeAlias);
     try {
         // If a primary key exists update the object, otherwise insert it.
         if ($this->hasPrimaryKey()) {
             $this->_db->updateObject($this->_tbl, $this, $this->_tbl_keys, $updateNulls);
         } else {
             $this->_db->insertObject($this->_tbl, $this, $this->_tbl_keys[0]);
         }
     } catch (\Exception $e) {
         $this->setError($e->getMessage());
         $result = false;
     }
     $this->typeAlias = $typeAlias;
     // If the table is not set to track assets return true.
     if ($this->_trackAssets) {
         if ($this->_locked) {
             $this->_unlock();
         }
         /*
          * Asset Tracking
          */
         $parentId = $this->_getAssetParentId();
         $name = $this->_getAssetName();
         $title = $this->_getAssetTitle();
         $asset = self::getInstance('Asset', 'JTable', array('dbo' => $this->getDbo()));
         $asset->loadByName($name);
         // Re-inject the asset id.
         $this->asset_id = $asset->id;
         // Check for an error.
         $error = $asset->getError();
         if ($error) {
             $this->setError($error);
             return false;
         } else {
             // Specify how a new or moved node asset is inserted into the tree.
             if (empty($this->asset_id) || $asset->parent_id != $parentId) {
                 $asset->setLocation($parentId, 'last-child');
             }
             // Prepare the asset to be stored.
             $asset->parent_id = $parentId;
             $asset->name = $name;
             $asset->title = $title;
             if ($this->_rules instanceof JAccessRules) {
                 $asset->rules = (string) $this->_rules;
             }
             if (!$asset->check() || !$asset->store($updateNulls)) {
                 $this->setError($asset->getError());
                 return false;
             } else {
                 // Create an asset_id or heal one that is corrupted.
                 if (empty($this->asset_id) || $currentAssetId != $this->asset_id && !empty($this->asset_id)) {
                     // Update the asset_id field in this table.
                     $this->asset_id = (int) $asset->id;
                     $query = $this->_db->getQuery(true)->update($this->_db->quoteName($this->_tbl))->set('asset_id = ' . (int) $this->asset_id);
                     $this->appendPrimaryKeys($query);
                     $this->_db->setQuery($query)->execute();
                 }
             }
         }
     }
     // Post-processing by observers
     $event = AbstractEvent::create('onTableAfterStore', ['subject' => $this, 'result' => &$result]);
     $this->getDispatcher()->dispatch('onTableAfterStore', $event);
     return $result;
 }
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:94,代码来源:table.php

示例7: updateOne

 /**
  * Do update action.
  *
  * @param string $table         The table name.
  * @param mixed  $data          Data set contain data we want to update.
  * @param array  $condFields    The where condition tell us record exists or not, if not set,
  *                              will use primary key instead.
  * @param bool   $updateNulls   Update empty fields or not.
  *
  * @throws \Exception
  * @return  mixed Updated data set.
  */
 public function updateOne($table, $data, array $condFields = array(), $updateNulls = false)
 {
     return $this->db->updateObject($table, $data, $condFields, $updateNulls);
 }
开发者ID:Biromain,项目名称:windwalker-joomla-rad,代码行数:16,代码来源:JoomlaAdapter.php


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