Пример #1
0
 /**
  * Bind the given SearchParameter values to the given SELECT-statement. 
  * @param SearchParameters $SearchParameters
  * @param mysqli_stmt $stmt 
  */
 public static function BindParamsToSelect(&$SearchParameters, &$stmt)
 {
     if ($SearchParameters->getValues()) {
         $bind_names[] = $SearchParameters->getParamTypes();
         $params = $SearchParameters->getValues();
         for ($i = 0; $i < count($params); $i++) {
             $bind_name = 'bind' . $i;
             ${$bind_name} = $params[$i];
             $bind_names[] =& ${$bind_name};
         }
         call_user_func_array(array($stmt, 'bind_param'), $bind_names);
     }
 }
 public function getMemberAdvertisements($memberID, $currentPage, $pagingAmount, $dbConnection)
 {
     $advertisementSearchResults = null;
     $advertisementSkeletons = null;
     try {
         //Construct Search Parameter object
         $advertisementSearchParameters = new SearchParameters();
         $advertisementSearchParameters->setVariable(SearchConstants::CURRENT_PAGE_ID, $currentPage);
         $advertisementSearchParameters->setVariable(SearchConstants::PAGING_AMOUNT_ID, $pagingAmount);
         $advertisementSearchParameters->setVariable(AdvertisementSearchConstants::MEMBER_INPUT_ID, $memberID);
         $advertisementCount = AdvertisementSearchDao::getSearchAdvertisementsCount($advertisementSearchParameters, $dbConnection);
         $advertisementSkeletons = AdvertisementSearchDao::searchAdvertisements($advertisementSearchParameters, $dbConnection);
         $advertisementSearchResults = new SearchResults();
         $advertisementSearchResults->setVariable(SearchResults::SEARCH_PARAMETERS, $advertisementSearchParameters);
         $advertisementSearchResults->setVariable(SearchResults::SKELETONS, $advertisementSkeletons);
         $advertisementSearchResults->setVariable(SearchResults::COUNT, $advertisementCount);
         $advertisementSearchResults->setVariable(SearchResults::PAGE_COUNT, ceil($advertisementCount / $pagingAmount));
     } catch (Exception $ex) {
         $advertisementSearchResults = null;
         echo 'Caught exception: ' . $ex->getMessage();
     }
     return $advertisementSearchResults;
 }
