Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Yac\Core;
- class content
- {
- public contentID;
- public bodytext;
- public pageID;
- public function __construct(contentID = null, bodytext = Null, pageID = Null) -> void
- {
- let this->contentID = contentID;
- let this->bodytext = bodytext;
- let this->pageID = pageID;
- }
- public function getContent(alias) -> void
- {
- var pdo, stmt, result;
- let pdo = DataBase::register();
- let stmt = pdo->prepare("SELECT content.contentID, content.bodytext, content.pageID FROM content INNER JOIN page ON content.pageID = page.pageID WHERE page.alias= :alias");
- stmt->bindParam(":alias", alias);
- stmt->execute();
- if stmt->rowCount() > 0 {
- let result = stmt->fetch(PDO::FETCH_OBJ);
- let this->contentID = result->contentID;
- let this->bodytext = result->bodytext;
- let this->pageID = result->pageID;
- }
- }
- public function getContentByID(id) -> void
- {
- var pdo, stmt, result;
- let pdo = DataBase::register();
- let stmt = pdo->prepare("SELECT content.contentID, content.bodytext, content.pageID FROM content WHERE content.pageID= :id");
- stmt->bindParam(":id", id);
- stmt->execute();
- if stmt->rowCount() > 0 {
- let result = stmt->fetch(pdo::FETCH_OBJ);
- let this->contentID = result->contentID;
- let this->bodytext = result->bodytext;
- let this->pageID = result->pageID;
- }
- }
- public function save() -> void
- {
- var pdo, stmt;
- let pdo = DataBase::register();
- let stmt = pdo->prepare("INSERT INTO content (contentID, bodytext, pageID)
- VALUES (:contentID, :bodytext, :pageID)
- ON DUPLICATE KEY
- UPDATE contentID = LAST_INSERT_ID(contentID), bodytext = :bodytext, pageID = :pageID");
- stmt->bindParam(":contentID", this->contentID);
- stmt->bindParam(":bodytext", this->bodytext);
- stmt->bindParam(":pageID", this->pageID);
- stmt->execute();
- }
- public static function destroy(id) -> void
- {
- var pdo, stmt;
- let pdo = DataBase::register();
- let stmt = pdo->prepare("DELETE FROM content WHERE pageID = :pageID");
- stmt->bindParam(":pageID", id);
- stmt->execute();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement