当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPWS_DB类代码示例

本文整理汇总了PHP中PHPWS_DB的典型用法代码示例。如果您正苦于以下问题:PHP PHPWS_DB类的具体用法?PHP PHPWS_DB怎么用?PHP PHPWS_DB使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PHPWS_DB类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Util.php');
     $term = $this->term;
     $db = new PHPWS_DB('hms_checkin');
     // Join hall structure
     $db->addJoin('', 'hms_checkin', 'hms_hall_structure', 'bed_id', 'bedid');
     $db->addColumn('hms_checkin.banner_id');
     $db->addColumn('hms_checkin.checkin_date');
     $db->addColumn('hms_hall_structure.hall_name');
     $db->addColumn('hms_hall_structure.room_number');
     $db->addWhere('hms_checkin.term', $term);
     $db->addWhere('hms_checkin.checkout_date', null, 'IS NULL');
     // Sort by hall, then room number
     $db->addOrder(array('hms_hall_structure.hall_name ASC', 'hms_hall_structure.room_number ASC'));
     $results = $db->select();
     if (PHPWS_Error::isError($results)) {
         throw new DatabaseException($results->toString());
     }
     // Post-processing, cleanup, making it pretty
     foreach ($results as $row) {
         // Updates counts
         $this->total++;
         $row['checkin_date'] = HMS_Util::get_short_date_time($row['checkin_date']);
         // Copy the cleaned up row to the member var for data
         $this->data[] = $row;
     }
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:28,代码来源:CheckinList.php

示例2: phatform_uninstall

/**
 * Uninstall file for PhatForm v2
 *
 * Rewritten to work with phpwebsite 1.0
 * @version $Id$
 */
function phatform_uninstall(&$content)
{
    $db = new PHPWS_DB('mod_phatform_forms');
    $db->addColumn('id');
    $db->addColumn('archiveTableName');
    $db->addWhere('saved', 1);
    $result = $db->select();
    if (!empty($result)) {
        foreach ($result as $form) {
            if (empty($form['archiveTableName'])) {
                $table = 'mod_phatform_form_' . $form['id'];
                if (PHPWS_DB::isTable($table)) {
                    PHPWS_DB::dropTable($table);
                }
            } else {
                $table = $form['archiveTableName'];
                PHPWS_DB::dropTable($table);
            }
        }
        $content[] = dgettext('phatform', 'Removed all dynamic Form Generator tables.');
    }
    PHPWS_DB::dropTable('mod_phatform_forms');
    PHPWS_DB::dropTable('mod_phatform_options');
    PHPWS_DB::dropTable('mod_phatform_textfield');
    PHPWS_DB::dropTable('mod_phatform_textarea');
    PHPWS_DB::dropTable('mod_phatform_dropbox');
    PHPWS_DB::dropTable('mod_phatform_multiselect');
    PHPWS_DB::dropTable('mod_phatform_radiobutton');
    PHPWS_DB::dropTable('mod_phatform_checkbox');
    $content[] = dgettext('phatform', 'All Form Generator static tables removed.');
    return TRUE;
}
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:38,代码来源:uninstall.php

示例3: hms_install

function hms_install(&$content)
{
    PHPWS_Core::initModClass('users', 'Users.php');
    $DB = new PHPWS_DB('users');
    $DB->addWhere('username', 'hms_admin');
    $result = $DB->select('one');
    if ($result == null) {
        $user = new PHPWS_User();
        $user->setUsername('hms_admin');
        $user->setPassword('in the white room, with black curtains');
        $user->save();
    }
    $DB = new PHPWS_DB('users');
    $DB->addWhere('username', 'hms_student');
    $result = $DB->select('one');
    if ($result == null) {
        $user = new PHPWS_User();
        $user->setUsername('hms_student');
        $user->setPassword('shes my everything, shes my pride and joy');
        $user->save();
    }
    $directory = PHPWS_HOME_DIR . 'files/hms_reports/';
    if (!is_dir($directory)) {
        mkdir($directory);
    }
    return true;
}
开发者ID:jlbooker,项目名称:homestead,代码行数:27,代码来源:install.php

