<?php
/**
* Entier Studio
*
* LICENSE
*
* Copyright 2006 Entier Studio team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @package entier.studio
* @copyright Copyright (c) 2006 Entier Studio team. All rights reserved.
* @version $Id: data.TemporaryComponentSet.php 94 2008-02-03 23:35:48Z yannromefort $
*/
//-----------------------------------------------------------------------------
// namespace
if (!defined("DefTemporaryComponentSet")) {
//-------------------------------------------------------------------------
// Define
define("DefTemporaryComponentSet", "1");
//-------------------------------------------------------------------------
// Include
@require_once (FRAMEWORK_DIR . DATASETOBJECT);
//-------------------------------------------------------------------------
// Class
class TemporaryComponentSet extends DataSet {
//---------------------------------------------------------------------
// Constructor
/**
*
* @param integer ObjectoryComponent $OBJCOMPPKID foreign key
* @param integer TemporyComponent $TMPCOMPLINK reflect key
*
*/
function TemporaryComponentSet($OBJCOMPPKID = 0, $TMPCOMPLINK = 0) {
//
$this->m_tableSet[PRIMARYKEY] = "tbl_temporary_component";
//
$this->m_indexSet[PRIMARYKEY] = "TMPCOMPPKID";
$this->m_indexSet[FOREIGNKEY] = "OBJCOMPPKID";
$this->m_indexSet[NATURALKEY] = "TMPCOMPNAME";
$this->m_indexSet[REFLECTKEY] = "TMPCOMPLINK";
//
$this->m_querySet["OBJCOMPPKID"] = $OBJCOMPPKID;
$this->m_querySet["TMPCOMPLINK"] = $TMPCOMPLINK;
}
//---------------------------------------------------------------------
// Methods
/**
*
* @access protected
*
* @param integer Index Type
* @return string SQL query
*
*/
function getDeleteQuery($indexType = FOREIGNKEY) {
//
$table = $this->m_tableSet[PRIMARYKEY];
//
switch ($indexType) {
case FOREIGNKEY:
/*
*
* DELETE
* tbl_temporary_component
* ON
* OBJCOMPPKID
*
*/
//
$field = $this->m_indexSet[FOREIGNKEY];
$index = $this->m_querySet[$field];
if ($index != 0) return ("
DELETE
t1,
t2
FROM
tbl_temporary_component as t1
LEFT JOIN
tbl_temporary_component_template as t2
ON
t2.TMPCOMPPKID=t1.TMPCOMPPKID
WHERE
t1.OBJCOMPPKID=$index");
//
break;
}
//
return ("");
}
/*
*
* @access protected
*
* @param integer index type
* @param integer order type
* @param string order mode
*
*/
function getSelectQuery($indexType = FOREIGNKEY, $orderType = NATURALKEY, $orderMode = "") {
//
switch ($indexType) {
case FOREIGNKEY:
/*
*
* SELECT
* tbl_temporary_component
* <-> tbl_objectory_component_type
* ON
* OBJCOMPPKID
*
*/
//
$index = $this->m_querySet["OBJCOMPPKID"];
if ($index != 0) {
//
$selectSQL = "SELECT
t1.*,
t2.OBJCTYPNAME,
t2.REPCCOTPKID,
t2.OBJCTYPTYPE
FROM
tbl_temporary_component as t1,
tbl_objectory_component_type as t2
WHERE
t1.OBJCOMPPKID=$index
AND
t1.TMPCOMPLINK is NULL
AND
t1.TMPCOMPSTAT>0
AND
t1.OBJCTYPPKID=t2.OBJCTYPPKID";
//
switch ($orderType) {
case PRIMARYKEY:
return ($selectSQL . " ORDER BY t1.TMPCOMPPKID $orderMode");
case NATURALKEY:
return ($selectSQL . " ORDER BY t1.TMPCOMPNAME $orderMode");
default:
return ($selectSQL . " ORDER BY t1.OBJCTYPPKID, t1.TMPCOMPNAME");
}
}
//
break;
case REFLECTKEY:
/*
*
* SELECT
* tbl_temporary_component
* <-> tbl_objectory_component_type
* ON TMPCOMPLINK
*
*/
//
$index = $this->m_querySet["TMPCOMPLINK"];
if ($index != 0) {
//
$selectSQL = "SELECT
t1.*,
t2.OBJCTYPNAME,
t2.REPCCOTPKID,
t2.OBJCTYPTYPE
FROM
tbl_temporary_component as t1,
tbl_objectory_component_type as t2
WHERE
t1.TMPCOMPLINK=$index
AND
t1.TMPCOMPSTAT>0
AND
t1.OBJCTYPPKID=t2.OBJCTYPPKID";
//
switch ($orderType) {
case PRIMARYKEY:
return ($selectSQL . " ORDER BY t1.TMPCOMPPKID $orderMode");
case NATURALKEY:
return ($selectSQL . " ORDER BY t1.OBJCTYPPKID, t1.TMPCOMPNAME $orderMode");
default:
return ($selectSQL . " ORDER BY t1.OBJCTYPPKID, t1.TMPCOMPNAME");
}
}
//
break;
default:
/*
*
* SELECT
* count(tbl_temporary_component)
* ON
* OBJELEMPKID
*
*/
//
$index = $this->m_querySet["OBJCOMPPKID"];
if ($index != 0) {
//
return ("SELECT
COUNT(*) as C
FROM
tbl_temporary_component as t1
WHERE
t1.OBJCOMPPKID=$index
HAVING
C >0");
}
//
break;
}
//
return ("");
}
};
// Class
//-------------------------------------------------------------------------
}
// namespace
//-----------------------------------------------------------------------------
?>