Add-DAO #14
@ -25,17 +25,17 @@ class Article {
|
|||||||
$this->client = mysqli_connect($host, $user, $pass, $db);
|
$this->client = mysqli_connect($host, $user, $pass, $db);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllPosts() {
|
public function getAllPosts() {
|
||||||
$result = mysqli_query($this->client, 'SELECT * FROM post');
|
$result = mysqli_query($this->client, 'SELECT * FROM post');
|
||||||
return mysqli_fetch_all($result);
|
return mysqli_fetch_all($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMostRecentPosts($limit){
|
public function getMostRecentPosts($limit){
|
||||||
$result = mysqli_query($this->client, 'SELECT * FROM post ORDER BY created DESC LIMIT ' . $limit);
|
$result = mysqli_query($this->client, 'SELECT * FROM post ORDER BY created DESC LIMIT ' . $limit);
|
||||||
return mysqli_fetch_all($result);
|
return mysqli_fetch_all($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPostData($postId) {
|
public function getPostData($postId) {
|
||||||
$result = mysqli_query($this->client, 'SELECT * FROM post WHERE ID = ' . $postId);
|
$result = mysqli_query($this->client, 'SELECT * FROM post WHERE ID = ' . $postId);
|
||||||
return mysqli_fetch_all($result);
|
return mysqli_fetch_all($result);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user