本文整理匯總了PHP中OW::getDbo方法的典型用法代碼示例。如果您正苦於以下問題:PHP OW::getDbo方法的具體用法?PHP OW::getDbo怎麽用?PHP OW::getDbo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OW
的用法示例。
在下文中一共展示了OW::getDbo方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: findUsers
public function findUsers($groupId, $count, $withPhoto = true)
{
$userTable = BOL_UserDao::getInstance()->getTableName();
$avatarJoin = !$withPhoto ? '' : "INNER JOIN `" . BOL_AvatarDao::getInstance()->getTableName() . "` as `a`\n \t\t\tON( `u`.`id` = `a`.`userId` )";
$query = "\n SELECT `u`.* FROM `{$userTable}` AS `u`\n\n INNER JOIN `" . GROUPS_BOL_GroupUserDao::getInstance()->getTableName() . "` AS `g`\n ON( `u`.`id` = `g`.`userId` )\n\n LEFT JOIN `" . BOL_UserSuspendDao::getInstance()->getTableName() . "` as `s`\n ON( `u`.`id` = `s`.`userId` )\n\n LEFT JOIN `" . BOL_UserApproveDao::getInstance()->getTableName() . "` as `d`\n ON( `u`.`id` = `d`.`userId` )\n\n {$avatarJoin}\n\n WHERE g.groupId=:g AND `s`.`id` IS NULL AND `d`.`id` IS NULL\n ORDER BY `u`.`activityStamp` DESC\n LIMIT :ls, :le";
return OW::getDbo()->queryForObjectList($query, BOL_UserDao::getInstance()->getDtoClassName(), array('ls' => 0, 'le' => $count, 'g' => $groupId));
}
示例2: init
/**
* Application init actions.
*/
public function init()
{
// $this->urlHostRedirect();
// //printVar(10);exit;
$this->userAutoLogin();
// setting default time zone
date_default_timezone_set(OW::getConfig()->getValue('base', 'site_timezone'));
// OW::getRequestHandler()->setIndexPageAttributes('BASE_CTRL_ComponentPanel');
// OW::getRequestHandler()->setStaticPageAttributes('BASE_CTRL_StaticDocument');
//
// // router init - need to set current page uri and base url
$router = OW::getRouter();
$router->setBaseUrl(OW_URL_HOME . 'api/');
$uri = OW::getRequest()->getRequestUri();
// before setting in router need to remove get params
if (strstr($uri, '?')) {
$uri = substr($uri, 0, strpos($uri, '?'));
}
$router->setUri($uri);
$router->setDefaultRoute(new OW_ApiDefaultRoute());
$beckend = OW::getEventManager()->call('base.cache_backend_init');
if ($beckend !== null) {
OW::getCacheManager()->setCacheBackend($beckend);
OW::getCacheManager()->setLifetime(3600);
OW::getDbo()->setUseCashe(true);
}
OW::getResponse()->setDocument($this->newDocument());
}
示例3: import
public function import($params)
{
$importDir = $params['importDir'];
$sqlFile = $importDir . 'configs.sql';
//import configs
if (file_exists($sqlFile)) {
DATAIMPORTER_BOL_ImportService::getInstance()->sqlImport($sqlFile);
}
$configFile = $importDir . 'config.txt';
$string = file_get_contents($configFile);
$this->configs = json_decode($string, true);
$this->importAvatars($this->configs['avatarUrl']);
$this->importTheme($importDir);
$this->importMediaPanelFiles();
if (OW::getPluginManager()->getPlugin('dataimporter')) {
if (file_exists(OW::getPluginManager()->getPlugin('dataimporter')->getRootDir() . 'langs.zip')) {
OW::getLanguage()->importPluginLangs(OW::getPluginManager()->getPlugin('dataimporter')->getRootDir() . 'langs.zip', 'dataimporter');
}
}
$languageId = OW::getLanguage()->getCurrentId();
BOL_LanguageService::getInstance()->generateCache($languageId);
OW::getDbo()->query("TRUNCATE " . OW_DB_PREFIX . 'base_component_place_cache');
//TODO: Use service function
// ADD MENU ITEMS add plugin and add theme
try {
OW::getDbo()->query("INSERT IGNORE INTO `" . OW_DB_PREFIX . "base_menu_item` ( `prefix`, `key`, `documentKey`, `type`, `order`, `routePath`, `externalUrl`, `newWindow`, `visibleFor`) VALUES ( 'admin', 'sidebar_menu_plugins_add', '', 'admin_plugins', 3, 'admin_plugins_add', NULL, 0, 2) ");
} catch (Exception $ex) {
}
try {
OW::getDbo()->query("INSERT IGNORE INTO `" . OW_DB_PREFIX . "base_menu_item` ( `prefix`, `key`, `documentKey`, `type`, `order`, `routePath`, `externalUrl`, `newWindow`, `visibleFor`) VALUES ( 'admin', 'sidebar_menu_themes_add', '', 'admin_appearance', 3, 'admin_themes_add_new', NULL, 0, 3) ");
} catch (Exception $ex) {
}
}
示例4: saveToplink
public function saveToplink(TOPLINK_BOL_Toplink $toplinkitems, $permission = null)
{
TOPLINK_BOL_ToplinkDao::getInstance()->save($toplinkitems);
if (!empty($toplinkitems->id)) {
$newId = OW::getDbo()->getInsertId();
//print_r( $toplinkitems );
}
$example = new OW_EXAMPLE();
$example->andFieldEqual('itemid', $toplinkitems->id);
$listOfItem = TOPLINK_BOL_ToplinkPermissionDao::getInstance()->findListByExample($example);
if (!empty($listOfItem)) {
if (!empty($permission)) {
//get saved permission
foreach ($listOfItem as $permissionObj) {
$visibleFor[$permissionObj->id] = $permissionObj->availablefor;
}
//if perm item is reduced, remove also from table
$removeInstalled = array_diff($visibleFor, $permission);
if (!empty($removeInstalled)) {
foreach ($removeInstalled as $id => $myperm) {
TOPLINK_BOL_ToplinkPermissionDao::getInstance()->deleteById($id);
}
}
//if perm is added, add also into table
$installNew = array_diff($permission, $visibleFor);
if (!empty($installNew)) {
foreach ($installNew as $id) {
$toplinkPermission = new TOPLINK_BOL_ToplinkPermission();
$toplinkPermission->itemid = $toplinkitems->id;
$toplinkPermission->availablefor = $id;
TOPLINK_BOL_ToplinkPermissionDao::getInstance()->save($toplinkPermission);
}
}
} else {
//if permission is not provided, remove except for admin
foreach ($listOfItem as $permissionObj) {
if ($permissionObj->availablefor != 1) {
TOPLINK_BOL_ToplinkPermissionDao::getInstance()->deleteById($permissionObj->availablefor);
}
}
}
} else {
if (!empty($permission)) {
//if no perm found in table, add allow to admin
foreach ($permission as $perm) {
$toplinkPermission = new TOPLINK_BOL_ToplinkPermission();
$toplinkPermission->itemid = $toplinkitems->id;
$toplinkPermission->availablefor = $perm;
TOPLINK_BOL_ToplinkPermissionDao::getInstance()->save($toplinkPermission);
}
} else {
//if no perm found in table, add allow to admin
$toplinkPermission = new TOPLINK_BOL_ToplinkPermission();
$toplinkPermission->itemid = $toplinkitems->id;
$toplinkPermission->availablefor = 1;
TOPLINK_BOL_ToplinkPermissionDao::getInstance()->save($toplinkPermission);
}
}
return $newId;
}
示例5: import
public function import($params)
{
$importDir = $params['importDir'];
$txtFile = $importDir . 'configs.txt';
// import configs
if (file_exists($txtFile)) {
$string = file_get_contents($txtFile);
$configs = json_decode($string, true);
}
if (!$configs) {
return;
}
$attachmentService = FORUM_BOL_PostAttachmentService::getInstance();
$attDir = OW::getPluginManager()->getPlugin('forum')->getUserFilesDir();
$attachments = $attachmentService->findAllAttachments();
if (!$attachments) {
return;
}
foreach ($attachments as $file) {
OW::getDbo()->query("SELECT 1 ");
$ext = UTIL_File::getExtension($file->fileName);
$path = $attachmentService->getAttachmentFilePath($file->id, $file->hash, $ext);
$fileName = str_replace($attDir, '', $path);
$content = file_get_contents($configs['url'] . '/' . $fileName);
if (mb_strlen($content)) {
OW::getStorage()->fileSetContent($path, $content);
}
}
}
示例6: resetAllUsersLastData
public function resetAllUsersLastData()
{
$sql = "SELECT COUNT(*) FROM `" . MAILBOX_BOL_UserLastDataDao::getInstance()->getTableName() . "` AS `uld`\nLEFT JOIN `" . BOL_UserOnlineDao::getInstance()->getTableName() . "` AS uo ON uo.userId = uld.userId\nWHERE uo.id IS NULL";
$usersOfflineButOnline = OW::getDbo()->queryForColumn($sql);
if ($usersOfflineButOnline > 0) {
MAILBOX_BOL_ConversationService::getInstance()->resetAllUsersLastData();
}
}
示例7: copyFeed
private function copyFeed()
{
if (OW::getPluginManager()->isPluginActive('newsfeed')) {
$tbl = NEWSFEED_BOL_ActionDao::getInstance()->getTableName();
$query = 'UPDATE ' . $tbl . ' SET pluginKey="equestions" WHERE pluginKey="questions"';
OW::getDbo()->query($query);
}
}
示例8: findUsers
public function findUsers($kw, $limit = null)
{
$questionName = OW::getConfig()->getValue('base', 'display_name_question');
$questionDataTable = BOL_QuestionDataDao::getInstance()->getTableName();
$limitStr = $limit === null ? '' : 'LIMIT 0, ' . intval($limit);
$query = 'SELECT DISTINCT qd.userId FROM ' . $questionDataTable . ' qd
LEFT JOIN `' . BOL_UserSuspendDao::getInstance()->getTableName() . '` AS `us` ON ( `qd`.`userId` = `us`.`userId` )
WHERE `us`.`userId` IS NULL AND questionName=:name AND textValue LIKE :kw ' . $limitStr;
return OW::getDbo()->queryForColumnList($query, array('kw' => '%' . $kw . '%', 'name' => $questionName));
}
示例9: detectCountry
public function detectCountry()
{
try {
$sql = 'SELECT `cc2` FROM `' . BOL_GeolocationIpToCountryDao::getInstance()->getTableName() . '`
WHERE inet_aton(:ip) >= ipFrom AND inet_aton(:ip) <= ipTo';
return OW::getDbo()->queryForColumn($sql, array('ip' => OW::getRequest()->getRemoteAddress()));
} catch (Exception $e) {
return null;
}
}
示例10: render
/**
* Returns rendered markup.
*
* @return string
*/
public function render()
{
if (defined("OW_PROFILER_ENABLE") && OW_PROFILER_ENABLE) {
$this->assign('queryLog', OW::getDbo()->getQueryLog());
$this->assign('queryCount', OW::getDbo()->getQueryCount());
$this->assign('queryExecutionTime', OW::getDbo()->getTotalQueryExecTime());
$this->assign('pageTime', UTIL_Profiler::getInstance()->getResult());
}
return $this->assignedVars;
}
示例11: findUsers
public function findUsers($kw, $userId, $limit = null)
{
if (!OW::getPluginManager()->isPluginActive('friends')) {
return array();
}
$friendsTable = FRIENDS_BOL_FriendshipDao::getInstance()->getTableName();
$questionName = OW::getConfig()->getValue('base', 'display_name_question');
$questionDataTable = BOL_QuestionDataDao::getInstance()->getTableName();
$limitStr = $limit === null ? '' : 'LIMIT 0, ' . intval($limit);
$query = "SELECT `fr`.`userId` FROM `" . $friendsTable . "` AS `fr`\n INNER JOIN " . $questionDataTable . " qd ON fr.userId = qd.userId\n LEFT JOIN `" . BOL_UserSuspendDao::getInstance()->getTableName() . "` AS `us` ON ( `fr`.`friendId` = `us`.`userId` )\n WHERE `fr`.`status` = :status AND `us`.`userId` IS NULL AND `fr`.`friendId` = :userId\n AND qd.questionName=:name AND qd.textValue LIKE :kw\n UNION\n SELECT `fr`.`friendId` AS `userId` FROM `" . $friendsTable . "` AS `fr`\n INNER JOIN " . $questionDataTable . " qd ON fr.friendId = qd.userId\n LEFT JOIN `" . BOL_UserSuspendDao::getInstance()->getTableName() . "` AS `us` ON ( `fr`.`friendId` = `us`.`userId` )\n WHERE `fr`.`status` = :status AND `us`.`userId` IS NULL AND `fr`.`userId` = :userId\n AND qd.questionName=:name AND qd.textValue LIKE :kw\n {$limitStr}\n ";
return OW::getDbo()->queryForColumnList($query, array('userId' => $userId, 'status' => FRIENDS_BOL_FriendshipDao::VAL_STATUS_ACTIVE, 'kw' => '%' . $kw . '%', 'name' => $questionName));
}
示例12: usearch_set_question_sql
function usearch_set_question_sql(BASE_CLASS_QueryBuilderEvent $event)
{
$params = $event->getParams();
if (empty($params['question']) || !$params['question'] instanceof BOL_Question || empty($params['value']) || !in_array($params['question']->name, array('sex', 'match_sex'))) {
return;
}
$value = is_array($params['value']) ? array_sum($params['value']) : (int) $params['value'];
$prefix = !empty($params['prefix']) ? $params['prefix'] : 'q' . rand(100, 10000);
$questionName = $params['question']->name == 'sex' ? 'match_sex' : 'sex';
$innerJoin = " INNER JOIN `" . BOL_QuestionDataDao::getInstance()->getTableName() . "` `" . $prefix . "`\n ON ( `user`.`id` = `" . $prefix . "`.`userId` AND `" . $prefix . "`.`questionName` = '" . OW::getDbo()->escapeString($questionName) . "' AND `" . $prefix . "`.`intValue` & " . OW::getDbo()->escapeString($value) . " ) ";
$event->addJoin($innerJoin);
}
示例13: findGroups
public function findGroups($kw, $userId, $limit = null)
{
$groupDao = GROUPS_BOL_GroupDao::getInstance();
$groupUserDao = GROUPS_BOL_GroupUserDao::getInstance();
$params = array('u' => $userId);
if (!empty($kw)) {
$params["kw"] = "%" . $kw . "%";
}
$limitStr = $limit === null ? '' : 'LIMIT 0, ' . intval($limit);
$kwWhere = empty($kw) ? "1" : "g.title LIKE :kw";
$query = "SELECT DISTINCT g.* FROM " . $groupDao->getTableName() . " g\n INNER JOIN " . $groupUserDao->getTableName() . " u ON g.id = u.groupId AND u.id != :u\n WHERE g.userId=:u AND {$kwWhere} " . $limitStr;
return OW::getDbo()->queryForObjectList($query, $groupDao->getDtoClassName(), $params);
}
示例14: findEvents
public function findEvents($past, $kw, $userId, $limit = null)
{
$eventDao = EVENT_BOL_EventDao::getInstance();
$eventUserDao = EVENT_BOL_EventUserDao::getInstance();
$params = array('startTime' => time(), 'endTime' => time(), 'u' => $userId, 's' => EVENT_BOL_EventUserDao::VALUE_STATUS_YES);
if (!empty($kw)) {
$params["kw"] = "%" . $kw . "%";
}
$limitStr = $limit === null ? '' : 'LIMIT 0, ' . intval($limit);
$kwWhere = empty($kw) ? "1" : "e.title LIKE :kw";
$order = "e.`startTimeStamp` " . ($past ? "DESC" : "");
$query = "SELECT e.* FROM `" . $eventDao->getTableName() . "` e \n INNER JOIN " . $eventUserDao->getTableName() . " u ON u.eventId=e.id AND u.status=:s\n WHERE u.userId!=:u AND e.userId=:u AND " . $this->getTimeClause($past, "e") . " AND " . $kwWhere . "\n ORDER BY {$order} {$limitStr}";
return OW::getDbo()->queryForObjectList($query, $eventDao->getDtoClassName(), $params);
}
示例15: findUserPhotos
public function findUserPhotos($userId, $start, $offset)
{
$photoService = PHOTO_BOL_PhotoService::getInstance();
$photoDao = PHOTO_BOL_PhotoDao::getInstance();
$albumDao = PHOTO_BOL_PhotoAlbumDao::getInstance();
$query = 'SELECT p.* FROM ' . $photoDao->getTableName() . ' AS p
INNER JOIN ' . $albumDao->getTableName() . ' AS a ON p.albumId=a.id
WHERE a.userId=:u AND p.status = "approved" ORDER BY p.addDatetime DESC
LIMIT :start, :offset';
$list = OW::getDbo()->queryForList($query, array('u' => $userId, 'start' => $start, 'offset' => $offset));
$out = array();
foreach ($list as $photo) {
$id = $photo['id'];
$out[$id] = array('id' => $id, 'thumb' => $photoService->getPhotoPreviewUrl($id), 'url' => $photoService->getPhotoUrl($id), 'path' => $photoService->getPhotoPath($id), 'description' => $photo['description'], 'permalink' => OW::getRouter()->urlForRoute('view_photo', array('id' => $id)));
$out[$id]['oembed'] = json_encode(array('type' => 'photo', 'url' => $out[$id]['url'], 'href' => $out[$id]['permalink'], 'description' => $out[$id]['description']));
}
return $out;
}