Пример #3
0
 /**
  * @param int $SingleID
  * @param array(int) $MultipleIDs
  * @param int $SingleSetID
  * @param array(int) $MultipleSetIDs
  * @param int $SingleModelID
  * @param array(int) $MultipleModelIDs
  * @param bool $OrAllMultipleIDs
  */
 public function __construct($SingleID = FALSE, $MultipleIDs = FALSE, $SingleSetID = FALSE, $MultipleSetIDs = FALSE, $SingleModelID = FALSE, $MultipleModelIDs = FALSE, $OrAllMultipleIDs = FALSE)
 {
     parent::__construct();
     if ($SingleID !== FALSE) {
         $this->paramtypes .= "i";
         $this->values[] = $SingleID;
         $this->where .= " AND video_id = ?";
     }
     if (is_array($MultipleIDs) && count($MultipleIDs) > 0 && !$OrAllMultipleIDs) {
         $this->paramtypes .= str_repeat('i', count($MultipleIDs));
         $this->values = array_merge($this->values, $MultipleIDs);
         $this->where .= sprintf(" AND video_id IN ( %1s ) ", implode(', ', array_fill(0, count($MultipleIDs), '?')));
     }
     if ($SingleSetID !== FALSE) {
         $this->paramtypes .= "i";
         $this->values[] = $SingleSetID;
         $this->where .= " AND set_id = ?";
     }
     if (is_array($MultipleSetIDs) && count($MultipleSetIDs) > 0 && !$OrAllMultipleIDs) {
         $this->paramtypes .= str_repeat('i', count($MultipleSetIDs));
         $this->values = array_merge($this->values, $MultipleSetIDs);
         $this->where .= sprintf(" AND set_id IN ( %1s ) ", implode(', ', array_fill(0, count($MultipleSetIDs), '?')));
     }
     if ($SingleModelID !== FALSE) {
         $this->paramtypes .= "i";
         $this->values[] = $SingleModelID;
         $this->where .= " AND model_id = ?";
     }
     if (is_array($MultipleModelIDs) && count($MultipleModelIDs) > 0 && !$OrAllMultipleIDs) {
         $this->paramtypes .= str_repeat('i', count($MultipleModelIDs));
         $this->values = array_merge($this->values, $MultipleModelIDs);
         $this->where .= sprintf(" AND model_id IN ( %1s ) ", implode(', ', array_fill(0, count($MultipleModelIDs), '?')));
     }
     if ($OrAllMultipleIDs) {
         $pieces = array();
         if (is_array($MultipleIDs) && count($MultipleIDs) > 0) {
             $this->paramtypes .= str_repeat('i', count($MultipleIDs));
             $this->values = array_merge($this->values, $MultipleIDs);
             $pieces[] = sprintf("video_id IN ( %1s )", implode(', ', array_fill(0, count($MultipleIDs), '?')));
         }
         if (is_array($MultipleSetIDs) && count($MultipleSetIDs) > 0) {
             $this->paramtypes .= str_repeat('i', count($MultipleSetIDs));
             $this->values = array_merge($this->values, $MultipleSetIDs);
             $pieces[] = sprintf("set_id IN ( %1s )", implode(', ', array_fill(0, count($MultipleSetIDs), '?')));
         }
         if (is_array($MultipleModelIDs) && count($MultipleModelIDs) > 0) {
             $this->paramtypes .= str_repeat('i', count($MultipleModelIDs));
             $this->values = array_merge($this->values, $MultipleModelIDs);
             $pieces[] = sprintf("model_id IN ( %1s )", implode(', ', array_fill(0, count($MultipleModelIDs), '?')));
         }
         if ($pieces) {
             $this->where .= " AND (";
             $this->where .= implode(' OR ', $pieces);
             $this->where .= ")";
         }
     }
 }
