本文整理匯總了PHP中JDatabase::updateObject方法的典型用法代碼示例。如果您正苦於以下問題:PHP JDatabase::updateObject方法的具體用法?PHP JDatabase::updateObject怎麽用?PHP JDatabase::updateObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類JDatabase
的用法示例。
在下文中一共展示了JDatabase::updateObject方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: store
/**
* Inserts a new row if id is zero or updates an existing row in the database table
*
* Can be overloaded/supplemented by the child class
*
* @access public
* @param boolean If false, null object variables are not updated
* @return null|string null if successful otherwise returns and error message
*/
function store($updateNulls = false)
{
$k = $this->_tbl_key;
if ($this->{$k}) {
$ret = $this->_db->updateObject($this->_tbl, $this, $this->_tbl_key, $updateNulls);
} else {
//loading libraries
$properties = $this->getProperties();
//loading resources
$user =& eFactory::getUser();
//initializing object properties
$this->_juser_id = $user->id;
$this->{$k} = create_guid();
if (array_key_exists('created_on', $properties)) {
$this->created_on = date('Y-m-d H:i:s', time());
}
if ($ret = $this->_db->insertObject($this->_tbl, $this, $this->_tbl_key)) {
$this->saveRelationship('juser');
}
}
if (!$ret) {
$this->setError(get_class($this) . '::store failed - ' . $this->_db->getErrorMsg());
return false;
} else {
return true;
}
}
示例2: migrateK2TagItems
public function migrateK2TagItems()
{
$items = $this->getK2TagMenuItems();
$re = "/.*&tag=(.*)&task/";
$component_id = $this->getComponentid('com_tags');
$tag_params = '{"show_tag_title":"","tag_list_show_tag_image":"","tag_list_show_tag_description":"","tag_list_image":"","tag_list_description":"","show_tag_num_items":"","tag_list_orderby":"","tag_list_orderby_direction":"","tag_list_show_item_image":"","tag_list_show_item_description":"","tag_list_item_maximum_characters":0,"filter_field":"","show_pagination_limit":"","show_pagination":"","show_pagination_results":"","return_any_or_all":"","include_children":"","maximum":24,"show_feed_link":"","menu-anchor_title":"","menu-anchor_css":"","menu_image":"","menu_text":1,"page_title":"","show_page_heading":"0","page_heading":"","pageclass_sfx":"","menu-meta_description":"Find healthy and breakfast recipes that you can make every morning in your kitchen in 30 minutes.","menu-meta_keywords":"","robots":"","secure":0,"mega_showtitle":"1","mega_desc":"","mega_tooltip":"0","mega_tooltip_content":"","mega_cols":"1","mega_group":"0","mega_width":"","mega_colw":"","mega_colxw":"","mega_class":"","submenu_align":"auto","mega_subcontent":"0"}';
foreach ($items as $key => $item) {
$link = $item->link;
$menu_id = $item->id;
preg_match($re, $link, $matches);
$k2_tag_name = $matches[1];
$this->out("K2 Tag Name = " . $k2_tag_name);
$new_tag_id = $this->getNewTagID($k2_tag_name);
if ($new_tag_id) {
$object = new stdClass();
$object->id = $menu_id;
$object->link = 'index.php?option=com_tags&view=tag&id[0]=' . $new_tag_id . '&types[0]=1&types[1]=16';
$object->component_id = $component_id;
$object->params = $tag_params;
$this->out("Updating menu with id " . $menu_id);
$this->out(" old link -> " . $item->link);
$this->out(" new link -> " . $object->link);
$this->dbo->updateObject('#__menu', $object, 'id');
} else {
$this->out("K2 Tag Name = " . $k2_tag_name . " has no new tagid");
}
}
}
示例3: updateRecipe
public function updateRecipe($recipe_id, $brand_id, $author_id)
{
$object = new stdClass();
$object->id = $recipe_id;
$object->created_by = $author_id;
$object->brand_id = $brand_id;
$result = $this->dbo->updateObject('#__akrecipes_recipe', $object, 'id');
return $result;
}
示例4: store
/**
* Inserts a new row if id is zero or updates an existing row in the database table
*
* Can be overloaded/supplemented by the child class
*
* @access public
* @param boolean If false, null object variables are not updated
* @return null|string null if successful otherwise returns and error message
*/
function store($updateNulls = false)
{
$k = $this->_tbl_key;
if ($this->{$k}) {
$ret = $this->_db->updateObject($this->_tbl, $this, $this->_tbl_key, $updateNulls);
} else {
$ret = $this->_db->insertObject($this->_tbl, $this, $this->_tbl_key);
}
if (!$ret) {
$this->setError(get_class($this) . '::store failed - ' . $this->_db->getErrorMsg());
return false;
} else {
return true;
}
}
示例5: doUpdate
/**
* Method to update an object in the database.
*
* @return void
*
* @since 12.1
* @throws RuntimeException
*/
protected function doUpdate()
{
// Get the primary key.
$primaryKey = $this->getTableKey('primary', 'primary');
try {
// Start a transaction.
$this->db->transactionStart();
// Update the data for each table.
foreach ($this->tables as $alias => $table) {
// Store the data to the database.
$dump = $this->dumpTable($alias);
$this->db->updateObject($table, $dump, $primaryKey);
}
// Commit the transaction.
$this->db->transactionCommit();
} catch (RuntimeException $error) {
// Rollback the transaction.
$this->db->transactionRollback();
// Rethrow the error.
throw $error;
}
}
示例6: migrateSpecific
public function migrateSpecific($module)
{
$id = $module->id;
$params = json_decode($module->params);
$newparams = new stdClass();
$newparams->layout = $this->getLayoutMapping($params->getTemplate);
$newparams->source = 'specific';
$newparams->recipes_sort_by = 'published';
$newparams->recipes_order_by = 'desc';
$newparams->recipe_count = 10;
$newparams->show_child_categories = 1;
$newparams->user = '';
$newparams->recipe_ids = $this->getRecipeIds($params->items);
$newparams->module_tag = $params->module_tag;
$newparams->bootstrap_size = $params->bootstrap_size;
$newparams->header_tag = $params->header_tag;
$newparams->header_class = $params->header_class;
$newparams->style = $newparams->style;
$object = new stdClass();
$object->id = $id;
$object->params = json_encode($newparams);
$object->module = 'mod_akrecipes_recipes';
$result = $this->dbo->updateObject('#__modules', $object, 'id');
}
示例7: 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}) {
$stored = $this->_db->updateObject($this->_tbl, $this, $this->_tbl_key, $updateNulls);
} else {
$stored = $this->_db->insertObject($this->_tbl, $this, $this->_tbl_key);
}
// If the store failed return false.
if (!$stored) {
$e = new JException(JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED', get_class($this), $this->_db->getErrorMsg()));
$this->setError($e);
return false;
}
// 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 = JTable::getInstance('Asset', 'JTable', array('dbo' => $this->getDbo()));
$asset->loadByName($name);
// Re-inject the asset id.
$this->asset_id = $asset->id;
// Check for an error.
if ($error = $asset->getError()) {
$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);
if (!$this->_db->execute()) {
$e = new JException(JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED_UPDATE_ASSET_ID', $this->_db->getErrorMsg()));
$this->setError($e);
return false;
}
}
return true;
}
示例8: updateObject
/**
* Update an object into a table
*
* @param AppTable $table The table object in which to uèdate the object
* @param object $object The object to update
* @param string $key The name of the primary key of the table
* @param boolean $updatenulls If the null properties should be updated (default: true)
*
* @return boolean If the operation was successful
*
* @throws RuntimeException
*
* @since 1.0.0
*/
public function updateObject($table, $object, $key, $updatenulls = true)
{
// update object
return $this->_database->updateObject($table, $object, $key, $updatenulls);
}