<?php
/**
 * Class that operate on table 'workstationassets'. Database Mysql.
 *
 * @author: http://phpdao.com
 * @date: 2014-04-01 11:09
 */
class WorkstationassetsMySqlExtDAO extends WorkstationassetsMySqlDAO{

	public function insertwithid($workstationassets){
	$sql = 'INSERT INTO workstationassets (workstationassetsId,	workstationid, assetsId, workhours, efficiency) VALUES (?, ?, ?, ?, ?)';
		$sqlQuery = new SqlQuery($sql);
		
		$sqlQuery->setNumber($workstationassets->workstationassetsId);
		$sqlQuery->setNumber($workstationassets->workstationid);
		$sqlQuery->set($workstationassets->assetsId);
		$sqlQuery->set($workstationassets->workhours);
		$sqlQuery->set($workstationassets->efficiency);

		$id = $this->executeInsert($sqlQuery);	
		$workstationassets->workstationassetsId = $id;
		return $id;
	}
	
	
	public function queryAllx($workstationid){
		$sql = 'SELECT assets.assetsName,  assets.Hourlyrate, workstationassets.*, workstation.workname
		FROM workstationassets
		 join assets on assets.assetId=workstationassets.assetsId
		 join workstation on workstation.workstationid=workstationassets.workstationid 
		 where workstation.workstationid='.$workstationid.'
		';
		$sqlQuery = new SqlQuery($sql);
		//print_r($sql.'</br>');
		return $this->getList($sqlQuery);
	}
	
	
	
		public function queryAllAsetess($id){
		
		$sql = 'select workstationassets.* , assets.assetsName
                FROM workstationassets 
				INNER JOIN assets ON workstationassets.assetsId= assets.assetId
                where  workstationid= "'.$id.'"';
					
		$sqlQuery = new SqlQuery($sql);
		//print_r($sqlQuery);
		return $this->getList($sqlQuery);
	}



	
}
?>