<?php
/**
 * ISO project
 * 
 * @author  Lukáš Havlíček
 * @version 1.0
 * 
 * Model for DB table documents revisions.
 */
class Revisions extends Zend_Db_Table_Abstract 
{
	protected $_name = 'iso_revisions';
	protected $_primary = 'id_revision';
	
	public function getRevNumberForInsert($idVersion)
	{
		$row = $this->fetchRow($this->select()->where('id_version = ?', $idVersion)->order('rev_number DESC')->limit(1));
		
		if ($row) {
			return ((int) $row->rev_number) + 1;
		} else {
			return (int) 1;
		}
	}
}
?>