本文整理汇总了PHP中JTable::generateAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP JTable::generateAlias方法的具体用法?PHP JTable::generateAlias怎么用?PHP JTable::generateAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JTable
的用法示例。
在下文中一共展示了JTable::generateAlias方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareTable
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if (isset($table->name)) {
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
}
if (isset($table->alias) && empty($table->alias)) {
$table->generateAlias();
}
if (empty($table->id)) {
$table->created = $date->toSql();
// set the user
if ($table->created_by == 0 || empty($table->created_by)) {
$table->created_by = $user->id;
}
// Set ordering to the last item if not set
if (empty($table->ordering)) {
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select('MAX(ordering)')->from($db->quoteName('#__demo_look'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
} else {
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
if (!empty($table->id)) {
// Increment the items version number.
$table->version++;
}
}
示例2: prepareTable
/**
* Prepare and sanitise the table prior to saving.
*
* @param JTable $table The JTable object
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate()->toSql();
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
$table->generateAlias();
if (empty($table->id)) {
// Set the values
$table->created = $date;
// Set ordering to the last item if not set
if (empty($table->ordering)) {
$db = $this->getDbo();
$query = $db->getQuery(true)->select('MAX(ordering)')->from($db->quoteName('#__contact_details'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
} else {
// Set the values
$table->modified = $date;
$table->modified_by = JFactory::getUser()->id;
}
// Increment the content version number.
$table->version++;
}