Robert Marshall 10 gadi atpakaļ
vecāks
revīzija
c0242472fe

+ 1 - 2
Model/Album.php

@@ -1,9 +1,8 @@
 <?php
-class Album extends DBObjectAutoCreate {
+class Album extends DBObject {
 	public $Images=array();
 	
 	public static function GetAlbums($includeHidden=false, $includeEmpty=false) {
-		self::CreateTable("albums");
 		$albums=array();
 		$hidden=$includeHidden?" AND album_hidden=1":"";
 		$albumIds=self::$PDO->query("SELECT album_id FROM albums WHERE album_deleted=0".$hidden);

+ 1 - 3
Model/BlogPost.php

@@ -1,20 +1,18 @@
 <?php
 ApplicationSettings::RegisterDefaultSetting("blog", "preview_length", 1000);
 
-class BlogPost extends DBObjectAutoCreate {
+class BlogPost extends DBObject {
 	//const PREVIEW_LENGTH=1000;
 	
 	private $_uri;
 
 	public static function GetCount() {
 		//self::SetupPDO();
-		self::CreateTable("blog_posts");
 		return self::$PDO->query("SELECT COUNT(*) FROM blog_posts WHERE post_content<>'' AND post_deleted=0")->fetchColumn();
 	}
 	
 	public static function GetLatest($count=1,$offset=0){
 		//self::SetupPDO();
-		self::CreateTable("blog_posts");
 		$prep=self::$PDO->prepare("SELECT post_id FROM blog_posts WHERE post_content<>'' AND post_deleted=0 ORDER BY post_timestamp DESC LIMIT ?,?");
 		$prep->bindValue(1,(int)$offset,PDO::PARAM_INT); // can't just use array in execute this time as execute array is treated like strings
 		$prep->bindValue(2,(int)$count,PDO::PARAM_INT);

+ 0 - 30
Model/DBObjectAutoCreate.php

@@ -1,30 +0,0 @@
-<?php
-
-/**
- * Description of DBObjectAutoCreate
- * 
- * Will automatically create any missing DB structures
- *
- * @author robert.marshall
- */
-class DBObjectAutoCreate extends DBObject {
-	private static $_run=array();
-	
-	protected static function CreateTable($table){
-		if (isset(self::$_run[$table]) && self::$_run[$table])
-			return;
-		
-		$PDO=self::GetPDO();
-		$prep=$PDO->prepare("SHOW TABLES LIKE ?");
-		$prep->execute(array($table));
-		if ($prep->rowCount()<1)
-			DBScriptRunner::RunScript("create_$table.sql");
-		
-		self::$_run[$table]=true;
-	}
-
-	public function __construct($table, $key, $id) {
-		self::CreateTable($table);
-		parent::__construct($table, $key, $id);
-	}
-}

+ 1 - 2
Model/Image.php

@@ -6,7 +6,7 @@ ApplicationSettings::RegisterDefaultSetting("images", "thumbnail_height", "360")
 if (!file_exists(ApplicationSettings::GetSetting("images", "upload_location")))
 	mkdir(ApplicationSettings::GetSetting("images", "upload_location"));
 
-class Image extends DBObjectAutoCreate {
+class Image extends DBObject {
 	public $Path,$ThumbnailPath;
 	private $Filename,$TempFile;
 	
@@ -31,7 +31,6 @@ class Image extends DBObjectAutoCreate {
 	}
 	
 	public static function GetImagesByAlbum($albumId) {
-		self::CreateTable("images");
 		$images=array();
 		$prep=self::$PDO->prepare("SELECT image_id FROM images WHERE album_id=? AND image_deleted=0");
 		$prep->execute(array($albumId));

+ 1 - 1
Model/Permission.php

@@ -1,5 +1,5 @@
 <?php
-class Permission extends DBObjectAutoCreate {
+class Permission extends DBObject {
 	public function __construct($id) {
 		$field="permission_id";
 		if (!is_numeric($id)){

+ 1 - 1
Model/Project.php

@@ -1,5 +1,5 @@
 <?php
-class Project extends DBObjectAutoCreate {
+class Project extends DBObject {
 	public $Category;
 	public $Images;
 	

+ 1 - 1
Model/ProjectCategory.php

@@ -1,5 +1,5 @@
 <?php
-class ProjectCategory extends DBObjectAutoCreate {
+class ProjectCategory extends DBObject {
 	public function __construct($id) {
 		parent::__construct("project_categories", "project_category_id", $id);
 	}

+ 1 - 1
Model/Session.php

@@ -1,7 +1,7 @@
 <?php
 ApplicationSettings::RegisterDefaultSetting("session", "expiry_window", "604800"); //a week
 
-class Session extends DBObjectAutoCreate {
+class Session extends DBObject {
 	private static $_instance,$_user;
 	
 	public function __construct($id=0) {

+ 1 - 1
Model/User.php

@@ -1,5 +1,5 @@
 <?php
-class User extends DBObjectAutoCreate {
+class User extends DBObject {
 	public $Group;
 	
 	public static function HashPassword($password) {

+ 1 - 1
Model/UserGroup.php

@@ -1,5 +1,5 @@
 <?php
-class UserGroup extends DBObjectAutoCreate {
+class UserGroup extends DBObject {
 	public $Permissions=array();
 	
 	public function __construct($id) {