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


PHP ServiceLocator::GetDatabase方法代码示例

本文整理汇总了PHP中ServiceLocator::GetDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP ServiceLocator::GetDatabase方法的具体用法?PHP ServiceLocator::GetDatabase怎么用?PHP ServiceLocator::GetDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ServiceLocator的用法示例。


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

示例1: GetList

 /**
  * Returns a limited query based on page number and size
  * If nulls are passed for both $pageNumber, $pageSize then all results are returned
  *
  * @param SqlCommand $command
  * @param callback $listBuilder callback to for each row of results
  * @param int|null $pageNumber
  * @param int|null $pageSize
  * @param string|null $sortField
  * @param string|null $sortDirection
  * @return PageableData
  */
 public static function GetList($command, $listBuilder, $pageNumber = null, $pageSize = null, $sortField = null, $sortDirection = null)
 {
     $total = null;
     $totalCounter = 0;
     $results = array();
     $db = ServiceLocator::GetDatabase();
     $pageNumber = intval($pageNumber);
     $pageSize = intval($pageSize);
     if (empty($pageNumber) && empty($pageSize) || $pageSize == PageInfo::All) {
         $resultReader = $db->Query($command);
     } else {
         $totalReader = $db->Query(new CountCommand($command));
         if ($row = $totalReader->GetRow()) {
             $total = $row[ColumnNames::TOTAL];
         }
         $pageNumber = empty($pageNumber) ? 1 : $pageNumber;
         $pageSize = empty($pageSize) ? 1 : $pageSize;
         $resultReader = $db->LimitQuery($command, $pageSize, ($pageNumber - 1) * $pageSize);
     }
     while ($row = $resultReader->GetRow()) {
         $results[] = call_user_func($listBuilder, $row);
         $totalCounter++;
     }
     $resultReader->Free();
     return new PageableData($results, is_null($total) ? $totalCounter : $total, $pageNumber, $pageSize);
 }
开发者ID:hugutux,项目名称:booked,代码行数:38,代码来源:PageableDataStore.php

示例2: GetGroupAdminPermissions

 private function GetGroupAdminPermissions($userId)
 {
     $userCommand = new SelectUserGroupResourceAdminPermissions($userId);
     $reader = ServiceLocator::GetDatabase()->Query($userCommand);
     $resources = array();
     while ($row = $reader->GetRow()) {
         $resources[] = new ScheduleResource($row[ColumnNames::RESOURCE_ID], $row[ColumnNames::RESOURCE_NAME]);
     }
     return $resources;
 }
开发者ID:ksdtech,项目名称:booked,代码行数:10,代码来源:ScheduleUserRepository.php

示例3: SetUserPreference

 /**
  * @param $userId int
  * @param $preferenceName string
  * @param $preferenceValue string
  * @return void
  */
 public function SetUserPreference($userId, $preferenceName, $preferenceValue)
 {
     $db = ServiceLocator::GetDatabase();
     $existingValue = self::GetUserPreference($userId, $preferenceName);
     if (is_null($existingValue)) {
         $db->ExecuteInsert(new AddUserPreferenceCommand($userId, $preferenceName, $preferenceValue));
     } else {
         if ($existingValue != $preferenceValue) {
             $db->Execute(new UpdateUserPreferenceCommand($userId, $preferenceName, $preferenceValue));
         }
     }
 }
开发者ID:Trideon,项目名称:gigolo,代码行数:18,代码来源:UserPreferenceRepository.php

示例4: GetGroupPermissions

 /**
  * @param $userId
  * @return array|ScheduleGroup[]
  */
 private function GetGroupPermissions($userId)
 {
     $groupCommand = new SelectUserGroupPermissions($userId);
     $reader = ServiceLocator::GetDatabase()->Query($groupCommand);
     $groupList = array();
     while ($row = $reader->GetRow()) {
         $group_id = $row[ColumnNames::GROUP_ID];
         $resourceId = $row[ColumnNames::RESOURCE_ID];
         $resourceName = $row[ColumnNames::RESOURCE_NAME];
         $groupList[$group_id][] = array($resourceId, $resourceName);
     }
     $groups = array();
     foreach ($groupList as $group_id => $resourceList) {
         $resources = array();
         foreach ($resourceList as $resourceItem) {
             $resources[] = new ScheduleResource($resourceItem[0], $resourceItem[1]);
         }
         $groups[] = new ScheduleGroup($group_id, $resources);
     }
     return $groups;
 }
