Location: PHPKode > scripts > GalleryShuffle > v1.0/php/Models/pictures.php
<?php

/**
* PICTURES
**/

class model_pictures extends model_classicTable
{
	
	public function __construct()
	{
	
		parent::__construct('pictures');
		
	}
	
	public function getAllFromAlbum($id)
	{
		
		return DB::qry("SELECT * FROM `" . $this->tableName . "` WHERE album_ID=" . $id, 3);
		
	}
	
	public function deleteAllFromAlbum($id)
	{
		
		$buffer = $this->getAllFromAlbum($id);
		foreach($buffer as $key => $value){
			unlink(CONFIG::picturesFolder . CONFIG::picturesSmallFolder . $value['UID'] . CONFIG::picturesExtension);
			unlink(CONFIG::picturesFolder . CONFIG::picturesLargeFolder . $value['UID'] . CONFIG::picturesExtension);
		}
			
		DB::qry("DELETE FROM `" . $this->tableName . "` WHERE album_ID=" . $id);
		
	}
	
	public function insertNewLine($name, $albumId, $imageBase64Small, $imageBase64Large)
	{
	
		$uid = uniqid();
		
		FUNCTIONS::writeBase64Image(CONFIG::picturesFolder . CONFIG::picturesSmallFolder . $uid, $imageBase64Small);
		FUNCTIONS::writeBase64Image(CONFIG::picturesFolder . CONFIG::picturesLargeFolder . $uid, $imageBase64Large);
		
		$params = "
		`name`='" . $name . "', 
		`UID`='" . $uid . "', 
		`album_ID`='" . $albumId . "'";
		
		parent::insertNewLine($params);
		
	}
	
	public function updateLineById($id, $name)
	{
		
		$params = "
		`name`='" . $name . "'";
		
		parent::updateLineById($id, $params);
		
	}
	
	public function updateAlbumLineById($id, $albumId) 
	{
		
		$params = "
		`album_ID`='" . $albumId . "'";
		
		parent::updateLineById($id, $params);
		
	}
	
	public function deleteLineById($id)
	{
	
		$buffer = $this->getLineById($id);
		unlink(CONFIG::picturesFolder . CONFIG::picturesSmallFolder . $buffer['UID'] . CONFIG::picturesExtension);
		unlink(CONFIG::picturesFolder . CONFIG::picturesLargeFolder . $buffer['UID'] . CONFIG::picturesExtension);
		parent::deleteLineById($id);
		
	}
	
}

?>
Return current item: GalleryShuffle