本文整理汇总了PHP中Engine_Db_Table::getDefaultAdapter方法的典型用法代码示例。如果您正苦于以下问题:PHP Engine_Db_Table::getDefaultAdapter方法的具体用法?PHP Engine_Db_Table::getDefaultAdapter怎么用?PHP Engine_Db_Table::getDefaultAdapter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Engine_Db_Table
的用法示例。
在下文中一共展示了Engine_Db_Table::getDefaultAdapter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteAction
public function deleteAction()
{
if (!$this->_helper->requireAuth()->setAuthParams('ynsocialads_campaign', null, 'delete')->isValid()) {
return;
}
// In smoothbox
$this->_helper->layout->setLayout('admin-simple');
$id = $this->_getParam('id');
$campaign = Engine_Api::_()->getItem('ynsocialads_campaign', $id);
if (!$campaign->isDeletable()) {
return;
}
$this->view->campaign_id = $id;
// Check post
if ($this->getRequest()->isPost()) {
$db = Engine_Db_Table::getDefaultAdapter();
$db->beginTransaction();
try {
$campaign->deleteAllAds();
$campaign->status = "deleted";
$campaign->save();
$db->commit();
} catch (Exception $e) {
$db->rollBack();
throw $e;
}
$this->_forward('success', 'utility', 'core', array('smoothboxClose' => 10, 'parentRefresh' => 10, 'messages' => array('')));
}
}
示例2: editAction
public function editAction()
{
// In smoothbox
$this->_helper->layout->setLayout('admin-simple');
$id = $this->_getParam('id', 0);
$location = Engine_Api::_()->getItem('user_location', $id);
if (!$id || !$location) {
return $this->_helper->requireSubject()->forward();
}
$form = $this->view->form = new User_Form_Admin_Location_Add();
$form->setAction($this->getFrontController()->getRouter()->assemble(array()));
$form->setField($location);
if ($location->level) {
$form->removeElement('continent');
}
// Check post
if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
// Ok, we're good to add field
$values = $form->getValues();
$db = Engine_Db_Table::getDefaultAdapter();
$db->beginTransaction();
try {
$location->title = $values["title"];
if ($location->level == 0) {
$location->continent = $values['continent'];
}
$location->save();
$db->commit();
} catch (Exception $e) {
$db->rollBack();
throw $e;
}
return $this->_forward('success', 'utility', 'core', array('smoothboxClose' => true, 'parentRefresh' => true, 'messages' => array('Edit successfully!')));
}
}
示例3: denyAction
public function denyAction()
{
// In smoothbox
$this->_helper->layout->setLayout('admin-simple');
$request = Engine_Api::_()->getItem('advgroup_request', $this->_getParam('req_id'));
$id = $this->_getParam('id');
$this->view->group_id = $id;
// Check post
if ($this->getRequest()->isPost()) {
$db = Engine_Db_Table::getDefaultAdapter();
$db->beginTransaction();
try {
$group = Engine_Api::_()->getItem('group', $id);
if ($group) {
$group->requested = false;
$group->save();
}
if ($request) {
$request->status = 2;
$request->save();
}
$db->commit();
} catch (Exception $e) {
$db->rollBack();
throw $e;
}
$notifyApi = Engine_Api::_()->getDbtable('notifications', 'activity');
$notifyApi->addNotification($group->getOwner(), $group, $group, 'advgroup_request_denied');
$this->_forward('success', 'utility', 'core', array('smoothboxClose' => 10, 'parentRefresh' => 10, 'messages' => array('')));
}
// Output
$this->renderScript('admin-request/deny.tpl');
}
示例4: editAction
public function editAction()
{
// In smoothbox
$this->_helper->layout->setLayout('admin-simple');
// Must have an id
if (!($id = $this->_getParam('id'))) {
die('No identifier specified');
}
$typeTable = Engine_Api::_()->getDbtable('languages', 'user');
$type = $typeTable->find($id)->current();
$form = $this->view->form = new User_Form_Admin_Language_Add();
$form->setAction($this->getFrontController()->getRouter()->assemble(array()));
$form->setField($type);
// Check post
if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
// Ok, we're good to add field
$values = $form->getValues();
$db = Engine_Db_Table::getDefaultAdapter();
$db->beginTransaction();
try {
$type->title = $values["label"];
$type->save();
$db->commit();
} catch (Exception $e) {
$db->rollBack();
throw $e;
}
return $this->_forward('success', 'utility', 'core', array('smoothboxClose' => 10, 'parentRefresh' => 10, 'messages' => array('')));
}
// Output
$this->renderScript('admin-languages/form.tpl');
}
示例5: deleteContentAction
public function deleteContentAction()
{
// In smoothbox
$this->_helper->layout->setLayout('admin-simple');
$content_id = $this->_getParam('content_id');
$this->view->content_id = $content_id;
// Check post
if ($this->getRequest()->isPost()) {
$db = Engine_Db_Table::getDefaultAdapter();
$db->beginTransaction();
try {
$content = Engine_Api::_()->getItem('ynfeed_welcome', $content_id);
if ($content) {
$content->delete();
}
$db->commit();
} catch (Exception $e) {
$db->rollBack();
throw $e;
}
$this->_forward('success', 'utility', 'core', array('smoothboxClose' => 10, 'parentRefresh' => 10, 'messages' => array('')));
}
// Output
$this->renderScript('admin-welcome/delete.tpl');
}
示例6: indexAction
public function indexAction()
{
if (!Engine_Api::_()->core()->hasSubject()) {
return $this->setNoRender();
}
if (!($group = Engine_Api::_()->core()->getSubject('group'))) {
return $this->setNoRender();
}
$viewer = Engine_Api::_()->user()->getViewer();
if (!$group->authorization()->isAllowed($viewer, "view")) {
return $this->setNoRender();
}
if ($this->_getParam('number') != '' && $this->_getParam('number') >= 0) {
$limit = $this->_getParam('number');
} else {
$limit = 5;
}
$db = Engine_Db_Table::getDefaultAdapter();
$db->beginTransaction();
$select = "SELECT count(*) as post_count, `result`.subject_id FROM ((SELECT type1.`action_id` , type1.`subject_id` , 'action' as 'type'\n FROM engine4_activity_actions type1\n WHERE object_type = 'group' and object_id = {$group->getIdentity()})\n UNION (\n SELECT like1.`action_id` , like2.`poster_id` as 'subject_id' , 'like' as 'type'\n FROM engine4_activity_likes like2\n JOIN engine4_activity_actions like1 ON like2.resource_id = like1.action_id\n WHERE like1.object_type = 'group'\n AND like1.object_id = {$group->getIdentity()})\n UNION (\n SELECT com1.`action_id`, com2.`poster_id` as 'subject_id' , 'comment' as 'type'\n FROM engine4_activity_comments com2\n JOIN engine4_activity_actions com1 ON com2.resource_id = com1.action_id\n WHERE com1.object_type = 'group'\n AND com1.object_id = {$group->getIdentity()}\n )\n ) as `result`\n GROUP BY `result`.subject_id\n ORDER BY post_count DESC";
$results = $db->fetchAll($select);
$this->view->limit = $limit;
$this->view->group = $group;
$this->view->results = $results;
// Do not render if nothing to show
if (count($results) <= 0) {
return $this->setNoRender();
}
}
示例7: getDb
public function getDb()
{
if ($this->_db == null) {
$this->_db = Engine_Db_Table::getDefaultAdapter();
}
return $this->_db;
}
示例8: editAction
public function editAction()
{
// In smoothbox
$this->_helper->layout->setLayout('admin-simple');
$id = $this->_getParam('id');
$this->view->campaign_id = $id;
// Check post
if ($this->getRequest()->isPost()) {
$newTitle = strip_tags($this->getRequest()->getPost('newTitle'));
$db = Engine_Db_Table::getDefaultAdapter();
$db->beginTransaction();
try {
$campaign = Engine_Api::_()->getItem('ynsocialads_campaign', $id);
$campaign->title = $newTitle;
$campaign->save();
$db->commit();
} catch (Exception $e) {
$db->rollBack();
throw $e;
}
$this->_forward('success', 'utility', 'core', array('smoothboxClose' => 10, 'parentRefresh' => 10, 'messages' => array('')));
}
// Output
$this->renderScript('admin-campaigns/edit.tpl');
}
示例9: emailAction
public function emailAction()
{
// In smoothbox
$this->_helper->layout->setLayout('admin-simple');
$id = $this->_getParam('id');
$this->view->request_id = $id;
// Check post
if ($this->getRequest()->isPost()) {
$table = Engine_Api::_()->getDbTable('inviterequests', 'user');
$db = Engine_Db_Table::getDefaultAdapter();
$db->beginTransaction();
$post = $this->getRequest()->getPost();
try {
$viewer = Engine_Api::_()->user()->getViewer();
$request = Engine_Api::_()->getItem('user_inviterequest', $id);
$message = trim($post['message']);
$mailType = 'user_email_request';
$mailParams = array('host' => $_SERVER['HTTP_HOST'], 'email' => $email, 'date' => time(), 'sender_email' => $request->email, 'sender_title' => $viewer->getTitle(), 'sender_link' => $viewer->getHref(), 'message' => $message);
Engine_Api::_()->getApi('mail', 'core')->sendSystem($request->email, $mailType, $mailParams);
$db->commit();
} catch (Exception $e) {
$db->rollBack();
throw $e;
}
$this->_forward('success', 'utility', 'core', array('smoothboxClose' => true, 'parentRefresh' => true, 'messages' => array('Email has been sent to requester.')));
}
}
示例10: deleteNode
public function deleteNode($node, $moveToId = 0)
{
$moveToId = (int) $moveToId;
$db = Engine_Db_Table::getDefaultAdapter();
$ids = $node->getAllChildrenIds();
$db->update('engine4_event_events', array('category_id' => $moveToId), 'category_id IN(' . implode(',', $ids) . ')');
$db->delete('engine4_event_categories', 'category_id IN(' . implode(',', $ids) . ')');
}
示例11: onItemDeleteBefore
public function onItemDeleteBefore($event)
{
$item = $event->getPayload();
if ($item instanceof Core_Model_Item_Abstract) {
$db = Engine_Db_Table::getDefaultAdapter();
$db->delete('engine4_seo_pages', array('page_id = ?' => $item->getGuid()));
}
}
示例12: denyAction
public function denyAction()
{
$id = $this->_getParam('id');
$array_id = $this->_getParam('array_id');
$reasonTable = Engine_Api::_()->getItemTable('slprofileverify_reason');
$this->view->reasons = $reasonTable->fetchAll();
$type = $this->_getParam('type');
if ($type != "unverifying") {
$type = "denied";
}
$this->view->type = $type;
if ($this->getRequest()->isPost()) {
$values = $this->getRequest()->getPost();
if (!isset($values['reason']) && !isset($values['other'])) {
$this->view->error_reason = 1;
return;
}
if (empty($values['content']) && isset($values['other'])) {
$this->view->error_reason = 2;
return;
}
$messages = "<ul style='list-style: square inside none;'>";
if (isset($values['reason'])) {
foreach ($values['reason'] as $reason_id) {
$reason = Engine_Api::_()->getItem('slprofileverify_reason', $reason_id);
$messages .= "<li>" . $reason->description . '</li>';
}
}
if (!empty($values['content'])) {
$messages .= "<li>" . $values['content'] . '</li>';
}
$messages .= "</ul>";
$db = Engine_Db_Table::getDefaultAdapter();
$db->beginTransaction();
try {
$settingApi = Engine_Api::_()->getApi('core', 'slprofileverify');
if (!empty($array_id)) {
$array_ids = split(",", $array_id);
foreach ($array_ids as $id) {
if ($id) {
$settingApi->verifyUser($id, 'unverified');
$settingApi->sendMailVerify($id, $messages, $type);
}
}
} else {
if ($id) {
$settingApi->verifyUser($id, 'unverified');
$settingApi->sendMailVerify($id, $messages, $type);
}
}
$db->commit();
} catch (Exception $e) {
$db->rollBack();
throw $e;
}
$this->_forward('success', 'utility', 'core', array('smoothboxClose' => 10, 'parentRefresh' => 10, 'messages' => array('successfully')));
}
}
示例13: contactAction
public function contactAction()
{
$translate = Zend_Registry::get('Zend_Translate');
$this->view->form = $form = new Core_Form_Contact();
if (!$this->getRequest()->isPost()) {
return;
}
if (!$form->isValid($this->getRequest()->getPost())) {
return;
}
// Success! Process
// Mail gets logged into database, so perform try/catch in this Controller
$db = Engine_Db_Table::getDefaultAdapter();
$db->beginTransaction();
try {
// the contact form is emailed to the first SuperAdmin by default
$users_table = Engine_Api::_()->getDbtable('users', 'user');
$users_select = $users_table->select()->where('level_id = ?', 1)->where('enabled >= ?', 1);
$super_admin = $users_table->fetchRow($users_select);
$viewer = Engine_Api::_()->user()->getViewer();
$values = $form->getValues();
// Check for error report
$error_report = '';
$name = $this->_getParam('name');
$loc = $this->_getParam('loc');
$time = $this->_getParam('time');
if ($name && $loc && $time) {
$error_report .= "\r\n";
$error_report .= "\r\n";
$error_report .= "-------------------------------------";
$error_report .= "\r\n";
$error_report .= $this->view->translate('The following information about an error was included with this message:');
$error_report .= "\r\n";
$error_report .= $this->view->translate('Exception: ') . base64_decode(urldecode($name));
$error_report .= "\r\n";
$error_report .= $this->view->translate('Location: ') . base64_decode(urldecode($loc));
$error_report .= "\r\n";
$error_report .= $this->view->translate('Time: ') . date('c', base64_decode(urldecode($time)));
$error_report .= "\r\n";
}
// Make params
$mail_settings = array('host' => $_SERVER['HTTP_HOST'], 'email' => $super_admin->email, 'date' => time(), 'recipient_title' => $super_admin->getTitle(), 'recipient_link' => $super_admin->getHref(), 'recipient_photo' => $super_admin->getPhotoUrl('thumb.icon'), 'sender_title' => $values['name'], 'sender_email' => $values['email'], 'message' => $values['body'], 'error_report' => $error_report);
if ($viewer && $viewer->getIdentity()) {
$mail_settings['sender_title'] .= ' (' . $viewer->getTitle() . ')';
$mail_settings['sender_email'] .= ' (' . $viewer->email . ')';
$mail_settings['sender_link'] = $viewer->getHref();
}
// send email
Engine_Api::_()->getApi('mail', 'core')->sendSystem($super_admin->email, 'core_contact', $mail_settings);
// if the above did not throw an exception, it succeeded
$db->commit();
$this->view->status = true;
$this->view->message = $translate->_('Thank you for contacting us!');
} catch (Zend_Mail_Transport_Exception $e) {
$db->rollBack();
throw $e;
}
}
示例14: getAllOutboxSelect
public function getAllOutboxSelect($users)
{
$rName = Engine_Api::_()->getDbtable('recipients', 'messages')->info('name');
$cName = $this->info('name');
$str = implode(",", array_map(array($this, "getFirst"), $users));
$select = "\n SELECT `engine4_messages_conversations`.* FROM `engine4_messages_conversations` \n\t\tRIGHT JOIN (`engine4_messages_recipients` INNER JOIN `engine4_ynbanmem_extramessage` ON `engine4_messages_recipients`.outbox_message_id = `engine4_ynbanmem_extramessage`.message_id) \n\t\tON `engine4_messages_recipients`.`conversation_id` = `engine4_messages_conversations`.`conversation_id` WHERE (`engine4_messages_recipients`.`user_id` IN (" . $str . ")) AND (`engine4_messages_recipients`.`outbox_deleted` = 0) ORDER BY outbox_updated DESC;\n \n ";
$db = Engine_Db_Table::getDefaultAdapter();
return $db->fetchAll($select);
}
示例15: altUrl
public function altUrl(Core_Model_Item_Abstract $item)
{
$db = Engine_Db_Table::getDefaultAdapter();
if (isset($this->_memo[$item->getGuid()])) {
return $this->_memo[$item->getGuid()];
}
$url = $db->select()->from('engine4_seo_pages', 'url')->where('page_id = ?', $item->getGuid())->query()->fetchColumn();
$this->_memo[$item->getGuid()] = $url;
return $url;
}