开发者ID:Trideon,项目名称:gigolo,代码行数:25,代码来源:ScheduleUserRepository.php

示例5: Validate

 public function Validate($username, $password)
 {
     if ($this->ShowUsernamePrompt() && empty($username) || $this->ShowPasswordPrompt() && empty($password)) {
         return false;
     }
     Log::Debug('Trying to log in as: %s', $username);
     $command = new AuthorizationCommand($username);
     $reader = ServiceLocator::GetDatabase()->Query($command);
     $valid = false;
     if ($row = $reader->GetRow()) {
         Log::Debug('User was found: %s', $username);
         $migration = $this->GetMigration();
         $password = $migration->Create($password, $row[ColumnNames::OLD_PASSWORD], $row[ColumnNames::PASSWORD]);
         $salt = $row[ColumnNames::SALT];
         if ($password->Validate($salt)) {
             $password->Migrate($row[ColumnNames::USER_ID]);
             $valid = true;
         }
     }
     Log::Debug('User: %s, was validated: %d', $username, $valid);
     return $valid;
 }
开发者ID:utn-frm-si,项目名称:booked,代码行数:22,代码来源:Authentication.php

示例6: RemoveResourceGroupPermission

 public function RemoveResourceGroupPermission($resourceId, $groupId)
 {
     ServiceLocator::GetDatabase()->Execute(new DeleteGroupResourcePermission($groupId, $resourceId));
 }
开发者ID:ViraSoftware,项目名称:booked,代码行数:4,代码来源:ResourceRepository.php

示例7: GetNextReservations

 /**
  * @param Date $earliestDate
  * @param null $lastDate
  * @return NextReservationView[]
  */
 public function GetNextReservations(Date $earliestDate, $lastDate = null)
 {
     if ($lastDate == null) {
         $lastDate = new NullDate();
     }
     $command = new GetNextReservationsCommand($earliestDate, $lastDate);
     $result = ServiceLocator::GetDatabase()->Query($command);
     $reservations = array();
     while ($row = $result->GetRow()) {
         $reservations[$row[ColumnNames::RESOURCE_ID]] = NextReservationView::Populate($row);
     }
     $result->Free();
     return $reservations;
 }
开发者ID:eEksperimenti,项目名称:Booked,代码行数:19,代码来源:ReservationViewRepository.php

示例8: GetReminderNotices

 /**
  * @param Date $now
  * @param ReservationReminderType $reminderType
  * @return ReminderNotice[]|array
  */
 public function GetReminderNotices(Date $now, $reminderType)
 {
     $reader = ServiceLocator::GetDatabase()->Query(new GetReminderNoticesCommand($now->ToTheMinute(), $reminderType));
     $notices = array();
     while ($row = $reader->GetRow()) {
         $notices[] = ReminderNotice::FromRow($row);
     }
     $reader->Free();
     return $notices;
 }
开发者ID:Trideon,项目名称:gigolo,代码行数:15,代码来源:ReminderRepository.php

示例9: GetGroupsByRole

 /**
  * @param $roleLevel int|RoleLevel
  * @return GroupItemView[]|array
  */
 public function GetGroupsByRole($roleLevel)
 {
     $reader = ServiceLocator::GetDatabase()->Query(new GetAllGroupsByRoleCommand($roleLevel));
     $groups = array();
     while ($row = $reader->GetRow()) {
         $groups[] = GroupItemView::Create($row);
     }
     $reader->Free();
     return $groups;
 }
开发者ID:hugutux,项目名称:booked,代码行数:14,代码来源:GroupRepository.php

示例10: Update

 /**
  * @param BlackoutSeries $blackoutSeries
  */
 public function Update(BlackoutSeries $blackoutSeries)
 {
     if ($blackoutSeries->IsNew()) {
         $seriesId = $this->AddSeries($blackoutSeries);
         $db = ServiceLocator::GetDatabase();
         $start = $blackoutSeries->CurrentBlackout()->StartDate();
         $end = $blackoutSeries->CurrentBlackout()->EndDate();
         $db->Execute(new UpdateBlackoutInstanceCommand($blackoutSeries->CurrentBlackoutInstanceId(), $seriesId, $start, $end));
     } else {
         $this->DeleteSeries($blackoutSeries->CurrentBlackoutInstanceId());
         $this->Add($blackoutSeries);
     }
 }
