모바일개발(Mobile Dev)/IOS개발(ObjectC)
php prepare stmt json type call
테크한스
2015. 11. 28. 12:45
반응형
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();
}
반응형