本文整理汇总了PHP中JModelLegacy::getDbo方法的典型用法代码示例。如果您正苦于以下问题:PHP JModelLegacy::getDbo方法的具体用法?PHP JModelLegacy::getDbo怎么用?PHP JModelLegacy::getDbo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JModelLegacy
的用法示例。
在下文中一共展示了JModelLegacy::getDbo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetDbo
/**
* Tests the setDbo method.
*
* @since 12.3
*
* @return void
*/
public function testSetDbo()
{
$this->fixture->setDbo(new stdClass());
$this->assertTrue($this->fixture->getDbo() instanceof stdClass);
}
示例2: postSaveHook
/**
* Function that allows child controller access to model data after the data has been saved.
*
* @param JModelLegacy $model The data model object.
* @param array $validData The validated data.
*
* @return void
*
* @since 3.1
*/
protected function postSaveHook(JModelLegacy $model, $validData = array())
{
require_once JPATH_COMPONENT . '/helpers/sibdiet.php';
$db = $model->getDbo();
// Construct the query
$query = $db->getQuery(true)->select('s.room1, s.room2, s.room3, s.room4, s.room5, p.id, p.fname, p.lname, p.mobile, u.email, u.username')->from('#__sibdiet_setdiets s')->join('INNER', '#__sibdiet_profiles p ON (s.profiles_id = p.id)')->join('INNER', '#__users u ON (p.users_id = u.id)')->where('s.id = ' . $validData['id']);
// Setup the query
$db->setQuery($query);
// Return the result
$result = $db->loadObject();
if ($result->email && !strpos($result->email, 'sibdiet') && $result->room1 && $result->room2 && $result->room3 && $result->room4 && $result->room5) {
$siteLink = JUri::root();
$subject = JText::_('COM_SIBDIET_DIET_READY_EMAIL_SUBJECT');
$password = $result->username == $result->id + 200000 ? $result->mobile : JText::_('COM_SIBDIET_YOU_SET_PASSWORD');
// Prepare email body
$body = JText::sprintf('COM_SIBDIET_DIET_READY_EMAIL_BODY', $result->fname . ' ' . $result->lname, $siteLink, $result->username, $password);
if (SibdietHelper::sendEmail($result->email, $subject, $body)) {
// Create an object for the record we are going to update.
$object = new stdClass();
// Must be a valid primary key value.
$object->id = $validData['id'];
$object->room6 = JFactory::getUser()->id;
// Update their details in the users table using id as the primary key.
$result = JFactory::getDbo()->updateObject('#__sibdiet_setdiets', $object, 'id');
}
}
$app = JFactory::getApplication();
$filter = $app->getUserState('com_sibdiet.setdiets.filter');
$filter->profiles_id = '';
$app->setUserState('com_sibdiet.setdiets.filter', $filter);
}