Пример #4
0
 /**
  * @param string $SingleID
  * @param array(string) $MultipleIDs
  * @param int $SingleIndexID
  * @param array(int) $MultipleIndexIDs
  * @param int $SingleModelID
  * @param array(int) $MultipleModelIDs
  * @param int $SingleSetID
  * @param array(int) $MultipleSetIDs
  * @param int $SingleImageID
  * @param array(int) $MultipleImageIDs
  * @param int $SingleVideoID
  * @param array(int) $MultipleVideoIDs
  * @param int $CacheImageWidth
  * @param int $CacheImageHeight
  * @param int $IndexSequenceNumber
  * @param int $IndexSequenceTotal
  */
 public function __construct($SingleID = FALSE, $MultipleIDs = FALSE, $SingleIndexID = FALSE, $MultipleIndexIDs = FALSE, $SingleModelID = FALSE, $MultipleModelIDs = FALSE, $SingleSetID = FALSE, $MultipleSetIDs = FALSE, $SingleImageID = FALSE, $MultipleImageIDs = FALSE, $SingleVideoID = FALSE, $MultipleVideoIDs = FALSE, $CacheImageWidth = FALSE, $CacheImageHeight = FALSE, $IndexSequenceNumber = FALSE, $IndexSequenceTotal = FALSE)
 {
     parent::__construct();
     if ($SingleID !== FALSE) {
         $this->paramtypes .= "s";
         $this->values[] = $SingleID;
         $this->where .= " AND cache_id = ?";
     }
     if (is_array($MultipleIDs) && count($MultipleIDs) > 0) {
         $this->paramtypes .= str_repeat('s', count($MultipleIDs));
         $this->values = array_merge($this->values, $MultipleIDs);
         $this->where .= sprintf(" AND cache_id IN ( %1s ) ", implode(', ', array_fill(0, count($MultipleIDs), '?')));
     }
     if ($SingleIndexID !== FALSE) {
         $this->paramtypes .= "i";
         $this->values[] = $SingleIndexID;
         $this->where .= " AND index_id = ?";
     }
     if (is_array($MultipleIndexIDs) && count($MultipleIndexIDs) > 0) {
         $this->paramtypes .= str_repeat('i', count($MultipleIndexIDs));
         $this->values = array_merge($this->values, $MultipleIndexIDs);
         $this->where .= sprintf(" AND index_id IN ( %1s ) ", implode(', ', array_fill(0, count($MultipleIndexIDs), '?')));
     }
     if ($SingleModelID !== FALSE) {
         $this->paramtypes .= "i";
         $this->values[] = $SingleModelID;
         $this->where .= " AND model_id = ?";
     }
     if (is_array($MultipleModelIDs) && count($MultipleModelIDs) > 0) {
         $this->paramtypes .= str_repeat('i', count($MultipleModelIDs));
         $this->values = array_merge($this->values, $MultipleModelIDs);
         $this->where .= sprintf(" AND model_id IN ( %1s ) ", implode(', ', array_fill(0, count($MultipleModelIDs), '?')));
     }
     if ($SingleSetID !== FALSE) {
         $this->paramtypes .= "i";
         $this->values[] = $SingleSetID;
         $this->where .= " AND set_id = ?";
     }
     if (is_array($MultipleSetIDs) && count($MultipleSetIDs) > 0) {
         $this->paramtypes .= str_repeat('i', count($MultipleSetIDs));
         $this->values = array_merge($this->values, $MultipleSetIDs);
         $this->where .= sprintf(" AND set_id IN ( %1s ) ", implode(', ', array_fill(0, count($MultipleSetIDs), '?')));
     }
     if ($SingleImageID !== FALSE) {
         $this->paramtypes .= "i";
         $this->values[] = $SingleImageID;
         $this->where .= " AND image_id = ?";
     }
     if (is_array($MultipleImageIDs) && count($MultipleImageIDs) > 0) {
         $this->paramtypes .= str_repeat('i', count($MultipleImageIDs));
         $this->values = array_merge($this->values, $MultipleImageIDs);
         $this->where .= sprintf(" AND image_id IN ( %1s ) ", implode(', ', array_fill(0, count($MultipleImageIDs), '?')));
     }
     if ($SingleVideoID !== FALSE) {
         $this->paramtypes .= "i";
         $this->values[] = $SingleVideoID;
         $this->where .= " AND video_id = ?";
     }
     if (is_array($MultipleVideoIDs) && count($MultipleVideoIDs) > 0) {
         $this->paramtypes .= str_repeat('i', count($MultipleVideoIDs));
         $this->values = array_merge($this->values, $MultipleVideoIDs);
         $this->where .= sprintf(" AND video_id IN ( %1s ) ", implode(', ', array_fill(0, count($MultipleVideoIDs), '?')));
     }
     if ($CacheImageWidth !== FALSE) {
         $this->paramtypes .= "i";
         $this->values[] = $CacheImageWidth;
         $this->where .= " AND cache_imagewidth = ?";
     }
     if ($CacheImageHeight !== FALSE) {
         $this->paramtypes .= "i";
         $this->values[] = $CacheImageHeight;
         $this->where .= " AND cache_imageheight = ?";
     }
     if ($IndexSequenceNumber !== FALSE) {
         $this->paramtypes .= "i";
         $this->values[] = $IndexSequenceNumber;
         $this->where .= " AND index_sequence_number = ?";
     }
     if ($IndexSequenceTotal !== FALSE) {
         $this->paramtypes .= "i";
         $this->values[] = $IndexSequenceTotal;
         $this->where .= " AND index_sequence_total = ?";
     }
 }
 public function searchForBandMembersAdvanced($bandID, $firstName, $lastName, $gender, $ageRange, $country, $state, $city, $region, $searchType, $currentPage, $pagingAmount, $dbConnection = null)
 {
     $memberSearchResults = null;
     $memberSkeletons = null;
     $countryID = null;
     $stateID = null;
     $cityID = null;
     $regionID = null;
     try {
         $memberSearchParameters = new SearchParameters();
         $memberSearchParameters->setVariable(SearchConstants::SEARCH_TYPE_INPUT_ID, $searchType);
         $memberSearchParameters->setVariable(SearchConstants::CURRENT_PAGE_ID, $currentPage);
         $memberSearchParameters->setVariable(SearchConstants::PAGING_AMOUNT_ID, $pagingAmount);
         $memberSearchParameters->setVariable(MemberSearchConstants::BAND_INPUT_ID, $bandID);
         //These elements are common to both search types
         $countryID = SearchUtilities::processSelectValues($country, 'defaultValue', '0');
         if ($countryID != null) {
             $stateID = SearchUtilities::processSelectValues($state, 'defaultValue', '0');
         }
         if ($stateID != null) {
             $cityID = SearchUtilities::processSelectValues($city, 'defaultValue', '0');
         }
         if ($cityID != null) {
             $regionID = SearchUtilities::processSelectValues($region, 'defaultValue', '0');
         }
         $memberSearchParameters->setVariable(LocationConstants::LOCATION_COUNTRY_INPUT_ID, $countryID);
         $memberSearchParameters->setVariable(LocationConstants::LOCATION_STATE_INPUT_ID, $stateID);
         $memberSearchParameters->setVariable(LocationConstants::LOCATION_CITY_INPUT_ID, $cityID);
         $memberSearchParameters->setVariable(LocationConstants::LOCATION_REGION_INPUT_ID, $regionID);
         $memberSearchParameters->setVariable(MemberSearchConstants::FIRST_NAME_INPUT_ID, $firstName);
         $memberSearchParameters->setVariable(MemberSearchConstants::LAST_NAME_INPUT_ID, $lastName);
         $memberSearchParameters->setVariable(MemberSearchConstants::GENDER_INPUT_ID, $gender);
         $memberSearchParameters->setVariable(MemberSearchConstants::AGE_INPUT_ID, $lastName);
         $memberCount = MemberSearchDao::getMemberSearchCount($memberSearchParameters, $dbConnection);
         $memberSkeletons = MemberSearchDao::searchMembers($memberSearchParameters, $ageRange);
         $memberSearchResults = new SearchResults();
         $memberSearchResults->setVariable(SearchResults::SEARCH_PARAMETERS, $memberSearchParameters);
         $memberSearchResults->setVariable(SearchResults::SKELETONS, $memberSkeletons);
         $memberSearchResults->setVariable(SearchResults::COUNT, $memberCount);
         $memberSearchResults->setVariable(SearchResults::PAGE_COUNT, ceil($memberCount / $pagingAmount));
     } catch (Exception $e) {
         $memberSearchResults = null;
         echo 'Caught exception: ', $e->getMessage(), "\n";
     }
     return $memberSearchResults;
 }
 public function browseAdvertisementByLocation($country, $state, $city, $region, $searchType, $currentPage, $pagingAmount, $dbConnection = null)
 {
     $advertisementSearchResults = null;
     $advertisementSkeletons = null;
     $countryID = null;
     $stateID = null;
     $cityID = null;
     $regionID = null;
     try {
         //Construct Search Parameter object
         $advertisementSearchParameters = new SearchParameters();
         $advertisementSearchParameters->setVariable(SearchConstants::CURRENT_PAGE_ID, $currentPage);
         $advertisementSearchParameters->setVariable(SearchConstants::PAGING_AMOUNT_ID, $pagingAmount);
         //These elements are common to both search types
         $countryID = SearchUtilities::processSelectValues($country, 'defaultValue', '0');
         if ($countryID != null) {
             $stateID = SearchUtilities::processSelectValues($state, 'defaultValue', '0');
         }
         if ($stateID != null) {
             $cityID = SearchUtilities::processSelectValues($city, 'defaultValue', '0');
         }
         if ($cityID != null) {
             $regionID = SearchUtilities::processSelectValues($region, 'defaultValue', '0');
         }
         $advertisementSearchParameters->setVariable(LocationConstants::LOCATION_COUNTRY_INPUT_ID, $countryID);
         $advertisementSearchParameters->setVariable(LocationConstants::LOCATION_STATE_INPUT_ID, $stateID);
         $advertisementSearchParameters->setVariable(LocationConstants::LOCATION_CITY_INPUT_ID, $cityID);
         $advertisementSearchParameters->setVariable(LocationConstants::LOCATION_REGION_INPUT_ID, $regionID);
         $advertisementCount = AdvertisementSearchDao::getSearchAdvertisementsCount($advertisementSearchParameters, $dbConnection);
         $advertisementSkeletons = AdvertisementSearchDao::searchAdvertisements($advertisementSearchParameters, $dbConnection);
         $advertisementSearchResults = new SearchResults();
         $advertisementSearchResults->setVariable(SearchResults::SEARCH_PARAMETERS, $advertisementSearchParameters);
         $advertisementSearchResults->setVariable(SearchResults::SKELETONS, $advertisementSkeletons);
         $advertisementSearchResults->setVariable(SearchResults::COUNT, $advertisementCount);
         $advertisementSearchResults->setVariable(SearchResults::PAGE_COUNT, ceil($advertisementCount / $pagingAmount));
     } catch (Exception $e) {
         $advertisementSearchResults = null;
         echo 'Caught exception: ', $e->getMessage(), "\n";
     }
     return $advertisementSearchResults;
 }
