<?php
class UserGroup extends Zend_Db_Table_Abstract {
	protected $_name = 'iso_user_group';
	protected $_primary = array('id_group', 'id_user');
	
	public function getUsers($idGroup) 
	{
		$select = $this->select()->setIntegrityCheck(false)
					   ->from($this)
					   ->where('id_group = ?', $idGroup)
					   ->joinLeftUsing('iso_users', 'id_user')
					   ->order('iso_users.user_surname ASC');
					   
		return $this->fetchAll($select);
	}
	
	public function getGroups($idUser) 
	{
		$select = $this->select()->setIntegrityCheck(false)
					   ->from($this)
					   ->where('id_user = ?', $idUser)
					   ->joinLeftUsing('iso_groups', 'id_group')
					   ->order('iso_groups.group_name ASC');
					   
		return $this->fetchAll($select);
	}
}
?>