本文整理汇总了PHP中Connection::fetch_array方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::fetch_array方法的具体用法?PHP Connection::fetch_array怎么用?PHP Connection::fetch_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection::fetch_array方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
public function load($iRecipeTypeID)
{
$connection = new Connection();
$sSQL = "SELECT RecipeTypeID, TypeName, Description, DisplayOrder\n FROM tbrecipetype\n WHERE RecipeTypeID=" . $iRecipeTypeID;
$resultSet = $connection->query($sSQL);
$row = $connection->fetch_array($resultSet);
//store into data attribues:
$this->iRecipeTypeID = $row["RecipeTypeID"];
$this->sTypeName = $row["TypeName"];
$this->sDescription = $row["Description"];
$this->iDisplayOrder = $row["DisplayOrder"];
// get all recipe IDs of type:
$sSQL = "SELECT RecipeID\n FROM tbrecipe\n WHERE RecipeTypeID=" . $iRecipeTypeID . "\n ORDER BY CreatedAt DESC";
$resultSet = $connection->query($sSQL);
while ($row = $connection->fetch_array($resultSet)) {
$iRecipeID = $row['RecipeID'];
$oRecipe = new Recipe();
$oRecipe->load($iRecipeID);
$this->aRecipes[] = $oRecipe;
}
$connection->close_connection();
}
示例2: listAllTypes
public static function listAllTypes()
{
// creates associative array
$aRecipeTypes = array();
$connection = new Connection();
$sSQL = "SELECT RecipeTypeID,TypeName\n FROM tbrecipetype\n ";
$resultSet = $connection->query($sSQL);
while ($row = $connection->fetch_array($resultSet)) {
$iRecipeTypeID = $row['RecipeTypeID'];
$aRecipeTypes[$iRecipeTypeID] = $row['TypeName'];
}
$connection->close_connection();
return $aRecipeTypes;
}
示例3: load
public function load($iCommentID)
{
$connection = new Connection();
$sSQL = "SELECT CommentID, Comment, UserID, RecipeID, CreatedAt, OriginalID\n FROM tbcomment\n WHERE CommentID=" . $iCommentID;
$resultSet = $connection->query($sSQL);
$row = $connection->fetch_array($resultSet);
//store data into attributes:
$this->iCommentID = $row["CommentID"];
$this->sComment = $row["Comment"];
$this->iUserID = $row["UserID"];
$this->iRecipeID = $row["RecipeID"];
$this->tCreatedAt = $row["CreatedAt"];
$this->iOriginalID = $row["OriginalID"];
$sSQL = "SELECT CommentID \n FROM tbcomment\n WHERE OriginalID=" . $iCommentID;
$resultSet = $connection->query($sSQL);
while ($row = $connection->fetch_array($resultSet)) {
$iCommentID = $row["CommentID"];
$oComment = new Comment();
$oComment->load($iCommentID);
$this->aReplies[] = $oComment;
}
$connection->close_connection();
}
示例4: getAllProducts
public static function getAllProducts()
{
$aAllProducts = array();
$connection = new Connection();
$sSQL = "SELECT ProductID\n FROM tbproduct\n ORDER BY CreatedAt DESC\n ";
$resultSet = $connection->query($sSQL);
while ($row = $connection->fetch_array($resultSet)) {
$iProductID = $row['ProductID'];
$oProduct = new Product();
$oProduct->load($iProductID);
$aAllProducts[] = $oProduct;
}
$connection->close_connection();
return $aAllProducts;
}
示例5: load
public function load($iRecipeID)
{
$connection = new Connection();
$sSQL = "SELECT RecipeID, Title, AuthorNotes, Ingredients, Directions, ImagePath, CreatedAt, UserID, RecipeTypeID\n FROM tbrecipe\n WHERE RecipeID = " . $iRecipeID;
$resultSet = $connection->query($sSQL);
$row = $connection->fetch_array($resultSet);
//store into attributes:
$this->iRecipeID = $row["RecipeID"];
$this->sTitle = $row["Title"];
$this->sAuthorNotes = $row["AuthorNotes"];
$this->sIngredients = $row["Ingredients"];
$this->sDirections = $row["Directions"];
$this->sImagePath = $row["ImagePath"];
$this->tCreatedAt = $row["CreatedAt"];
$this->iUserID = $row["UserID"];
$this->iRecipeTypeID = $row["RecipeTypeID"];
// get all likes from recipe:
$sSQL = "SELECT LikeID\n FROM tblike\n WHERE RecipeID = " . $iRecipeID;
$resultSet = $connection->query($sSQL);
while ($row = $connection->fetch_array($resultSet)) {
$iLikeID = $row["LikeID"];
$oLike = new Like();
$oLike->load($iLikeID);
$this->aLikes[] = $iLikeID;
}
// get all comments on a recipe:
$sSQL = "SELECT CommentID\n FROM tbcomment\n WHERE RecipeID = " . $iRecipeID . " ORDER BY CreatedAt DESC";
$resultSet = $connection->query($sSQL);
while ($row = $connection->fetch_array($resultSet)) {
$iCommentID = $row["CommentID"];
$oComment = new Comment();
$oComment->load($iCommentID);
$this->aComments[] = $oComment;
}
$connection->close_connection();
}
示例6: loadByUserRecipe
public function loadByUserRecipe($iUserID, $iRecipeID)
{
// checks if user has already liked recipe
$connection = new Connection();
$sSQL = "SELECT LikeID\n\t\t\t\t FROM tblike\n\t\t\t\t WHERE UserID='" . $connection->escape($iUserID) . "' AND RecipeID='" . $connection->escape($iRecipeID) . "'";
$resultSet = $connection->query($sSQL);
$row = $connection->fetch_array($resultSet);
if ($row == false) {
// user hasn't liked recipe
return false;
} else {
$this->load($row["LikeID"]);
return true;
}
}
示例7: load
public function load($iID)
{
// open
$oConnection = new Connection();
// extract
$sSQL = "SELECT TypeID, TypeName, Description, DisplayOrder\n\t\tFROM tbproducttype\n\t\tWHERE TypeID=" . $iID;
$oResult = $oConnection->query($sSQL);
// fetch
$aCategory = $oConnection->fetch_array($oResult);
$this->iTypeID = $aCategory["TypeID"];
$this->sTypeName = $aCategory["TypeName"];
$this->sDescription = $aCategory["Description"];
$this->iDisplayOrder = $aCategory["DisplayOrder"];
// load products under the category
$sSQL = "SELECT ProductID\n\t\tFROM tbproduct\n\t\tWHERE TypeID=" . $iID;
$oResult = $oConnection->query($sSQL);
while ($aRow = $oConnection->fetch_array($oResult)) {
$oProduct = new product();
$oProduct->load($aRow["ProductID"]);
$this->aProducts[] = $oProduct;
}
// close
$oConnection->close_connection();
}
示例8: getAllRecipes
public static function getAllRecipes()
{
$aAllRecipes = array();
$connection = new Connection();
$sSQL = "SELECT RecipeID\n FROM tbrecipe\n ORDER BY CreatedAt DESC\n ";
$resultSet = $connection->query($sSQL);
while ($row = $connection->fetch_array($resultSet)) {
$iRecipeID = $row['RecipeID'];
$oRecipe = new Recipe();
$oRecipe->load($iRecipeID);
$aAllRecipes[] = $oRecipe;
}
$connection->close_connection();
return $aAllRecipes;
}
示例9: loadByUsername
public function loadByUsername($sUsername)
{
// checks if username already exists in database
$connection = new Connection();
$sSQL = "SELECT UserID\n FROM tbuser\n WHERE Username='" . $connection->escape($sUsername) . "'";
$resultSet = $connection->query($sSQL);
$row = $connection->fetch_array($resultSet);
if ($row == false) {
// if username doesn't exist
return false;
} else {
$this->load($row["UserID"]);
// if username exists
return true;
}
}
示例10: loadByEmail
public function loadByEmail($sEmail)
{
// checks if email already exists in database
$connection = new Connection();
$sSQL = "SELECT SubscriberID\n FROM tbnewsletter\n WHERE Email='" . $connection->escape($sEmail) . "'";
$resultSet = $connection->query($sSQL);
$row = $connection->fetch_array($resultSet);
if ($row == false) {
// if user hasn't subscribed
return false;
} else {
$this->load($row['SubscriberID']);
// if user has already subscribed
return true;
}
}
示例11: load
public function load($iProductID)
{
$connection = new Connection();
$sSQL = "SELECT ProductID, ProductName, Description, Price, Size, Ingredients, StockLevel, ImagePath, CreatedAt\n FROM tbproduct\n WHERE ProductID=" . $iProductID;
$resultSet = $connection->query($sSQL);
$row = $connection->fetch_array($resultSet);
//store into attributes:
$this->iProductID = $row["ProductID"];
$this->sProductName = $row["ProductName"];
$this->sDescription = $row["Description"];
$this->fPrice = $row["Price"];
$this->sSize = $row["Size"];
$this->sIngredients = $row["Ingredients"];
$this->iStockLevel = $row["StockLevel"];
$this->sImagePath = $row["ImagePath"];
$this->tCreatedAt = $row["CreatedAt"];
$connection->close_connection();
}
示例12: load
public function load($iID)
{
// Open
$oConnection = new Connection();
// Extract
$sSQL = "SELECT ProductID, ProductName, Description, Price, TypeID, PhotoPath\n\t\tFROM tbproduct\n\t\tWHERE ProductID =" . $iID;
$oResult = $oConnection->query($sSQL);
// fetch
$aProduct = $oConnection->fetch_array($oResult);
$this->iProductID = $aProduct["ProductID"];
$this->sProductName = $aProduct["ProductName"];
$this->sDescription = $aProduct["Description"];
$this->iCost = $aProduct["Price"];
$this->iTypeID = $aProduct["TypeID"];
$this->sPhotoPath = $aProduct["PhotoPath"];
// close
$oConnection->close_connection();
}
示例13: load
public function load($iOrderID)
{
$connection = new Connection();
$sSQL = "SELECT OrderID, OrderDate, OrderStatus, RecipientName, DeliveryAddress, BillingAddress, Payment, AccountName, CardNumber, ExpiryDate, Security, UserID\n FROM tborder\n WHERE OrderID=" . $iOrderID;
$resultSet = $connection->query($sSQL);
$row = $connection->fetch_array($resultSet);
//store data in attributes:
$this->iOrderID = $row["OrderID"];
$this->tOrderDate = $row["OrderDate"];
$this->sOrderStatus = $row["OrderStatus"];
$this->sRecipientName = $row["RecipientName"];
$this->sDelivery = $row["DeliveryAddress"];
$this->sBilling = $row["BillingAddress"];
$this->sPayment = $row["Payment"];
$this->sAccountName = $row["AccountName"];
$this->iCardNumber = $row["CardNumber"];
$this->sExpiry = $row["ExpiryDate"];
$this->iSecurity = $row["Security"];
$this->iUserID = $row["UserID"];
$connection->close_connection();
}
示例14: load
public function load($iID)
{
// open
$oConnection = new Connection();
// execute query
$sSQL = "SELECT CustomerID, FirstName, LastName, Address, Telephone, Email, Username, Password\n\t\tFROM tbcustomer\n\t\tWHERE CustomerID =" . $oConnection->escape_value($iID);
$oResult = $oConnection->query($sSQL);
// extract
$aCustomer = $oConnection->fetch_array($oResult);
$this->iCustomerID = $aCustomer["CustomerID"];
$this->sFirstName = $aCustomer["FirstName"];
$this->sLastName = $aCustomer["LastName"];
$this->sAddress = $aCustomer["Address"];
$this->sTelephone = $aCustomer["Telephone"];
$this->sEmail = $aCustomer["Email"];
$this->sUserName = $aCustomer["Username"];
$this->sPassword = $aCustomer["Password"];
$this->bExisting = true;
// close
$oConnection->close_connection();
}