示例4: showFP

function showFP()
{
    $db = new PHPWS_DB('ps_page');
    $db->addWhere('front_page', 1);
    if ($db->isTableColumn('deleted')) {
        $db->addWhere('deleted', 0);
    }
    Key::restrictView($db, 'pagesmith');
    $db->loadClass('pagesmith', 'PS_Page.php');
    $result = $db->getObjects('PS_Page');
    if (!PHPWS_Error::logIfError($result) && !empty($result)) {
        PHPWS_Core::initModClass('pagesmith', 'PageSmith.php');
        foreach ($result as $page) {
            $content = $page->view();
            if ($content && !PHPWS_Error::logIfError($content)) {
                if (Current_User::allow('pagesmith', 'edit_page', $page->id)) {
                    $content .= sprintf('<p class="pagesmith-edit">%s</p>', $page->editLink());
                }
                Layout::add($content, 'pagesmith', 'view_' . $page->id, TRUE);
            }
        }
    } else {
        return null;
    }
}
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:25,代码来源:runtime.php

示例5: menu_unregister_key

/**
 * unregisters deleted keys from menu
 *
 * @author Matthew McNaney <mcnaney at gmail dot com>
 * @version $Id$
 */
function menu_unregister_key(Key $key)
{
    PHPWS_Core::initModClass('menu', 'Menu_Link.php');
    if (empty($key) || empty($key->id)) {
        return FALSE;
    }
    $db = new PHPWS_DB('menu_links');
    $db->addWhere('key_id', $key->id);
    $result = $db->delete();
    if (PHPWS_Error::isError($result)) {
        PHPWS_Error::log($result);
    }
    $db2 = new PHPWS_DB('menu_assoc');
    $db2->addWhere('key_id', $key->id);
    $result = $db2->delete();
    if (PHPWS_Error::isError($result)) {
        PHPWS_Error::log($result);
    }
    $db3 = new PHPWS_DB('menus');
    $db3->addWhere('assoc_key', $key->id);
    $db3->addValue('assoc_key', 0);
    $db3->addValue('assoc_url', null);
    $db3->update();
    return true;
}
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:31,代码来源:key.php

示例6: execute

 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'edit_role_members')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to edit role members.');
     }
     $username = $context->get('username');
     $rolename = $context->get('role');
     $class = $context->get('className');
     $instance = $context->get('instance');
     if (is_null($username) || is_null($rolename)) {
         echo json_encode(false);
         exit;
     }
     $db = new PHPWS_DB('hms_role');
     $db->addWhere('name', $rolename);
     $result = $db->select('row');
     if (PHPWS_Error::logIfError($result) || is_null($result['id'])) {
         echo json_encode(false);
         exit;
     }
     $role_id = $result['id'];
     $role = new HMS_Role();
     $role->id = $role_id;
     if ($role->load()) {
         echo json_encode($role->removeUser($username, $class, $instance));
         exit;
     }
     echo json_encode(false);
     exit;
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:31,代码来源:RoleRemoveUserCommand.php

示例7: execute

 public function execute()
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     if (!isset($this->term) || is_null($this->term)) {
         throw new InvalidArgumentException('Missing term.');
     }
     $db = new PHPWS_DB('hms_new_application');
     $db->addColumn('banner_id');
     $db->addColumn('username');
     $db->addWhere('term', $this->term);
     $results = $db->select();
     if (empty($results)) {
         return;
     } elseif (PEAR::isError($results)) {
         throw new DatabaseException($results->toString());
     }
     $twentyFiveYearsAgo = strtotime("-25 years");
     foreach ($results as $student) {
         try {
             $sf = StudentFactory::getStudentByBannerId($student['banner_id'], $this->term);
             $dob = $sf->getDOB();
             if (strtotime($dob) > $twentyFiveYearsAgo) {
                 continue;
             }
             $student['dob'] = $dob;
             $student['full_name'] = $sf->getFullName();
             $this->all_rows[] = $student;
         } catch (Exception $e) {
             $student['dob'] = $student['full_name'] = null;
             $this->problems[] = $student['banner_id'];
         }
     }
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:33,代码来源:TwentyFive.php

