//model sample programs
--------------------------------------------------------------
<?php
/**
* Statistics class
*
* @uses StatisticsActions
* @copyright
* @license
* @version
* @author Rathinasamy
* @created Oct 07, 2011
*/
class Statistics extends Zend_Db_Table_Abstract
{
protected $_name ="test_statistics";
/**
* Function to getTest Team fields
*
* Created: Oct 08, 2011
* @param string $pmTeamID
* @return Array
*/
function getTestTeamFieldsDetails($pmTeamID){
$selTeamFields = $this->select()
->setIntegrityCheck(false)
->from(array('stsm'=>'test_statistics_master'),array('stsm.stsm_name','stsm.stsm_id','stsm.stsm_field_width'))
->joinInner ( array('sprt'=>'test_sport'), 'stsm.stsm_sprt_id=sprt.sprt_id',array('sprt_id'))
->joinInner ( array('team'=>'test_team'), 'sprt.sprt_id=team.team_sprt_id',array('team_id'))
->where("stsm.stsm_status=1 and sprt.sprt_status=1 and team.team_status=1 and team.team_id=".$pmTeamID)
->order('stsm.stsm_id');
$resTeamFields = $this->fetchAll($selTeamFields);
return $resTeamFields;
}
/**
* Function to getTest Recent player's statistics
*
* Created: Oct 07, 2011
* @param string $pmTeamID
* @param string $pmPlayerID
* @return Array
*/
function getTestLatestGameDetails($pmTeamID,$pmPlayerID){
$selLstGamedels = $this->select()
->setIntegrityCheck(false)
->from(array('stsm'=>'test_statistics_master'),array('GROUP_CONCAT(stsm.stsm_name ORDER BY stsm.stsm_id) stst_name','GROUP_CONCAT(stsm.stsm_id ORDER BY stsm.stsm_id) sts_id'))
->joinInner ( array('sprt'=>'test_sport'), 'stsm.stsm_sprt_id=sprt.sprt_id')
->joinInner ( array('team'=>'test_team'), 'stsm.stsm_sprt_id=sprt.sprt_id')
->joinInner ( array('stst'=>'test_statistics'), 'stst.stst_team_id=team.team_id',array('stst.stst_game_date',
'stst.stst_played_team_name','stst.stst_id'))
->joinInner ( array('stsd'=>'test_statistics_dtl'), 'stsd.stsd_stsm_id = stsm.stsm_id and stsd.stsd_stst_id=stst.stst_id',array('GROUP_CONCAT(stsd.stsd_value ORDER BY stsm_id) stsd_value'))
->joinInner ( array('plyr'=>'test_team_players'), 'plyr.plyr_id=stsd.stsd_plyr_id',array('plyr.plyr_user_id'))
->where("stsm.stsm_status=1 and sprt.sprt_status=1 and stst.stst_status=1 and stsd.stsd_status =1 and team.team_status=1 and plyr.plyr_status=1 and team.team_id=".$pmTeamID." and stsd.stsd_plyr_id=".$pmPlayerID)
->group('stst.stst_game_date')
->order('stst.stst_game_date DESC')
->limit('1');
$resLstGamedels= $this->fetchAll($selLstGamedels);
return $resLstGamedels;
}
/**
* Function to getTest player's statistics summary
*
* Created: Oct 08, 2011
* @param string $pmTeamID
* @param string $pmPlayerID
* @return Array
*/
function getTestGameDetails($pmTeamID,$pmPlayerID,$vSort){
if($vSort!="")
$vSortdet=" and stst.stst_game_date LIKE "."'".$vSort."%'";
$selGamedls = $this->select()
->setIntegrityCheck(false)
->from(array('stsm'=>'test_statistics_master'),array('GROUP_CONCAT(stsm.stsm_name ORDER BY stsm.stsm_id) stst_name','GROUP_CONCAT(stsm.stsm_id ORDER BY stsm.stsm_id) sts_id'))
->joinInner ( array('sprt'=>'test_sport'), 'stsm.stsm_sprt_id=sprt.sprt_id')
->joinInner ( array('team'=>'test_team'), 'stsm.stsm_sprt_id=sprt.sprt_id')
->joinInner ( array('stst'=>'test_statistics'), 'stst.stst_team_id=team.team_id',array('stst.stst_game_date',
'stst.stst_played_team_name','stst.stst_id'))
->joinInner ( array('stsd'=>'test_statistics_dtl'), 'stsd.stsd_stsm_id = stsm.stsm_id and stsd.stsd_stst_id=stst.stst_id',array('GROUP_CONCAT(stsd.stsd_value ORDER BY stsm_id) stsd_value'))
->joinInner ( array('plyr'=>'test_team_players'), 'plyr.plyr_id=stsd.stsd_plyr_id',array('plyr.plyr_user_id'))
->where("stsm.stsm_status=1 and sprt.sprt_status=1 and stst.stst_status=1 and stsd.stsd_status =1 and team.team_status=1 and plyr.plyr_status=1 and team.team_id=".$pmTeamID." and stsd.stsd_plyr_id=".$pmPlayerID.$vSortdet)
->group('stst.stst_game_date')
->order('stst.stst_game_date DESC');
$resGamedls = $this->fetchAll($selGamedls);
return $resGamedls;
}
/**
* Function to getTest player's Details
*
* Created: Oct 08, 2011
* @param string $pmTeamID
* @return Array
*/
function getTestPlayerDetails($pmTeamID,$playerID){
$selPlyrdls = $this->select()
->setIntegrityCheck(false)
->from(array('plyr'=>'test_team_players'),array('plyr.plyr_id'))
->joinInner ( array('team'=>'test_team'), 'team.team_id=plyr.plyr_team_id',array('team.team_id','team.team_name'))
->joinInner ( array('users'=>'test_users'), 'users.user_id=plyr.plyr_user_id',array('users.user_fname','users.user_lname'))
->where("plyr.plyr_status=1 and team.team_status=1 and users.user_status=1 and plyr.plyr_id=".$playerID." and team.team_id=".$pmTeamID);
$resPlyrdls = $this->fetchAll($selPlyrdls);
return $resPlyrdls;
}
/**
* Function to getTest player's Details
*
* Created: Oct 08, 2011
* @param string $pmTeamID
* @return Array
*/
function getTestTeamPlayerDetails($pmTeamID){
$selTeamPlyrdls = $this->select()
->setIntegrityCheck(false)
->from(array('plyr'=>'test_team_players'),array('plyr.plyr_id'))
->joinInner ( array('team'=>'test_team'), 'team.team_id=plyr.plyr_team_id',array('team.team_id','team.team_sprt_id'))
->joinInner ( array('users'=>'test_users'), 'users.user_id=plyr.plyr_user_id',array('users.user_fname','users.user_lname'))
->joinInner ( array('router'=>'test_router'),'router.rutr_id=team.team_rutr_id',array('router.rutr_url'))
->where("plyr.plyr_status=1 and team.team_status=1 and users.user_status=1 and team.team_id=".$pmTeamID);
$resTeamPlyrdls = $this->fetchAll($selTeamPlyrdls);
return $resTeamPlyrdls;
}
/**
* Function to getTest statistics Details
*
* Created: Oct 08, 2011
* @param string $pmStstID
* @return Array
*/
function getTestStatisticsDetails($pmStstID){
$selStcsdls = $this->select()
->setIntegrityCheck(false)
->from(array('stst'=>'test_statistics'))
->joinInner ( array('stsd'=>'test_statistics_dtl'), 'stsd.stsd_stst_id=stst.stst_id')
->where("stst.stst_status=1 and stsd.stsd_status=1 and stst.stst_id=".$pmStstID);
$resStcsdls = $this->fetchAll($selStcsdls);
return $resStcsdls;
}
/**
* Function to store statistics Details
*
* Created: Oct 08, 2011
* @param string $parameters
* @return Array
*/
function addStatistics($pmData)
{
//#-- Home Team details
$gameDate=explode("/",$pmData['gameDate']);
$gameDate=$gameDate[2]."-".$gameDate[0]."-".$gameDate[1];
$insHomeDet = array(
"stst_team_id"=>$pmData['teamid'],
"stst_played_team_name"=>$pmData['opponent'],
"stst_game_date"=>$gameDate,
"stst_played_team_type"=>0,
"stst_status"=>1
);
$homelastid = $this->insert($insHomeDet);
$vScoreids = explode(",",$pmData['Plyrscoreid']);
$vScorecnt = count($vScoreids);
$vHomeScores = explode(",",$pmData['plyrscore']);
$oStatisticsDetails = new StatisticsDetail();
for($scloop=0;$scloop<$vScorecnt;$scloop++)
{
if($vScoreids[$scloop] != "")
{
$insHomeScores = array(
"stsd_stsm_id"=>$vScoreids[$scloop],
"stsd_stst_id"=>$homelastid,
"stsd_plyr_id"=>$pmData['playerid'],
"stsd_value"=>$vHomeScores[$scloop],
"stsd_status"=>1
);
$oStatisticsDetails->insert($insHomeScores);
}
}
}
/**
* Function to update statistics Details
*
* Created: Oct 08, 2011
* @param string $parameters
* @return true/false
*/
function updateStatistics($pmData)
{
$gameDate=explode("/",$pmData['gameDate']);
$gameDate=$gameDate[2]."-".$gameDate[0]."-".$gameDate[1];
$UpdateFields = array(
"stst_played_team_name"=>$pmData['opponent'],
"stst_game_date"=>$gameDate
);
$this->update($UpdateFields,array('stst_id= ?'=>$pmData['stst_id']));
$vScoreids = explode(",",$pmData['Plyrscoreid']);
$vScorecnt = count($vScoreids);
$vHomeScores = explode(",",$pmData['plyrscore']);
$oStatisticsDet = new StatisticsDetail();
for($scloop=0;$scloop<$vScorecnt;$scloop++)
{
if($vScoreids[$scloop] != "")
{
$UpdateFields = array("stsd_value"=>$vHomeScores[$scloop]);
$oStatisticsDet->update($UpdateFields,array('stsd_stsm_id= ?'=>$vScoreids[$scloop],'stsd_stst_id= ?'=>$pmData['stst_id']));
}
}
}
/**
* Function to delete statistics Details
*
* Created: Oct 11, 2011
* @param string $parameters
* @return true/false
*/
function deleteStatistics($pmData)
{
$UpdateFields = array("stst_status"=>2);
$this->update($UpdateFields,array('stst_id= ?'=>$pmData['stst_id']));
$oStatisticsDet = new StatisticsDetail();
$UpdateFields = array("stsd_status"=>2);
$oStatisticsDet->update($UpdateFields,array('stsd_stst_id= ?'=>$pmData['stst_id']));
}
/**
* Function to list the opponent Details
*
* Created: Oct 12, 2011
* @param string $parameters
* @return array
*/
function opponentlists($sportID,$teamID,$searchKey)
{
$vSortdet=" and team.team_name LIKE "."'".$searchKey."%'";
$selTeamFields = $this->select()
->setIntegrityCheck(false)
->from(array('team'=>'test_team'),array('team_name'))
->joinInner( array('router'=>'test_router'),'router.rutr_id=team.team_rutr_id',array('rutr_url'))
->where("team.team_id!=".$teamID." and team.team_sprt_id=".$sportID.$vSortdet);
$resTeamFields = $this->fetchAll($selTeamFields);
return $resTeamFields;
}
}
?>
--------------------------------------------------------------
<?php
/**
* Statistics class
*
* @uses StatisticsActions
* @copyright
* @license
* @version
* @author Rathinasamy
* @created Oct 07, 2011
*/
class Statistics extends Zend_Db_Table_Abstract
{
protected $_name ="test_statistics";
/**
* Function to getTest Team fields
*
* Created: Oct 08, 2011
* @param string $pmTeamID
* @return Array
*/
function getTestTeamFieldsDetails($pmTeamID){
$selTeamFields = $this->select()
->setIntegrityCheck(false)
->from(array('stsm'=>'test_statistics_master'),array('stsm.stsm_name','stsm.stsm_id','stsm.stsm_field_width'))
->joinInner ( array('sprt'=>'test_sport'), 'stsm.stsm_sprt_id=sprt.sprt_id',array('sprt_id'))
->joinInner ( array('team'=>'test_team'), 'sprt.sprt_id=team.team_sprt_id',array('team_id'))
->where("stsm.stsm_status=1 and sprt.sprt_status=1 and team.team_status=1 and team.team_id=".$pmTeamID)
->order('stsm.stsm_id');
$resTeamFields = $this->fetchAll($selTeamFields);
return $resTeamFields;
}
/**
* Function to getTest Recent player's statistics
*
* Created: Oct 07, 2011
* @param string $pmTeamID
* @param string $pmPlayerID
* @return Array
*/
function getTestLatestGameDetails($pmTeamID,$pmPlayerID){
$selLstGamedels = $this->select()
->setIntegrityCheck(false)
->from(array('stsm'=>'test_statistics_master'),array('GROUP_CONCAT(stsm.stsm_name ORDER BY stsm.stsm_id) stst_name','GROUP_CONCAT(stsm.stsm_id ORDER BY stsm.stsm_id) sts_id'))
->joinInner ( array('sprt'=>'test_sport'), 'stsm.stsm_sprt_id=sprt.sprt_id')
->joinInner ( array('team'=>'test_team'), 'stsm.stsm_sprt_id=sprt.sprt_id')
->joinInner ( array('stst'=>'test_statistics'), 'stst.stst_team_id=team.team_id',array('stst.stst_game_date',
'stst.stst_played_team_name','stst.stst_id'))
->joinInner ( array('stsd'=>'test_statistics_dtl'), 'stsd.stsd_stsm_id = stsm.stsm_id and stsd.stsd_stst_id=stst.stst_id',array('GROUP_CONCAT(stsd.stsd_value ORDER BY stsm_id) stsd_value'))
->joinInner ( array('plyr'=>'test_team_players'), 'plyr.plyr_id=stsd.stsd_plyr_id',array('plyr.plyr_user_id'))
->where("stsm.stsm_status=1 and sprt.sprt_status=1 and stst.stst_status=1 and stsd.stsd_status =1 and team.team_status=1 and plyr.plyr_status=1 and team.team_id=".$pmTeamID." and stsd.stsd_plyr_id=".$pmPlayerID)
->group('stst.stst_game_date')
->order('stst.stst_game_date DESC')
->limit('1');
$resLstGamedels= $this->fetchAll($selLstGamedels);
return $resLstGamedels;
}
/**
* Function to getTest player's statistics summary
*
* Created: Oct 08, 2011
* @param string $pmTeamID
* @param string $pmPlayerID
* @return Array
*/
function getTestGameDetails($pmTeamID,$pmPlayerID,$vSort){
if($vSort!="")
$vSortdet=" and stst.stst_game_date LIKE "."'".$vSort."%'";
$selGamedls = $this->select()
->setIntegrityCheck(false)
->from(array('stsm'=>'test_statistics_master'),array('GROUP_CONCAT(stsm.stsm_name ORDER BY stsm.stsm_id) stst_name','GROUP_CONCAT(stsm.stsm_id ORDER BY stsm.stsm_id) sts_id'))
->joinInner ( array('sprt'=>'test_sport'), 'stsm.stsm_sprt_id=sprt.sprt_id')
->joinInner ( array('team'=>'test_team'), 'stsm.stsm_sprt_id=sprt.sprt_id')
->joinInner ( array('stst'=>'test_statistics'), 'stst.stst_team_id=team.team_id',array('stst.stst_game_date',
'stst.stst_played_team_name','stst.stst_id'))
->joinInner ( array('stsd'=>'test_statistics_dtl'), 'stsd.stsd_stsm_id = stsm.stsm_id and stsd.stsd_stst_id=stst.stst_id',array('GROUP_CONCAT(stsd.stsd_value ORDER BY stsm_id) stsd_value'))
->joinInner ( array('plyr'=>'test_team_players'), 'plyr.plyr_id=stsd.stsd_plyr_id',array('plyr.plyr_user_id'))
->where("stsm.stsm_status=1 and sprt.sprt_status=1 and stst.stst_status=1 and stsd.stsd_status =1 and team.team_status=1 and plyr.plyr_status=1 and team.team_id=".$pmTeamID." and stsd.stsd_plyr_id=".$pmPlayerID.$vSortdet)
->group('stst.stst_game_date')
->order('stst.stst_game_date DESC');
$resGamedls = $this->fetchAll($selGamedls);
return $resGamedls;
}
/**
* Function to getTest player's Details
*
* Created: Oct 08, 2011
* @param string $pmTeamID
* @return Array
*/
function getTestPlayerDetails($pmTeamID,$playerID){
$selPlyrdls = $this->select()
->setIntegrityCheck(false)
->from(array('plyr'=>'test_team_players'),array('plyr.plyr_id'))
->joinInner ( array('team'=>'test_team'), 'team.team_id=plyr.plyr_team_id',array('team.team_id','team.team_name'))
->joinInner ( array('users'=>'test_users'), 'users.user_id=plyr.plyr_user_id',array('users.user_fname','users.user_lname'))
->where("plyr.plyr_status=1 and team.team_status=1 and users.user_status=1 and plyr.plyr_id=".$playerID." and team.team_id=".$pmTeamID);
$resPlyrdls = $this->fetchAll($selPlyrdls);
return $resPlyrdls;
}
/**
* Function to getTest player's Details
*
* Created: Oct 08, 2011
* @param string $pmTeamID
* @return Array
*/
function getTestTeamPlayerDetails($pmTeamID){
$selTeamPlyrdls = $this->select()
->setIntegrityCheck(false)
->from(array('plyr'=>'test_team_players'),array('plyr.plyr_id'))
->joinInner ( array('team'=>'test_team'), 'team.team_id=plyr.plyr_team_id',array('team.team_id','team.team_sprt_id'))
->joinInner ( array('users'=>'test_users'), 'users.user_id=plyr.plyr_user_id',array('users.user_fname','users.user_lname'))
->joinInner ( array('router'=>'test_router'),'router.rutr_id=team.team_rutr_id',array('router.rutr_url'))
->where("plyr.plyr_status=1 and team.team_status=1 and users.user_status=1 and team.team_id=".$pmTeamID);
$resTeamPlyrdls = $this->fetchAll($selTeamPlyrdls);
return $resTeamPlyrdls;
}
/**
* Function to getTest statistics Details
*
* Created: Oct 08, 2011
* @param string $pmStstID
* @return Array
*/
function getTestStatisticsDetails($pmStstID){
$selStcsdls = $this->select()
->setIntegrityCheck(false)
->from(array('stst'=>'test_statistics'))
->joinInner ( array('stsd'=>'test_statistics_dtl'), 'stsd.stsd_stst_id=stst.stst_id')
->where("stst.stst_status=1 and stsd.stsd_status=1 and stst.stst_id=".$pmStstID);
$resStcsdls = $this->fetchAll($selStcsdls);
return $resStcsdls;
}
/**
* Function to store statistics Details
*
* Created: Oct 08, 2011
* @param string $parameters
* @return Array
*/
function addStatistics($pmData)
{
//#-- Home Team details
$gameDate=explode("/",$pmData['gameDate']);
$gameDate=$gameDate[2]."-".$gameDate[0]."-".$gameDate[1];
$insHomeDet = array(
"stst_team_id"=>$pmData['teamid'],
"stst_played_team_name"=>$pmData['opponent'],
"stst_game_date"=>$gameDate,
"stst_played_team_type"=>0,
"stst_status"=>1
);
$homelastid = $this->insert($insHomeDet);
$vScoreids = explode(",",$pmData['Plyrscoreid']);
$vScorecnt = count($vScoreids);
$vHomeScores = explode(",",$pmData['plyrscore']);
$oStatisticsDetails = new StatisticsDetail();
for($scloop=0;$scloop<$vScorecnt;$scloop++)
{
if($vScoreids[$scloop] != "")
{
$insHomeScores = array(
"stsd_stsm_id"=>$vScoreids[$scloop],
"stsd_stst_id"=>$homelastid,
"stsd_plyr_id"=>$pmData['playerid'],
"stsd_value"=>$vHomeScores[$scloop],
"stsd_status"=>1
);
$oStatisticsDetails->insert($insHomeScores);
}
}
}
/**
* Function to update statistics Details
*
* Created: Oct 08, 2011
* @param string $parameters
* @return true/false
*/
function updateStatistics($pmData)
{
$gameDate=explode("/",$pmData['gameDate']);
$gameDate=$gameDate[2]."-".$gameDate[0]."-".$gameDate[1];
$UpdateFields = array(
"stst_played_team_name"=>$pmData['opponent'],
"stst_game_date"=>$gameDate
);
$this->update($UpdateFields,array('stst_id= ?'=>$pmData['stst_id']));
$vScoreids = explode(",",$pmData['Plyrscoreid']);
$vScorecnt = count($vScoreids);
$vHomeScores = explode(",",$pmData['plyrscore']);
$oStatisticsDet = new StatisticsDetail();
for($scloop=0;$scloop<$vScorecnt;$scloop++)
{
if($vScoreids[$scloop] != "")
{
$UpdateFields = array("stsd_value"=>$vHomeScores[$scloop]);
$oStatisticsDet->update($UpdateFields,array('stsd_stsm_id= ?'=>$vScoreids[$scloop],'stsd_stst_id= ?'=>$pmData['stst_id']));
}
}
}
/**
* Function to delete statistics Details
*
* Created: Oct 11, 2011
* @param string $parameters
* @return true/false
*/
function deleteStatistics($pmData)
{
$UpdateFields = array("stst_status"=>2);
$this->update($UpdateFields,array('stst_id= ?'=>$pmData['stst_id']));
$oStatisticsDet = new StatisticsDetail();
$UpdateFields = array("stsd_status"=>2);
$oStatisticsDet->update($UpdateFields,array('stsd_stst_id= ?'=>$pmData['stst_id']));
}
/**
* Function to list the opponent Details
*
* Created: Oct 12, 2011
* @param string $parameters
* @return array
*/
function opponentlists($sportID,$teamID,$searchKey)
{
$vSortdet=" and team.team_name LIKE "."'".$searchKey."%'";
$selTeamFields = $this->select()
->setIntegrityCheck(false)
->from(array('team'=>'test_team'),array('team_name'))
->joinInner( array('router'=>'test_router'),'router.rutr_id=team.team_rutr_id',array('rutr_url'))
->where("team.team_id!=".$teamID." and team.team_sprt_id=".$sportID.$vSortdet);
$resTeamFields = $this->fetchAll($selTeamFields);
return $resTeamFields;
}
}
?>
No comments:
Post a Comment