本文整理汇总了PHP中JTable::getKeyName方法的典型用法代码示例。如果您正苦于以下问题:PHP JTable::getKeyName方法的具体用法?PHP JTable::getKeyName怎么用?PHP JTable::getKeyName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JTable
的用法示例。
在下文中一共展示了JTable::getKeyName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetKeyNameComposite
/**
* Test for getKeyName returning an array
*
* @covers JTable::getKeyName
*
* @return void
*
* @since 12.3
*/
public function testGetKeyNameComposite()
{
$this->assertEquals(
array('id1', 'id2'),
$this->object->getKeyName(true)
);
}
示例2: deleteHistory
/**
* Method to delete the history for an item.
*
* @param JTable $table JTable object being versioned
*
* @return boolean true on success, otherwise false.
*
* @since 3.2
*/
public function deleteHistory($table)
{
$key = $table->getKeyName();
$id = $table->{$key};
$typeTable = JTable::getInstance('Contenttype', 'JTable');
$typeId = $typeTable->getTypeId($this->typeAlias);
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'))->where($db->quoteName('ucm_item_id') . ' = ' . (int) $id)->where($db->quoteName('ucm_type_id') . ' = ' . (int) $typeId);
$db->setQuery($query);
return $db->execute();
}
示例3: clearPrimaryKeys
/**
* clearPrimaryKeys
*
* @param \JTable $itemTable
*
* @return \JTable
*/
public function clearPrimaryKeys(\JTable $itemTable)
{
foreach ($itemTable->getKeyName(true) as $key) {
$itemTable->{$key} = null;
}
return $itemTable;
}
示例4: unTagItem
/**
* Method to untag an item
*
* @param integer $contentId ID of the content item being untagged
* @param JTable $table JTable object being untagged
* @param array $tags Array of tags to be untagged. Use an empty array to untag all existing tags.
*
* @return boolean true on success, otherwise false.
*
* @since 3.1
*/
public function unTagItem($contentId, $table, $tags = array())
{
$key = $table->getKeyName();
$id = $table->{$key};
$db = JFactory::getDbo();
$query = $db->getQuery(true)->delete('#__contentitem_tag_map')->where($db->quoteName('type_alias') . ' = ' . $db->quote($this->typeAlias))->where($db->quoteName('content_item_id') . ' = ' . (int) $id);
if (is_array($tags) && count($tags) > 0) {
$query->where($db->quoteName('tag_id') . ' IN ' . implode(',', $tags));
}
$db->setQuery($query);
return (bool) $db->execute();
}
示例5: loadHistory
/**
* Method to load a row for editing from the version history table.
*
* @param integer $version_id Key to the version history table.
* @param JTable &$table Content table object being loaded.
*
* @return boolean False on failure or error, true otherwise.
*
* @since 12.2
*/
public function loadHistory($version_id, JTable &$table)
{
// Only attempt to check the row in if it exists.
if ($version_id) {
$user = JFactory::getUser();
// Get an instance of the row to checkout.
$historyTable = JTable::getInstance('History', 'ContenthistoryTable');
if (!$historyTable->load($version_id)) {
$this->setError($historyTable->getError());
return false;
}
$rowArray = JArrayHelper::fromObject(json_decode($historyTable->version_data));
$typeId = JTable::getInstance('Types', 'ContentTable')->getTypeId($this->typeAlias);
if ($historyTable->ucm_type_id != $typeId) {
$this->setError(JText::_('JLIB_APPLICATION_ERROR_HISTORY_ID_MISMATCH'));
$key = $table->getKeyName();
if (isset($rowArray[$key])) {
$table->checkIn($rowArray[$key]);
}
return false;
}
}
$this->setState('save_date', $historyTable->save_date);
$this->setState('version_note', $historyTable->version_note);
return $table->bind($rowArray);
}
示例6: prepareTable
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A reference to a JTable object.
*
* @return void
*/
protected function prepareTable(\JTable $table)
{
$date = DateHelper::getDate('now');
$user = $this->container->get('user');
$key = $table->getKeyName();
// Alias
if (property_exists($table, 'alias')) {
if (!$table->alias) {
$table->alias = JFilterOutput::stringURLSafe(trim($table->title));
} else {
$table->alias = JFilterOutput::stringURLSafe(trim($table->alias));
}
if (!$table->alias) {
$table->alias = JFilterOutput::stringURLSafe($date->toSql(true));
}
}
// Created date
if (property_exists($table, 'created')) {
if ($table->created) {
$table->created = DateHelper::toServerTime($table->created);
} else {
$table->created = $date->toSql();
}
}
// Publish_up date
if (property_exists($table, 'publish_up')) {
if ($table->publish_up) {
$table->publish_up = DateHelper::toServerTime($table->publish_up);
} else {
$table->publish_up = $this->db->getNullDate();
}
}
// Publish_down date
if (property_exists($table, 'publish_down')) {
if ($table->publish_down) {
$table->publish_down = DateHelper::toServerTime($table->publish_down);
} else {
$table->publish_down = $this->db->getNullDate();
}
}
// Modified date
if (property_exists($table, 'modified') && $table->{$key}) {
$table->modified = $date->toSql();
}
// Created user
if (property_exists($table, 'created_by') && !$table->created_by) {
$table->created_by = $user->get('id');
}
// Modified user
if (property_exists($table, 'modified_by') && $table->{$key}) {
$table->modified_by = $user->get('id');
}
// Set Ordering or Nested ordering
if (property_exists($table, 'ordering')) {
if (empty($table->id)) {
$this->setOrderPosition($table);
}
}
}