Пример #7
0
 /**
  * @param int $SingleTagID
  * @param array(int) $MultipleTagIDs
  * @param string $TagName
  * @param int $SingleModelID
  * @param array(int) $MultipleModelIDs
  * @param int $SingleSetID
  * @param array(int) $MultipleSetIDs
  * @param int $SingleImageID
  * @param array(int) $MultipleImageIDs
  * @param int $SingleVideoID
  * @param array(int) $MultipleVideoIDs
  * @param bool $ModelIdIsNull
  * @param bool $SetIdIsNull
  * @param bool $ImageIdIsNull
  * @param bool $VideoIdIsNull
  */
 public function __construct($SingleTagID = FALSE, $MultipleTagIDs = FALSE, $TagName = FALSE, $SingleModelID = FALSE, $MultipleModelIDs = FALSE, $SingleSetID = FALSE, $MultipleSetIDs = FALSE, $SingleImageID = FALSE, $MultipleImageIDs = FALSE, $SingleVideoID = FALSE, $MultipleVideoIDs = FALSE, $ModelIdIsNull = FALSE, $SetIdIsNull = FALSE, $ImageIdIsNull = FALSE, $VideoIdIsNull = FALSE)
 {
     parent::__construct();
     if ($SingleTagID !== FALSE) {
         $this->paramtypes .= "i";
         $this->values[] = $SingleTagID;
         $this->where .= " AND tag_id = ?";
     }
     if (is_array($MultipleTagIDs) && count($MultipleTagIDs) > 0) {
         $this->paramtypes .= str_repeat('i', count($MultipleTagIDs));
         $this->values = array_merge($this->values, $MultipleTagIDs);
         $this->where .= sprintf(" AND tag_id IN ( %1s ) ", implode(', ', array_fill(0, count($MultipleTagIDs), '?')));
     }
     if ($TagName !== FALSE) {
         $this->paramtypes .= 's';
         $this->values[] = '%' . $TagName . '%';
         $this->where .= " AND tag_name LIKE ?";
     }
     if ($SingleModelID !== FALSE) {
         $this->paramtypes .= "i";
         $this->values[] = $SingleModelID;
         $this->where .= " AND model_id = ?";
     }
     if (is_array($MultipleModelIDs) && count($MultipleModelIDs) > 0) {
         $this->paramtypes .= str_repeat('i', count($MultipleModelIDs));
         $this->values = array_merge($this->values, $MultipleModelIDs);
         $this->where .= sprintf(" AND model_id IN ( %1s ) ", implode(', ', array_fill(0, count($MultipleModelIDs), '?')));
     }
     if ($SingleSetID !== FALSE) {
         $this->paramtypes .= "i";
         $this->values[] = $SingleSetID;
         $this->where .= " AND set_id = ?";
     }
     if (is_array($MultipleSetIDs) && count($MultipleSetIDs) > 0) {
         $this->paramtypes .= str_repeat('i', count($MultipleSetIDs));
         $this->values = array_merge($this->values, $MultipleSetIDs);
         $this->where .= sprintf(" AND set_id IN ( %1s ) ", implode(', ', array_fill(0, count($MultipleSetIDs), '?')));
     }
     if ($SingleImageID !== FALSE) {
         $this->paramtypes .= "i";
         $this->values[] = $SingleImageID;
         $this->where .= " AND image_id = ?";
     }
     if (is_array($MultipleImageIDs) && count($MultipleImageIDs) > 0) {
         $this->paramtypes .= str_repeat('i', count($MultipleImageIDs));
         $this->values = array_merge($this->values, $MultipleImageIDs);
         $this->where .= sprintf(" AND image_id IN ( %1s ) ", implode(', ', array_fill(0, count($MultipleImageIDs), '?')));
     }
     if ($SingleVideoID !== FALSE) {
         $this->paramtypes .= "i";
         $this->values[] = $SingleVideoID;
         $this->where .= " AND video_id = ?";
     }
     if (is_array($MultipleVideoIDs) && count($MultipleVideoIDs) > 0) {
         $this->paramtypes .= str_repeat('i', count($MultipleVideoIDs));
         $this->values = array_merge($this->values, $MultipleVideoIDs);
         $this->where .= sprintf(" AND video_id IN ( %1s ) ", implode(', ', array_fill(0, count($MultipleVideoIDs), '?')));
     }
     if ($ModelIdIsNull) {
         $this->where .= " AND model_id IS NULL";
     }
     if ($SetIdIsNull) {
         $this->where .= " AND set_id IS NULL";
     }
     if ($ImageIdIsNull) {
         $this->where .= " AND image_id IS NULL";
     }
     if ($VideoIdIsNull) {
         $this->where .= " AND video_id IS NULL";
     }
 }
