<?php

class Model_DbTable_SportsCode extends Zend_Db_Table {
	protected $_name = 'SportsCodes';

	public function insertData($data) {
		try {
			return $this -> insert($data);
		} catch (Exception $ex) {
			return $ex;
		}
	}

	public function updateData($data, $id) {
		try {
			return $this -> update($data, "SID ='" . $id . "'");
		} catch(Exception $e) {
			print_r($e);
			return false;
		}
	}

	public function getAutocomplete($keyword) {

		$select = $this -> select();
		$select -> from(array('t' => $this -> _name));
		$select -> where("Institution LIKE '%" . $keyword . "%' ");
		$select -> where('hide = 0 ');
		$select -> setIntegrityCheck(false);
		return $this -> fetchAll($select);
	}

	public function getAll() {
		$select = $this -> select();
		$select -> from(array('t' => $this -> _name));
		$select -> where("Active = 1  ");
		$select -> setIntegrityCheck(false);
		return $this -> fetchAll($select);

	}

}
