mysql query just ex:
/*************************************************************************/
SELECT T.* FROM(
SELECT
team_user_id,
user.user_fname,
user.user_lname,
user.user_email
FROM
test_team team
INNER JOIN test_users user ON user.user_id=team_user_id
WHERE
team_id=24 AND team_status=1 AND user_status=1
UNION
SELECT
user.user_id,
user.user_fname,
user.user_lname,
user.user_email
FROM
`test_team` AS `t`
INNER JOIN `test_team_players` AS `tp` ON t.team_id = tp.plyr_team_id
INNER JOIN `test_relationships` rlsp ON rlsp.rlsp_rsty_id = 2
INNER JOIN `test_users` AS `user` ON user.user_id = rlsp.rlsp_relation_user_id
WHERE
(user.user_status=1 and t.team_status=1 and tp.plyr_status=1 and t.team_id=24 and rlsp.rlsp_user_id = tp.plyr_user_id)
)as T order by T.user_lname
/*****************************************************************/
//Zend converted queries will be
/****************************************************************/
$pmSort = 'user_lname DESC';
$qry1=$this->select()
->setIntegrityCheck(false)
->from(array('team'=>'test_team'),array('team_id','team_name','team_sprt_id','team_user_id'))
->joinInner(array('user'=>'test_users'),'user.user_id=team_user_id',array('user_fname','user_lname','user_email'))
->where("team_id='$pmTeamID' and team_status=1 and user_status=1");
$qry2=$this->select()
->setIntegrityCheck(false)
->from(array('t'=>'test_team'),array('team_id'))
->joinInner(array('tp'=>'test_team_players'),'t.team_id = tp.plyr_team_id',array('plyr_id'))
->joinInner(array('rlsp'=>'test_relationships'),'rlsp.rlsp_rsty_id = 2',array('rlsp_id'))
->joinInner(array('user'=>'test_users'),'user.user_id = rlsp.rlsp_relation_user_id',array('user_id','user_fname','user_lname','user_email'))
->where("user.user_status=1 and t.team_status=1 and tp.plyr_status=1 and t.team_id='$pmTeamID' and rlsp.rlsp_user_id = tp.plyr_user_id");
$select = $this->select()
->setIntegrityCheck(false)
->union(array($qry1, $qry2));
$select1 = $this->select()
->setIntegrityCheck(false)
->from(array('T'=> $select ) )
->order($pmSort);
echo $select1;
/************************************************************************/
/*************************************************************************/
SELECT T.* FROM(
SELECT
team_user_id,
user.user_fname,
user.user_lname,
user.user_email
FROM
test_team team
INNER JOIN test_users user ON user.user_id=team_user_id
WHERE
team_id=24 AND team_status=1 AND user_status=1
UNION
SELECT
user.user_id,
user.user_fname,
user.user_lname,
user.user_email
FROM
`test_team` AS `t`
INNER JOIN `test_team_players` AS `tp` ON t.team_id = tp.plyr_team_id
INNER JOIN `test_relationships` rlsp ON rlsp.rlsp_rsty_id = 2
INNER JOIN `test_users` AS `user` ON user.user_id = rlsp.rlsp_relation_user_id
WHERE
(user.user_status=1 and t.team_status=1 and tp.plyr_status=1 and t.team_id=24 and rlsp.rlsp_user_id = tp.plyr_user_id)
)as T order by T.user_lname
/*****************************************************************/
//Zend converted queries will be
/****************************************************************/
$pmSort = 'user_lname DESC';
$qry1=$this->select()
->setIntegrityCheck(false)
->from(array('team'=>'test_team'),array('team_id','team_name','team_sprt_id','team_user_id'))
->joinInner(array('user'=>'test_users'),'user.user_id=team_user_id',array('user_fname','user_lname','user_email'))
->where("team_id='$pmTeamID' and team_status=1 and user_status=1");
$qry2=$this->select()
->setIntegrityCheck(false)
->from(array('t'=>'test_team'),array('team_id'))
->joinInner(array('tp'=>'test_team_players'),'t.team_id = tp.plyr_team_id',array('plyr_id'))
->joinInner(array('rlsp'=>'test_relationships'),'rlsp.rlsp_rsty_id = 2',array('rlsp_id'))
->joinInner(array('user'=>'test_users'),'user.user_id = rlsp.rlsp_relation_user_id',array('user_id','user_fname','user_lname','user_email'))
->where("user.user_status=1 and t.team_status=1 and tp.plyr_status=1 and t.team_id='$pmTeamID' and rlsp.rlsp_user_id = tp.plyr_user_id");
$select = $this->select()
->setIntegrityCheck(false)
->union(array($qry1, $qry2));
$select1 = $this->select()
->setIntegrityCheck(false)
->from(array('T'=> $select ) )
->order($pmSort);
echo $select1;
/************************************************************************/
No comments:
Post a Comment