本文整理汇总了PHP中SplFixedArray::next方法的典型用法代码示例。如果您正苦于以下问题:PHP SplFixedArray::next方法的具体用法?PHP SplFixedArray::next怎么用?PHP SplFixedArray::next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplFixedArray
的用法示例。
在下文中一共展示了SplFixedArray::next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getControllerFromUrlObject
/**
* Get controller from $mProjectUrl by request
* @access public
* @static
* @param string $pPathInfo
* @return array
*/
public static function getControllerFromUrlObject($pPathInfo = '')
{
$controller_params = array();
$pPathInfo = $pPathInfo ?: self::$mPathInfo;
self::$mPojrectUrl->rewind();
while (self::$mPojrectUrl->valid()) {
list($pattern, $controller) = self::$mPojrectUrl->current();
$pattern = '/' . str_replace('/', '\\/', $pattern) . '/';
preg_match_all($pattern, $pPathInfo, $matched);
if ($matched[0][0] == $pPathInfo) {
$controller_params['c'] = $controller;
$controller_params['p'] = self::getParamsFromRequest($matched);
break;
}
self::$mPojrectUrl->next();
}
return $controller_params;
}
示例2: getFavoriteByTweetId
/**
* gets the Favorite by tweet it id
*
* @param \PDO $pdo PDO connection object
* @param int $tweetId tweet id to search for
* @return \SplFixedArray array of Favorites found or null if not found
* @throws \PDOException when mySQL related errors occur
* @throws \TypeError when variables are not the correct data type
**/
public static function getFavoriteByTweetId(\PDO $pdo, int $tweetId)
{
// sanitize the tweet id
$tweetId = filter_var($tweetId, FILTER_VALIDATE_INT);
if ($tweetId <= 0) {
throw new \PDOException("tweet id is not positive");
}
// create query template
$query = "SELECT profileId, tweetId, favoriteDate FROM favorite WHERE tweetId = :tweetId";
$statement = $pdo->prepare($query);
// bind the member variables to the place holders in the template
$parameters = ["tweetId" => $tweetId];
$statement->execute($parameters);
// build an array of favorites
$favorites = new \SplFixedArray($statement->rowCount());
$statement->setFetchMode(\PDO::FETCH_ASSOC);
while (($row = $statement->fetch()) !== false) {
try {
$favorite = new Favorite($row["tweetId"], $row["profileId"], $row["favoriteDate"]);
$favorites[$favorites->key()] = $favorite;
$favorites->next();
} catch (\Exception $exception) {
// if the row couldn't be converted, rethrow it
throw new \PDOException($exception->getMessage(), 0, $exception);
}
}
return $favorites;
}
示例3: getFavoritePlayersByFavoritePlayerProfileId
/**
* get a favorite player by profile id
*
* @param \PDO $pdo PDO connection object
* @param int $profileId
* @return \SplFixedArray SplFixedArray of Favorite Players found or null if not found
* @throws \PDOException when mySQL related errors occur
* @throws \TypeError when variables are not the correct data type
**/
public static function getFavoritePlayersByFavoritePlayerProfileId(\PDO $pdo, int $favoritePlayerProfileId)
{
if ($favoritePlayerProfileId <= 0) {
throw new \PDOException("this profile doesn't exist");
}
// create query template
$query = "SELECT favoritePlayerProfileId, favoritePlayerPlayerId FROM favoritePlayer WHERE favoritePlayerProfileId = :favoritePlayerProfileId";
$statement = $pdo->prepare($query);
$parameters = ["favoritePlayerProfileId" => $favoritePlayerProfileId];
$statement->execute($parameters);
// build an array of favorite players
$favoritePlayers = new \SplFixedArray($statement->rowCount());
$statement->setFetchMode(\PDO::FETCH_ASSOC);
while (($row = $statement->fetch()) !== false) {
try {
$favoritePlayer = new FavoritePlayer($row["favoritePlayerProfileId"], $row["favoritePlayerPlayerId"]);
$favoritePlayers[$favoritePlayers->key()] = $favoritePlayer;
$favoritePlayers->next();
} catch (\Exception $exception) {
// if the row couldn't be converted, rethrow it
throw new \PDOException($exception->getMessage(), 0, $exception);
}
}
return $favoritePlayers;
}
示例4: getProductAlertByProductId
/**
* getProductAlertByProductId
*
* @param PDO $pdo pointer to PDO connection, by reference
* @param int $productId
* @return mixed ProductAlert
* @throws PDOException if productId is not an integer
* @throws PDOException if productId is not positive
**/
public static function getProductAlertByProductId(PDO &$pdo, $productId)
{
// sanitize the productId before searching
$productId = filter_var($productId, FILTER_VALIDATE_INT);
if ($productId === false) {
throw new PDOException("productId is not an integer");
}
if ($productId <= 0) {
throw new PDOException("productId is not positive");
}
//create query template
$query = "SELECT alertId, productId, alertEnabled FROM productAlert WHERE productId = :productId";
$statement = $pdo->prepare($query);
//bind the productId to the place holder in the template
$parameters = array("productId" => $productId);
$statement->execute($parameters);
// build an array of ProductAlert(s)
$productAlerts = new SplFixedArray($statement->rowCount());
$statement->setFetchMode(PDO::FETCH_ASSOC);
while (($row = $statement->fetch()) !== false) {
try {
$productAlert = new ProductAlert($row["alertId"], $row["productId"], $row["alertEnabled"]);
$productAlerts[$productAlerts->key()] = $productAlert;
$productAlerts->next();
} catch (PDOException $exception) {
// if the row couldn't be converted, rethrow it
throw new PDOException($exception->getMessage(), 0, $exception);
}
}
return $productAlerts;
}
示例5: getAllPlayersByTeamId
/**
* gets all Players by teamId
*
* @param \PDO $pdo PDO connection object
* @return \SplFixedArray SplFixedArray of players found or null if not found
* @throws \PDOException when mySQL related errors occur
* @throws \TypeError when variables are not the correct data type
**/
public static function getAllPlayersByTeamId(\PDO $pdo, int $playerTeamId)
{
$query = "SELECT playerId, playerApiId, playerTeamId, playerSportId, playerName FROM player WHERE playerTeamId = :playerTeamId";
$statement = $pdo->prepare($query);
$parameters = ["playerTeamId" => $playerTeamId];
$statement->execute($parameters);
// build an array of Players
$players = new \SplFixedArray($statement->rowCount());
$statement->setFetchMode(\PDO::FETCH_ASSOC);
while (($row = $statement->fetch()) !== false) {
try {
$player = new Player($row["playerId"], $row["playerApiId"], $row["playerTeamId"], $row["playerSportId"], $row["playerName"]);
$players[$players->key()] = $player;
$players->next();
} catch (\Exception $exception) {
// if the row couldn't be converted, rethrow it
throw new \PDOException($exception->getMessage(), 0, $exception);
}
}
return $players;
}
示例6: getAllProfiles
/**
* Gets all profiles
*
* @param PDO $pdo pointer to PDO connection, by reference
* @return SplFixedArray of Profiles found
* @throws PDOException when MySQL related errors occur
*/
public static function getAllProfiles(PDO &$pdo)
{
// Create query template
$query = "SELECT profileId, username, passwordHash FROM profile";
$statement = $pdo->prepare($query);
$statement->execute();
// Build an array of profiles
$profiles = new SplFixedArray($statement->rowCount());
$statement->setFetchMode(PDO::FETCH_ASSOC);
while (($row = $statement->fetch()) !== false) {
try {
$profile = new Profile($row["profileId"], $row["username"], $row["passwordHash"]);
$profiles[$profiles->key()] = $profile;
$profiles->next();
} catch (Exception $e) {
// If the row couldn't be converted, rethrow it
throw new PDOException($e->getMessage(), 0, $e);
}
}
return $profiles;
}
示例7: getSportBySportName
/**
* gets the sport by the sport name
*
* @param \PDO $pdo connection object
* @param string $sportName sport Name to search for
* @return \SplFixedArray SplFixedArray of names found
* @throws \PDOException when db related errors occur
* @throws \TypeError when variables are not correct data type
**/
public static function getSportBySportName(\PDO $pdo, string $sportName)
{
// sanitize the description before searching
$sportName = trim($sportName);
$sportName = filter_var($sportName, FILTER_SANITIZE_STRING);
if (empty($sportName) === true) {
throw new \PDOException("That name is invalid");
}
// create query template
$query = "SELECT sportId, sportName, sportLeague FROM sport WHERE sportName LIKE :sportName";
$statement = $pdo->prepare($query);
// bind the sport name to the place holder in the template
$sportName = "%{$sportName}%";
$parameters = array("sportName" => $sportName);
$statement->execute($parameters);
//build array of sport names
$sportNames = new \SplFixedArray($statement->rowCount());
$statement->setFetchMode(\PDO::FETCH_ASSOC);
while (($row = $statement->fetch()) !== false) {
try {
$sport = new sport($row["sportId"], $row["sportLeague"], $row["sportName"]);
$sportNames[$sportNames->key()] = $sport;
$sportNames->next();
} catch (\Exception $exception) {
//if the row couldn't be converted, rethrow it
throw new \PDOException($exception->getMessage(), 0, $exception);
}
return $sportNames;
}
}
示例8: getAllPosts
public static function getAllPosts(\PDO $pdo)
{
// Create query template and execute
$query = "SELECT postId, postProfileUserName, postSubmission, postTime FROM post";
$statement = $pdo->prepare($query);
$statement->execute();
// Build an array of matches
$posts = new \SplFixedArray($statement->rowCount());
$statement->setFetchMode(\PDO::FETCH_ASSOC);
while (($row = $statement->fetch()) !== false) {
try {
$post = new Post($row["postId"], $row["postProfileUserName"], $row["postSubmission"], \DateTime::createFromFormat("Y-m-d H:i:s", $row["postTime"]));
$posts[$posts->key()] = $post;
$posts->next();
} catch (\Exception $exception) {
throw new \PDOException($exception->getMessage(), 0, $exception);
}
}
return $posts;
}
示例9: getAllTweets
/**
* gets all Tweets
*
* @param PDO $pdo pointer to PDO connection, by reference
* @return mixed SplFixedArray of Tweets found or null if not found
* @throws PDOException when mySQL related errors occur
**/
public static function getAllTweets(PDO &$pdo)
{
// create query template
$query = "SELECT tweetId, profileId, tweetContent, tweetDate FROM tweet";
$statement = $pdo->prepare($query);
$statement->execute();
// build an array of tweets
$tweets = new SplFixedArray($statement->rowCount());
$statement->setFetchMode(PDO::FETCH_ASSOC);
while (($row = $statement->fetch()) !== false) {
try {
$tweet = new Tweet($row["tweetId"], $row["profileId"], $row["tweetContent"], $row["tweetDate"]);
$tweets[$tweets->key()] = $tweet;
$tweets->next();
} catch (Exception $exception) {
// if the row couldn't be converted, rethrow it
throw new PDOException($exception->getMessage(), 0, $exception);
}
}
// count the results in the array and return:
// 1) null if 0 results
// 2) the entire array if >= 1 result
$numberOfTweets = count($tweets);
if ($numberOfTweets === 0) {
return null;
} else {
return $tweets;
}
}
示例10: getAllGame
/**
* gets all Game
*
* @param \PDO $pdo PDO connection object
* @return \SplFixedArray SplFixedArray of Game found or null if not found
* @throws \PDOException when mySQL related errors occur
* @throws \TypeError when variables are not the correct data type
**/
public static function getAllGame(\PDO $pdo)
{
//create query template
$query = "SELECT gameId, gameFirstTeamId, gameSecondTeamId, gameTime FROM game ";
$statement = $pdo->prepare($query);
$statement->execute();
//build an array of game
$games = new \SplFixedArray($statement->rowCount());
$statement->setFetchMode(\PDO::FETCH_ASSOC);
while (($row = $statement->fetch()) !== false) {
try {
$game = new Game($row["gameId"], $row["gameFirstTeamId"], $row["gameSecondTeamId"], $row["gameTime"]);
$games[$games->key()] = $game;
$games->next();
} catch (\Exception $exception) {
// if the row couldn't be converted rethrow it
throw new \PDOException($exception->getMessage(), 0, $exception);
}
}
return $games;
}
示例11: getAllProductLocations
/**
* gets all ProductLocations
*
* @param PDO $pdo pointer to PDO connection, by reference
* @return SplFixedArray all productLocations found
* @throws PDOException when mySQL related errors occur
**/
public static function getAllProductLocations(PDO &$pdo)
{
// create query template
$query = "SELECT locationId, productId, unitId, quantity FROM productLocation";
$statement = $pdo->prepare($query);
$statement->execute();
// build an array of ProductLocation(s)
$productLocations = new SplFixedArray($statement->rowCount());
$statement->setFetchMode(PDO::FETCH_ASSOC);
while (($row = $statement->fetch()) !== false) {
try {
$productLocation = new ProductLocation($row["locationId"], $row["productId"], $row["unitId"], $row["quantity"]);
$productLocations[$productLocations->key()] = $productLocation;
$productLocations->next();
} catch (PDOException $exception) {
// if the row couldn't be converted, rethrow it
throw new PDOException($exception->getMessage(), 0, $exception);
}
}
return $productLocations;
}
示例12: getAllProfiles
public static function getAllProfiles(\PDO $pdo)
{
// Create query template and execute
$query = "SELECT profileId, profileAdmin, profileNameFirst, profileNameLast, profileEmail, profileUserName, profileSalt, profileHash, profileActivationToken FROM profile";
$statement = $pdo->prepare($query);
$statement->execute();
// Build an array of matches
$profiles = new \SplFixedArray($statement->rowCount());
$statement->setFetchMode(\PDO::FETCH_ASSOC);
while (($row = $statement->fetch()) !== false) {
try {
$profile = new Profile($row["profileId"], $row["profileAdmin"], $row["profileNameFirst"], $row["profileNameLast"], $row["profileEmail"], $row["profileUserName"], $row["profileSalt"], $row["profileHash"], $row["profileActivationToken"]);
$profiles[$profiles->key()] = $profile;
$profiles->next();
} catch (\Exception $exception) {
throw new \PDOException($exception->getMessage(), 0, $exception);
}
}
return $profiles;
}
示例13: getFollowerByFollowedId
/**
* gets the Follower relationship by the person being followed
*
* @param \PDO $pdo PDO connection object
* @param int $followerFollowedId the person being followed
* @return \SplFixedArray SplFixedArray of Follower relationships found or null if not found
* @throws \PDOException when mySQL related errors occur
* @throws \TypeError when variables are not the correct data type
**/
public static function getFollowerByFollowedId(\PDO $pdo, int $followerFollowedId)
{
//Sanitize the followed id
if ($followerFollowedId <= 0) {
throw new \PDOException("Get Follower by Followed: Followed Id is not positive");
}
//Create a query template
$query = "SELECT followerFollowerId, followerFollowedId FROM follower WHERE followerFollowedId = :followerFollowedId";
$statement = $pdo->prepare($query);
//Search based on the one being followed
$parameters = ["followerFollowedId" => $followerFollowedId];
$statement->execute($parameters);
//Build an array of follower relationships
$followers = new \SplFixedArray($statement->rowCount());
$statement->setFetchMode(\PDO::FETCH_ASSOC);
while (($row = $statement->fetch()) !== false) {
try {
$follower = new Follower($row["followerFollowerId"], $row["followerFollowedId"]);
$followers[$followers->key()] = $follower;
$followers->next();
} catch (\Exception $exception) {
//If the row couldn't be converted, rethrow it
throw new \PDOException($exception->getMessage(), 0, $exception);
}
}
return $followers;
}
示例14: getFavoriteTeamsByFavoriteTeamProfileId
/**
* gets the list of this profiles favorite teams
*
* @param \PDO $pdo connection object
* @param int $allFavoriteTeams search for
* @return \SplFixedArray SplFixedArray of all teams favorited found
* @throws \PDOException when db related errors occur
* @throws \TypeError when variables are not correct data type
**/
public static function getFavoriteTeamsByFavoriteTeamProfileId(\PDO $pdo, int $favoriteTeamProfileId)
{
// sanitize the favoriteTeamProfileId
if ($favoriteTeamProfileId <= 0) {
throw new \PDOException("that profile doesnt exist");
}
// create a query template
$query = "SELECT favoriteTeamProfileId, favoriteTeamTeamId FROM favoriteTeam WHERE favoriteTeamProfileId = :favoriteTeamProfileId";
$statement = $pdo->prepare($query);
// bind the favoriteTeamTeamId to the place holder in the template
$parameters = ["favoriteTeamProfileId" => $favoriteTeamProfileId];
$statement->execute($parameters);
// build an array of favorite teams
$favoriteTeams = new \SplFixedArray($statement->rowCount());
$statement->setFetchMode(\PDO::FETCH_ASSOC);
while (($row = $statement->fetch()) !== false) {
try {
$favoriteTeam = new FavoriteTeam($row["favoriteTeamProfileId"], $row["favoriteTeamTeamId"]);
$favoriteTeams[$favoriteTeams->key()] = $favoriteTeam;
$favoriteTeams->next();
} catch (\Exception $exception) {
// if the row can't be converted, rethrow it
throw new \PDOException($exception->getMessage(), 0, $exception);
}
}
return $favoriteTeams;
}
示例15: next
/**
*
*/
public function next()
{
$this->set->next();
}