반응형
php prepare stmt json type call
function getComments($inPostID=null)
{
$commentArray = array();
$tempArray = array();
if (!empty($inPostID))
{
//echo " Get comments for the post with the postID of ". $inPostID;
$stmt = db::connect()->prepare("SELECT * FROM Comments WHERE postID = ? ORDER BY commentDate DESC");
$stmt->bind_param('i', $inPostID);
$stmt->execute();
$stmt->bind_result($commentID, $postID, $userID, $commentDate, $commentContent);
while($stmt->fetch())
{
$bindResults = array($commentID, $postID, $userID, $commentDate, $commentContent);
array_push($tempArray, $bindResults);
}
$stmt->close();
$total = count($tempArray);
for($i = 0; $i < $total; $i++)
{
$thisComment = new ViewComment($tempArray[$i][0], $tempArray[$i][1], $tempArray[$i][2], $tempArray[$i][3], $tempArray[$i][4]);
array_push($commentArray, $thisComment);
}
}
return $commentArray;
}
$conn = new mysqli(DB_HOST,DB_USERNAME,DB_PASSWORD, DB_NAME);
if($stmt = $conn->prepare('select * from users where u_id = ?'))
{
$stmt->bind_param("s", $param);
$stmt->execute();
$stmt->bind_result($column1, $column2, $column3);
while ($stmt->fetch()) {
echo "Column 1: $column1\n";
echo "Column 2: $column2\n";
echo "Column 3: $column3\n";
}
$stmt->close();
}
반응형
'모바일개발(Mobile Dev) > IOS개발(ObjectC)' 카테고리의 다른 글
Customizing Navigation Bar (0) | 2015.11.29 |
---|---|
IOS image file path (0) | 2015.11.28 |
How To Make an iPhone App Connect to a MySQL Database (0) | 2015.11.27 |
Getting Data From Web Services in JSON Format (0) | 2015.11.27 |
mysqli_stmt::bind_param (0) | 2015.11.23 |