Пример #8
0
 /**
  * @param int $SingleID
  * @param array(int) $MultipleIDs
  * @param string $FirstName
  * @param string $LastName
  * @param string $FullName
  */
 public function __construct($SingleID = FALSE, $MultipleIDs = FALSE, $FirstName = FALSE, $LastName = FALSE, $FullName = FALSE)
 {
     parent::__construct();
     if ($SingleID !== FALSE) {
         $this->paramtypes .= "i";
         $this->values[] = $SingleID;
         $this->where .= " AND model_id = ?";
     }
     if (is_array($MultipleIDs) && count($MultipleIDs) > 0) {
         $this->paramtypes .= str_repeat('i', count($MultipleIDs));
         $this->values = array_merge($this->values, $MultipleIDs);
         $this->where .= sprintf(" AND model_id IN ( %1s ) ", implode(', ', array_fill(0, count($MultipleIDs), '?')));
     }
     if ($FirstName !== FALSE) {
         $this->paramtypes .= 's';
         $this->values[] = '%' . $FirstName . '%';
         $this->where .= " AND model_firstname LIKE ?";
     }
     if ($LastName !== FALSE) {
         $this->paramtypes .= 's';
         $this->values[] = '%' . $LastName . '%';
         $this->where .= " AND model_lastname LIKE ?";
     }
     if ($FullName !== FALSE) {
         $this->paramtypes .= 's';
         $this->values[] = '%' . $FullName . '%';
         $this->where .= " AND CONCAT_WS(' ', model_firstname, model_lastname) LIKE ?";
     }
 }
Пример #9
0
 public function __construct($SingleID = FALSE, $MultipleIDs = FALSE, $UserName = FALSE, $Password = FALSE, $Email = FALSE)
 {
     parent::__construct();
     if ($SingleID !== FALSE) {
         $this->paramtypes .= "i";
         $this->values[] = $SingleID;
         $this->where .= " AND user_id = ?";
     }
     if (is_array($MultipleIDs) && count($MultipleIDs) > 0) {
         $this->paramtypes .= str_repeat('i', count($MultipleIDs));
         $this->values = array_merge($this->values, $MultipleIDs);
         $this->where .= sprintf(" AND user_id IN ( %1s ) ", implode(', ', array_fill(0, count($MultipleIDs), '?')));
     }
     if ($UserName !== FALSE) {
         $this->paramtypes .= 's';
         $this->values[] = $UserName;
         $this->where .= " AND user_username = ?";
     }
     if ($Password !== FALSE) {
         $this->paramtypes .= 's';
         $this->values[] = $Password;
         $this->where .= " AND user_password = ?";
     }
     if ($Email !== FALSE) {
         $this->paramtypes .= 's';
         $this->values[] = $Email;
         $this->where .= " AND user_email = ?";
     }
 }