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