开发者ID:hugutux,项目名称:booked,代码行数:16,代码来源:BlackoutRepository.php

示例11: DeleteById

 /**
  * @param $quotaId
  * @return void
  */
 function DeleteById($quotaId)
 {
     //TODO:  Make this delete a quota instead of the id
     $command = new DeleteQuotaCommand($quotaId);
     ServiceLocator::GetDatabase()->Execute($command);
 }
开发者ID:Trideon,项目名称:gigolo,代码行数:10,代码来源:QuotaRepository.php

示例12: UserExists

 public function UserExists($emailAddress, $userName)
 {
     $reader = ServiceLocator::GetDatabase()->Query(new CheckUserExistenceCommand($userName, $emailAddress));
     if ($row = $reader->GetRow()) {
         return $row[ColumnNames::USER_ID];
     }
     return null;
 }
开发者ID:ksdtech,项目名称:booked,代码行数:8,代码来源:UserRepository.php

示例13: AddScheduleLayout

 public function AddScheduleLayout($scheduleId, ILayoutCreation $layout)
 {
     $db = ServiceLocator::GetDatabase();
     $timezone = $layout->Timezone();
     $addLayoutCommand = new AddLayoutCommand($timezone);
     $layoutId = $db->ExecuteInsert($addLayoutCommand);
     $days = array(null);
     if ($layout->UsesDailyLayouts()) {
         $days = DayOfWeek::Days();
     }
     foreach ($days as $day) {
         $slots = $layout->GetSlots($day);
         /* @var $slot LayoutPeriod */
         foreach ($slots as $slot) {
             $db->Execute(new AddLayoutTimeCommand($layoutId, $slot->Start, $slot->End, $slot->PeriodType, $slot->Label, $day));
         }
     }
     $db->Execute(new UpdateScheduleLayoutCommand($scheduleId, $layoutId));
     $db->Execute(new DeleteOrphanLayoutsCommand());
 }
开发者ID:Trideon,项目名称:gigolo,代码行数:20,代码来源:ScheduleRepository.php

示例14: Delete

 /**
  * @param int $accessoryId
  * @return void
  */
 public function Delete($accessoryId)
 {
     ServiceLocator::GetDatabase()->Execute(new DeleteAccessoryCommand($accessoryId));
 }
开发者ID:Trideon,项目名称:gigolo,代码行数:8,代码来源:AccessoryRepository.php

示例15: define

You should have received a copy of the GNU General Public License
along with Booked Scheduler.  If not, see <http://www.gnu.org/licenses/>.
*/
define('ROOT_DIR', dirname(__FILE__) . '/../');
require_once ROOT_DIR . 'lib/Application/Reservation/namespace.php';
require_once ROOT_DIR . 'lib/Common/Helpers/namespace.php';
echo "<h1>Booked Scheduler Data Load</h1>";
$stopWatch = new StopWatch();
$stopWatch->Start();
$numberOfResources = 10;
$numberOfUsers = 1000;
$numberOfReservations = 5000;
$numberOfAccessories = 20;
$users = array();
$resources = array();
$db = ServiceLocator::GetDatabase();
// USERS
$db->Execute(new AdHocCommand("delete from users where fname ='load' and lname = 'test'"));
$userRepo = new UserRepository();
for ($i = 0; $i < $numberOfUsers; $i++) {
    $user = User::Create("load{$i}", "test{$i}", "email {$i}", "username {$i}", "en_us", "America/Chicago", "7b6aec38ff9b7650d64d0374194307bdde711425", "3b3dbb9b");
    $userId = $userRepo->Add($user);
    $users[] = $user;
}
echo "Loaded {$numberOfUsers} users<br/>";
// RESOURCES
$db->Execute(new AdHocCommand("delete from resources where name like 'load%'"));
$resourceRepo = new ResourceRepository();
for ($i = 0; $i < $numberOfResources; $i++) {
    $resource = BookableResource::CreateNew("load{$i}", 1);
    $resourceId = $resourceRepo->Add($resource);
开发者ID:utn-frm-si,项目名称:booked,代码行数:31,代码来源:load_test.php


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