All pastes #731289 Raw Edit

Something

public text v1 · immutable
·published 2007-10-09 22:34 UTC
rendered paste body
<?php
	require_once('functions.php');
	require_once('Image.class.php');

	class Article {
		private $article_id;
		private $title;
		private $author;
		private $body;
		private $publish_dt;
		private $update_dt;
		private $views;
		private $front_page;
		private $section;
		public $img;
		
		public function __construct($row) {
			$this->loadFromRow($row);
		}
		
		private function loadFromRow($row) {
			$this->article_id	= $row['pk_article_id'];
			$this->title			= $row['title'];
			$this->author			= $row['author'];
			$this->body				= $row['body'];
			$this->publish_dt	= $row['publish_dt'];
			$this->update_dt	= $row['update_dt'];
			$this->views			= $row['views'];
			$this->front_page	=	$row['front_page'];
			$this->section		= $row['name'];
			$this->getImages();
		}
		
		public function getImages() {
			$link = getConnection();
			
			$query = sprintf("SELECT * FROM photo WHERE fk_article_id = %d ORDER BY thumb DESC",
				mysql_real_escape_string($this->article_id));
			
			$result = mysql_query($query, $link) or die(mysql_error());
			
			if (mysql_num_rows($result) > 0) {
				for ($i=0; $i<mysql_num_rows($result); $i++) {
					$row[$i] = mysql_fetch_assoc($result);
				}
				
				$i = 0;
				foreach ($row as $image) {
					$this->img[$i] = new Image($image);
					$i++;
				}
			}
			else {
				$this->img = 0;
			}
		}
		
		public function hasThumb () {
		 $has = false;
			if (is_array($this->img)) {
				//if ($this->img->[0]->['img_isThumb'] == 1) {
					$has = true;
				//}
			}
			return $has;
		}
		
		public function getArticleId() {
			return $this->article_id;
		}
		
		public function getTitle() {
			return $this->title;
		}
		
		public function getAuthor() {
			return $this->author;
		}
		
		public function getBody() {
			return $this->body;
		}
		
		public function getShortBody() {
			return snippetwop($this->body, 300);
		}
		
		public function getPublishDt() {
			return $this->publish_dt;
		}
		
		public function getUpdateDt() {
			return $this->update_dt;
		}
		
		public function getViews() {
			return $this->views;
		}
		
		public function getFrontPage() {
			return $this->front_page;
		}
		
		public function getSection() {
			return $this->section;
		}
	}

?>