本文整理汇总了PHP中SJB_DB类的典型用法代码示例。如果您正苦于以下问题:PHP SJB_DB类的具体用法?PHP SJB_DB怎么用?PHP SJB_DB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SJB_DB类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAddParameter
function getAddParameter()
{
if (isset($this->property_info['value']['add_parameter'])) {
return SJB_DB::quote($this->property_info['value']['add_parameter']);
}
return '';
}
示例2: getObjectInfo
function getObjectInfo($sorting_fields, $inner_join = false, $relevance = false)
{
$SearchSqlTranslator = new SJB_GuestAlertSearchSQLTranslator($this->table_prefix);
$sql_string = $SearchSqlTranslator->buildSqlQuery($this->criteria, $this->valid_criterion_number, $sorting_fields, $this->inner_join);
if ($this->sorting_field !== false && $this->sorting_order !== false) {
$sql_string .= ' ORDER BY ' . $this->sorting_field . ' ' . $this->sorting_order . ' ';
}
SJB_DB::queryExec($sql_string);
$affectedRows = SJB_DB::getAffectedRows();
if ($this->limit !== false) {
if (isset($this->limit['limit'])) {
$sql_string .= 'limit ' . $this->limit['limit'] . ', ' . $this->limit['num_rows'];
} else {
$sql_string .= 'limit ' . $this->limit . ', 100';
}
}
$sql_results = SJB_DB::query($sql_string);
$result = array();
foreach ($sql_results as $sql_result) {
if ($this->valid_criterion_number == 0 || $sql_result['countRows'] == $this->valid_criterion_number) {
$result[]['object_sid'] = $sql_result['object_sid'];
}
}
$this->affectedRows = $affectedRows - (SJB_DB::getAffectedRows() - count($result));
return $result;
}
示例3: login
public static function login($username, $password, $keep_signed, &$errors, $login_as_user = false, $autoriseByUsername = false)
{
$login = SJB_UserManager::login($username, $password, $errors, $autoriseByUsername, $login_as_user);
if ($login) {
if (SJB_UserManager::checkBan($errors)) {
return false;
}
$userInfo = SJB_UserManager::getUserInfoByUserName($username);
if (!$userInfo['active']) {
$errors['USER_NOT_ACTIVE'] = 1;
return false;
}
// if "Approve Users by Admin" option is turned on
$userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($userInfo['user_group_sid']);
if (!empty($userGroupInfo['approve_user_by_admin']) && 'Approved' != $userInfo['approval']) {
$errors['USER_NOT_APPROVED'] = 1;
return false;
}
$loginParams = array('username' => $username, 'password' => $password);
SJB_Event::dispatch('Login', $loginParams);
if ($keep_signed) {
SJB_Authorization::keepUserSignedIn($userInfo);
}
SJB_DB::query('update `users` set `ip` = ?s where `sid` = ?n', $_SERVER['REMOTE_ADDR'], $userInfo['sid']);
if (!empty($userInfo['parent_sid'])) {
$subuserInfo = $userInfo;
$userInfo = SJB_UserManager::getUserInfoBySID($userInfo['parent_sid']);
$userInfo['subuser'] = $subuserInfo;
}
SJB_Authorization::setSessionForUser($userInfo);
return true;
}
return false;
}
示例4: isDataValid
function isDataValid(&$errors)
{
$errors = array();
if ($this->name == '') {
$errors['Zip Code'] = 'EMPTY_VALUE';
}
$count = SJB_DB::queryValue("SELECT count(*) FROM `locations` WHERE `name` = ?s AND `country_sid` = ?s AND `state` = ?s AND `city` = ?s AND sid <> ?n ", $this->name, $this->country_sid, $this->state, $this->city, $this->sid);
if ($count) {
$errors['Zip Code'] = 'NOT_UNIQUE_VALUE';
}
if ($this->longitude == '') {
$errors['Longitude'] = 'EMPTY_VALUE';
} elseif (!is_numeric($this->longitude)) {
$errors['Longitude'] = 'NOT_FLOAT_VALUE';
}
if ($this->latitude == '') {
$errors['Latitude'] = 'EMPTY_VALUE';
} elseif (!is_numeric($this->latitude)) {
$errors['Latitude'] = 'NOT_FLOAT_VALUE';
}
if ($this->country_sid == '') {
$errors['Country'] = 'EMPTY_VALUE';
}
return count($errors) == 0;
}
示例5: _getWhatPart
function _getWhatPart()
{
if (is_array($this->order_info['property'])) {
foreach ($this->order_info['property'] as $orderInfoProperty) {
$property[] = $orderInfoProperty;
}
} else {
$property = $this->order_info['property'];
}
if (is_array($property)) {
foreach ($property as $propertyItem) {
if ($propertyItem->isSystem()) {
return "`{$this->table_prefix}`.sid";
}
}
} elseif ($property->isSystem()) {
if ($this->orderRelevance) {
$value = SJB_DB::quote($this->orderRelevance['value']['value']);
return "`{$this->table_prefix}`.sid, MATCH(`{$this->orderRelevance['value']['field']}`) AGAINST ('{$value}') as relevance";
} else {
return "`{$this->table_prefix}`.sid";
}
} elseif ($property->getType() != 'tree') {
$id = $property->getID();
$sql_type = $property->getSQLType();
if ($sql_type == 'DECIMAL') {
// DECIMAL type is available in MYSQL 5.0.8 or higher
return "{$this->table_prefix}.*, {$id}.value + 0.0 AS {$id}";
}
return "{$this->table_prefix}.*, CAST({$id}.value AS {$sql_type}) AS {$id}";
}
$tree_browser = new SJB_TreeBrowser($property->getID());
return "{$this->table_prefix}.*, " . $tree_browser->getWhatPart();
}
示例6: isAdminExist
public static function isAdminExist($username, $password)
{
$username = SJB_DB::quote($username);
$password = md5(SJB_DB::quote($password));
$value = SJB_DB::queryValue("SELECT * FROM `administrator` WHERE `username` = ?s AND `password` = '?w'", $username, $password);
return !empty($value);
}
示例7: savePermissions
public function savePermissions($request, $product)
{
$acl = SJB_Acl::getInstance();
$resources = $acl->getResources();
$type = 'product';
$role = $product->getSID();
SJB_Acl::clearPermissions($type, $role);
$userGroupSID = $product->getPropertyValue('user_group_sid');
$groupPermissions = SJB_DB::query('select * from `permissions` where `type` = ?s and `role` = ?s', 'group', $userGroupSID);
foreach ($groupPermissions as $key => $groupPermission) {
$groupPermissions[$groupPermission['name']] = $groupPermission;
unset($groupPermissions[$key]);
}
foreach ($resources as $name => $resource) {
$params = isset($request[$name . '_params']) ? $request[$name . '_params'] : '';
$params1 = isset($request[$name . '_params1']) ? $request[$name . '_params1'] : '';
$value = isset($request[$name]) ? $request[$name] : '';
$message = isset($request[$name . '_message']) ? $request[$name . '_message'] : '';
if (empty($value) && isset($groupPermissions[$name])) {
$value = 'inherit';
$message = $groupPermissions[$name]['message'];
$params = $groupPermissions[$name]['params'];
} elseif ($value == 'deny' && $params1) {
$params = $params1;
}
SJB_Acl::allow($name, $type, $role, $value, $params, $message);
}
}
示例8: execute
public function execute()
{
$template = SJB_Request::getVar('template', 'featured_listings.tpl');
$listingType = SJB_Request::getVar('listing_type', 'Job');
$searches['data']['listing_type']['equal'] = $listingType;
$searches['data']['featured']['equal'] = 1;
$searches['data']['default_listings_per_page'] = SJB_Request::getVar('items_count', 1);
$searches['data']['sorting_field'] = 'featured_last_showed';
$searches['data']['default_sorting_field'] = 'featured_last_showed';
$searches['data']['default_sorting_order'] = 'ASC';
$searches['data']['sorting_order'] = 'ASC';
// фичерные листинги кешировать не будем
$cache = SJB_Cache::getInstance();
$caching = $cache->getOption('caching');
$cache->setOption('caching', false);
$searchResultsTP = new SJB_SearchResultsTP($searches['data'], $listingType);
$searchResultsTP->setLimit(SJB_Request::getVar('items_count', 1));
$tp = $searchResultsTP->getChargedTemplateProcessor();
$featuredListingSIDs = $searchResultsTP->getListingSidCollectionForCurrentPage();
if ($featuredListingSIDs) {
SJB_DB::query('UPDATE `listings` SET `featured_last_showed` = NOW() WHERE `sid` in (?w)', implode(',', $featuredListingSIDs));
SJB_Statistics::addSearchStatistics($featuredListingSIDs, $listingType);
}
$cache->setOption('caching', $caching);
$tp->assign('number_of_cols', SJB_Request::getVar('number_of_cols', 1));
$tp->display($template);
}
示例9: execute
public function execute()
{
ini_set('max_execution_time', 0);
$tp = SJB_System::getTemplateProcessor();
$userGroupID = SJB_Request::getVar('user_group_id', 0);
$user = SJB_UsersExportController::createUser($userGroupID);
$searchFormBuilder = new SJB_SearchFormBuilder($user);
$criteria = $searchFormBuilder->extractCriteriaFromRequestData($_REQUEST, $user);
$searchFormBuilder->registerTags($tp);
$searchFormBuilder->setCriteria($criteria);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$exportProperties = SJB_Request::getVar('export_properties', array());
if (empty($exportProperties)) {
SJB_FlashMessages::getInstance()->addWarning('EMPTY_EXPORT_PROPERTIES');
} else {
$innerJoin = false;
if (isset($_REQUEST['product']['multi_like']) && $_REQUEST['product']['multi_like'] != '') {
$products = $_REQUEST['product']['multi_like'];
if (is_array($products)) {
$products = implode(',', $products);
}
$whereParam = implode(',', explode(',', SJB_DB::quote($products)));
$innerJoin = array('contracts' => array('join_field' => 'user_sid', 'join_field2' => 'sid', 'join' => 'INNER JOIN', 'where' => "AND FIND_IN_SET(`contracts`.`product_sid`, '{$whereParam}')"));
unset($criteria['system']['product']);
}
$searcher = new SJB_UserSearcher(false, 'parent_sid', 'ASC', $innerJoin);
$searchAliases = SJB_UsersExportController::getSearchPropertyAliases();
$foundUsersSid = $searcher->getObjectsSIDsByCriteria($criteria, $searchAliases);
if (!empty($foundUsersSid)) {
$result = SJB_UsersExportController::createExportDirectories();
if ($result === true) {
$exportProperties['extUserID'] = 1;
$exportProperties['parent_sid'] = 1;
$exportAliases = SJB_UsersExportController::getExportPropertyAliases();
$exportData = SJB_UsersExportController::getExportData($foundUsersSid, $exportProperties, $exportAliases);
$fileName = 'users.xls';
SJB_UsersExportController::makeExportFile($exportData, $fileName);
if (!file_exists(SJB_System::getSystemSettings('EXPORT_FILES_DIRECTORY') . "/{$fileName}")) {
SJB_FlashMessages::getInstance()->addWarning('CANT_CREATE_EXPORT_FILES');
} else {
SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . "/users/archive-and-send-export-data/");
}
}
} else {
SJB_FlashMessages::getInstance()->addWarning('EMPTY_EXPORT_DATA');
}
}
}
$userSystemProperties = SJB_UserManager::getAllUserSystemProperties();
$userGroups = SJB_UserGroupManager::getAllUserGroupsInfo();
$userCommonProperties = array();
foreach ($userGroups as $userGroup) {
$userGroupProperties = SJB_UserProfileFieldManager::getFieldsInfoByUserGroupSID($userGroup['sid']);
$userCommonProperties[$userGroup['id']] = $userGroupProperties;
}
$tp->assign('userSystemProperties', $userSystemProperties);
$tp->assign('userCommonProperties', $userCommonProperties);
$tp->assign('selected_user_group_id', $userGroupID);
$tp->display('export_users.tpl');
}
示例10: execute
public function execute()
{
set_time_limit(0);
$notifiedEmails = array();
$emailScheduling = SJB_Settings::getSettingByName('email_scheduling');
$numberEmails = SJB_Settings::getSettingByName('number_emails');
$emailsSend = SJB_Settings::getSettingByName('send_emails');
$limit = $numberEmails - $emailsSend;
$limit = $limit > 0 ? $limit : 20;
$letters = SJB_DB::query('SELECT * FROM `email_scheduling` ORDER BY `id` ASC LIMIT 0, ?n', $limit);
if ($emailScheduling && $numberEmails || count($letters)) {
foreach ($letters as $letter) {
$params = $letter;
unset($params['id']);
$email = new SJB_Email($params['email']);
$email->setSubject($params['subject']);
$email->setText($params['text']);
$email->setFile($params['file']);
if ($email->send(true)) {
SJB_DB::query('DELETE FROM `email_scheduling` WHERE `id` = ?n', $letter['id']);
array_push($notifiedEmails, $params['email']);
}
}
}
$tp = SJB_System::getTemplateProcessor();
$tp->assign('notified_emails', $notifiedEmails);
$schedulerLog = $tp->fetch('email_scheduler_log.tpl');
SJB_HelperFunctions::writeCronLogFile('email_scheduler.log', $schedulerLog);
}
示例11: execute
public function execute()
{
$listing_id = SJB_Request::getVar('listing_id', null);
$tp = SJB_System::getTemplateProcessor();
if (isset($_REQUEST['action'])) {
$action = strtolower($_REQUEST['action']);
$comment_id = SJB_Request::getVar('comment_id', null);
if (is_null($listing_id) && !is_null($comment_id)) {
$listing_id = SJB_CommentManager::getListingSIDByCommentSID($comment_id);
}
$comment_ids = array();
if (isset($_REQUEST['comment']) && is_array($_REQUEST['comment'])) {
$comment_ids = array_keys($_REQUEST['comment']);
} else {
$comment_ids = array($comment_id);
}
switch ($action) {
case 'delete':
foreach ($comment_ids as $comment_id) {
SJB_CommentManager::deleteComment($comment_id);
}
break;
case 'disable':
foreach ($comment_ids as $comment_id) {
SJB_CommentManager::disableComment($comment_id);
}
break;
case 'enable':
foreach ($comment_ids as $comment_id) {
SJB_CommentManager::enableComment($comment_id);
}
break;
case 'edit':
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
SJB_DB::query("UPDATE `comments` SET `message` = ?s WHERE `sid` = ?n", $_REQUEST['message'], $comment_id);
} else {
$listingInfo = SJB_ListingManager::getListingInfoBySID($listing_id);
$listingTypeInfo = SJB_ListingTypeManager::getListingTypeInfoBySID($listingInfo['listing_type_sid']);
$tp->assign('listingType', SJB_ListingTypeManager::createTemplateStructure($listingTypeInfo));
$tp->assign('comment', SJB_CommentManager::getObjectInfoBySID('comments', $comment_id));
$tp->display('edit_comment.tpl');
return;
}
break;
}
header('Location: ' . SJB_System::getSystemSettings('SITE_URL') . '/listing-comments/?listing_id=' . $listing_id);
exit;
}
if (!is_null($listing_id)) {
$comments = SJB_CommentManager::getCommentsToListing($listing_id);
$listingInfo = SJB_ListingManager::getListingInfoBySID($listing_id);
$listingTypeInfo = SJB_ListingTypeManager::getListingTypeInfoBySID($listingInfo['listing_type_sid']);
$tp->assign('comments', $comments);
$tp->assign('comments_num', count($comments));
$tp->assign('listing_id', $listing_id);
$tp->assign('listingType', SJB_ListingTypeManager::createTemplateStructure($listingTypeInfo));
$tp->display('listing_comments.tpl');
}
}
示例12: getUserSessionBySessionId
public static function getUserSessionBySessionId($sessionId)
{
$userSession = SJB_DB::query('SELECT * FROM `session` WHERE `session_id` = ?s', $sessionId);
if ($userSession) {
return array_pop($userSession);
}
return null;
}
示例13: getEmailTemplateInfoBySID
/**
* retrieve email template info by sid
* @static
* @param int $sid
* @return bool|mixed
*/
public static function getEmailTemplateInfoBySID($sid)
{
$result = SJB_DB::query('SELECT * FROM `email_templates` WHERE `sid` = ?n', $sid);
if (!empty($result)) {
return array_pop($result);
}
return false;
}
示例14: execute
public function execute()
{
$id = SJB_Request::getVar('id', false);
if ($id) {
SJB_DB::query("DELETE FROM `parsers` WHERE id = ?n", $id);
}
SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . "/show-import/");
}
示例15: getAdminDetailsByUsername
public static function getAdminDetailsByUsername($username)
{
if (!empty($username)) {
return SJB_DB::query("SELECT * FROM `administrator` WHERE `username` = ?s", $username);
} else {
return false;
}
}