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

/**
* ALBUMS
**/

class model_albums extends model_classicTable
{
	
	public function __construct()
	{
		
		parent::__construct('albums');
		
	}

	public function getAll()
	{
	
		return DB::qry("SELECT * FROM `" . $this->tableName . "` ORDER BY `order`", 3);
		
	}
	public function getAllActive()
	{
	
		return DB::qry("SELECT * FROM `" . $this->tableName . "` WHERE `is_active`=1 ORDER BY `order`", 3);
		
	}
	
	public function insertNewLine($name, $isPrivate, $password, $isActive)
	{
		
		$isPrivate = FUNCTIONS::getTinyIntFromCheckbox($isPrivate);
		if($name == '') $name = 'noname';
		
		$params = "
		`name`='" . $name . "', 
		`url`='" . $name . "', 
		`default_picture_ID`='0', 
		`is_private`='" . $isPrivate . "', 
		`password`='" . $password . "', 
		`order`='0'";
		
		parent::insertNewLine($params, $isActive);
		
	}
	
	public function updateLineById($id, $name, $isPrivate, $password, $isActive)
	{
		
		$isPrivate = FUNCTIONS::getTinyIntFromCheckbox($isPrivate);
		
		$params = "
		`name`='" . $name . "',
		`url`='" . $name . "', 
		`is_private`='" . $isPrivate . "', 
		`password`='" . $password . "'";
		
		parent::updateLineById($id, $params, $isActive);
		
	}	
	
	public function updateOrderById($id, $order)
	{
		
		$buffer = $this->getAll();
		
		$orderCount = 0;
		foreach($buffer as $key => $value){
			
			if($value['ID'] == $id){
				$params = "
				`order`='" . $order . "'";
			}else{
				if($orderCount == $order) $orderCount++;
				$params = "
				`order`='" . $orderCount . "'";
				$orderCount++;
			}
			parent::updateLineById($value['ID'], $params);
			
		}
		
	}	
}

?>
Return current item: GalleryShuffle