示例8: execute

 public function execute(CommandContext $context)
 {
     $term = Term::getSelectedTerm();
     $messageAll = Current_User::allow('hms', 'email_all');
     $db = new PHPWS_DB('hms_residence_hall');
     $db->addWhere('term', $term);
     $results = $db->getObjects('HMS_Residence_Hall');
     if (PHPWS_Error::logIfError($results) || is_null($results)) {
         $errorMsg = array();
         if (is_null($results)) {
             $errorMsg['error'] = 'You do not have permission to message any halls, sorry.';
         } else {
             $errorMsg['error'] = 'There was a problem reading the database, please try reloading the page.  If the problem persists contact ESS.';
         }
         echo json_encode($errorMsg);
         exit;
     }
     $permission = new HMS_Permission();
     $data = array();
     foreach ($results as $hall) {
         $somethingEnabled = false;
         $floors = $hall->get_floors();
         unset($obj);
         $obj = new stdClass();
         $obj->name = $hall->getHallName();
         $obj->id = $hall->getId();
         $obj->floors = array();
         //$blah = 'Verify: ' . ($permission->verify(UserStatus::getUsername(), $hall, 'email') ? 'true' : 'false');
         if ($permission->verify(UserStatus::getUsername(), $hall, 'email') || $messageAll) {
             $obj->enabled = true;
             $somethingEnabled = true;
             foreach ($floors as $floor) {
                 unset($floor_obj);
                 $floor_obj = new stdClass();
                 $floor_obj->name = "Floor: " . $floor->getFloorNumber();
                 $floor_obj->id = $floor->getId();
                 $floor_obj->enabled = true;
                 $obj->floors[] = $floor_obj;
             }
         } else {
             $obj->enabled = false;
             foreach ($floors as $floor) {
                 unset($floor_obj);
                 $floor_obj = new stdClass();
                 $floor_obj->name = "Floor: " . $floor->getFloorNumber();
                 $floor_obj->id = $floor->getId();
                 $floor_obj->enabled = $permission->verify(Current_User::getUsername(), $floor, 'email');
                 $obj->floors[] = $floor_obj;
                 if ($floor_obj->enabled) {
                     $somethingEnabled = true;
                 }
             }
         }
         if ($somethingEnabled) {
             $data[] = $obj;
         }
     }
     echo json_encode($data);
     exit;
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:60,代码来源:ListAllowedHallsCommand.php

示例9: processAll

 public static function processAll($term)
 {
     $db = new PHPWS_DB('hms_banner_queue');
     $db->addWhere('term', $term);
     $db->addOrder('id');
     $items = $db->getObjects('BannerQueueItem');
     $errors = array();
     foreach ($items as $item) {
         $result = null;
         try {
             $result = $item->process();
         } catch (Exception $e) {
             $error = array();
             $error['username'] = $item->asu_username;
             $error['code'] = $e->getCode();
             $error['message'] = $e->getMessage();
             $errors[] = $error;
             continue;
         }
         if ($result === TRUE) {
             $item->delete();
         }
     }
     if (empty($errors)) {
         return TRUE;
     }
     return $errors;
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:28,代码来源:BannerQueue.php

示例10: saveObject

 public static function saveObject(DbStorable $o)
 {
     $vars = $o->extractVars();
     $tableName = $o::getTableName();
     // Check if the key already exists
     $query = "SELECT * FROM {$tableName} WHERE id = {$vars['id']}";
     $result = \PHPWS_DB::getAll($query);
     if (count($result) > 0) {
         $exists = true;
     } else {
         $exists = false;
     }
     $db = new \PHPWS_DB($o->getTableName());
     foreach ($vars as $key => $value) {
         $db->addValue($key, $value);
     }
     if ($exists) {
         $db->addWhere('id', $vars['id']);
         $result = $db->update();
     } else {
         $result = $db->insert(false);
     }
     if (\PHPWS_Error::logIfError($result)) {
         throw new \Exception($result->toString());
     }
 }
开发者ID:jlbooker,项目名称:InternshipInventory,代码行数:26,代码来源:DatabaseStorage.php

示例11: execute

 public function execute(CommandContext $context)
 {
     // Check for report ID
     $reportId = $context->get('reportId');
     if (!isset($reportId) || is_null($reportId)) {
         throw new InvalidArgumentException('Missing report id.');
     }
     PHPWS_Core::initModClass('hms', 'ReportFactory.php');
     // Load the report to get its class
     try {
         $report = ReportFactory::getReportById($reportId);
     } catch (InvalidArgumentException $e) {
         NQ::simple('hms', hms\NotificationView::SUCCESS, 'Report canceled.');
         $context->goBack();
     }
     $db = new PHPWS_DB('hms_report');
     $db->addWhere('id', $reportId);
     $result = $db->delete();
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     }
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'Report canceled.');
     $cmd = CommandFactory::getCommand('ShowReportDetail');
     $cmd->setReportClass($report->getClass());
     $cmd->redirect();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:26,代码来源:CancelReportCommand.php

示例12: execute

 public function execute()
 {
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'HMS_Util.php');
     // Select all cancelled apps for the given term
     $db = new PHPWS_DB('hms_new_application');
     $db->addWhere('cancelled', 1);
     $db->addWhere('term', $this->term);
     $results = $db->select();
     // Initialize storage for processed rows
     $this->rows = array();
     // Get friendly cancellation reasons from HousingApplication
     $reasons = HousingApplication::getCancellationReasons();
     // Process and store each result
     foreach ($results as $app) {
         $row = array();
         $row['bannerId'] = $app['banner_id'];
         $row['username'] = $app['username'];
         $row['gender'] = HMS_Util::formatGender($app['gender']);
         $row['application_term'] = $app['application_term'];
         $row['student_type'] = $app['student_type'];
         $row['cancelled_reason'] = $reasons[$app['cancelled_reason']];
         $row['cancelled_on'] = HMS_Util::get_long_date($app['cancelled_on']);
         $row['cancelled_by'] = $app['cancelled_by'];
         $this->rows[] = $row;
     }
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:27,代码来源:CancelledAppsList.php

示例13: save

 public function save()
 {
     $db = new PHPWS_DB('analytics_tracker');
     $result = $db->saveObject($this);
     if (PHPWS_Error::logIfError($result)) {
         return $result;
     }
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:8,代码来源:Tracker.php

示例14: runDbMigration

function runDbMigration($fileName)
{
    $db = new PHPWS_DB();
    $result = $db->importFile(PHPWS_SOURCE_DIR . 'mod/systemsinventory/boost/updates/' . $fileName);
    if (PEAR::isError($result)) {
        throw new \Exception($result->toString());
    }
}
开发者ID:AppStateESS,项目名称:systemsinventory,代码行数:8,代码来源:update.php

示例15: filecabinet_unregister

/**
 * @version $Id$
 * @author Matthew McNaney <mcnaney at gmail dot com>
 */
function filecabinet_unregister($module, &$content)
{
    $db = new PHPWS_DB('folders');
    $db->addValue('module_created', null);
    $db->addWhere('module_created', $module);
    PHPWS_Error::logIfError($db->update());
    $content[] = dgettext('filecabinet', 'Unregistered from File Cabinet.');
    return true;
}
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:13,代码来源:unregister.php


注:本文中的PHPWS_DB类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。