<?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.TemporaryElementSet.php 81 2008-01-17 23:08:21Z yannromefort $
*/
//-----------------------------------------------------------------------------
// namespace
if (!defined("DefTemporaryElementSet")) {
//-------------------------------------------------------------------------
// Define
define("DefTemporaryElementSet", "1");
//-------------------------------------------------------------------------
// Include
@require_once (FRAMEWORK_DIR . DATASETOBJECT);
//-------------------------------------------------------------------------
// Class
class TemporaryElementSet extends DataSet {
//---------------------------------------------------------------------
// Constructor
/**
*
* @param integer ObjectoryElement $OBJELEMPKID foreign key
* @param integer TemporyElement $TMPELEMLINK reflect key
*
*/
function TemporaryElementSet($OBJELEMPKID = 0, $TMPELEMLINK = 0) {
//
$this->m_tableSet[PRIMARYKEY] = "tbl_temporary_element";
//
$this->m_indexSet[PRIMARYKEY] = "TMPELEMPKID";
$this->m_indexSet[FOREIGNKEY] = "OBJELEMPKID";
$this->m_indexSet[NATURALKEY] = "TMPELEMNAME";
$this->m_indexSet[REFLECTKEY] = "TMPELEMLINK";
//
$this->m_querySet["OBJELEMPKID"] = $OBJELEMPKID;
$this->m_querySet["TMPELEMLINK"] = $TMPELEMLINK;
}
//---------------------------------------------------------------------
// 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_element
* -> tbl_temporary_element_reference
* -> tbl_temporary_element_property_value
* ON
* OBJELEMPKID & TMPEPROPKID
*
*/
//
$field = $this->m_indexSet[FOREIGNKEY];
$index = $this->m_querySet[$field];
if ($index != 0) return ("
DELETE
t1,
t2,
t3
FROM
tbl_temporary_element as t1
LEFT JOIN
tbl_temporary_element_reference as t2
ON
t2.TMPELEMPKID=t1.TMPELEMPKID
LEFT JOIN
tbl_temporary_element_property_value as t3
ON
t3.TMPELEMPKID=t1.TMPELEMPKID
WHERE
t1.OBJELEMPKID=$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_element
* <-> tbl_objectory_element_type
* ON
* OBJELEMPKID
*
*/
//
$index = $this->m_querySet["OBJELEMPKID"];
if ($index != 0) {
//
$selectSQL = "SELECT
t1.*,
t2.OBJETYPNAME,
t2.REPCELTPKID
FROM
tbl_temporary_element as t1,
tbl_objectory_element_type as t2
WHERE
t1.OBJELEMPKID=$index
AND
t1.TMPELEMLINK is NULL
AND
t1.TMPELEMSTAT>0
AND
t1.OBJETYPPKID=t2.OBJETYPPKID";
//
switch ($orderType) {
case PRIMARYKEY:
return ($selectSQL . " ORDER BY t1.TMPELEMPKID $orderMode");
case NATURALKEY:
return ($selectSQL . " ORDER BY t1.TMPELEMCODE $orderMode");
default:
return ($selectSQL . " ORDER BY t1.OBJETYPPKID, t1.TMPELEMRANK, t1.TMPELEMCODE");
}
}
//
break;
case REFLECTKEY:
/*
*
* SELECT
* tbl_temporary_element
* <-> tbl_objectory_element_type
* ON
* TMPELEMLINK
*
*/
//
$index = $this->m_querySet[TMPELEMLINK];
if ($index != 0) {
//
$selectSQL = "SELECT
t1.*,
t2.OBJETYPNAME,
t2.OBJETYPCODE,
t2.REPCELTPKID
FROM
tbl_temporary_element as t1,
tbl_objectory_element_type as t2
WHERE
t1.TMPELEMLINK=$index
AND
t1.TMPELEMSTAT>0
AND
t1.OBJETYPPKID=t2.OBJETYPPKID";
//
switch ($orderType) {
case PRIMARYKEY:
return ($selectSQL . " ORDER BY t1.TMPELEMPKID $orderMode");
case NATURALKEY:
return ($selectSQL . " ORDER BY t1.OBJETYPPKID, t1.TMPELEMCODE $orderMode");
default:
return ($selectSQL . " ORDER BY t1.OBJETYPPKID, t1.TMPELEMRANK, t1.TMPELEMCODE");
}
}
default:
/*
*
* SELECT
* count(tbl_temporary_element)
* ON
* OBJELEMPKID
*
*/
//
$index = $this->m_querySet["OBJELEMPKID"];
if ($index != 0) {
//
return ("SELECT
COUNT(*) as C
FROM
tbl_temporary_element as t1
WHERE
t1.OBJELEMPKID=$index
HAVING
C >0");
}
//
break;
}
//
return ("");
}
};
// Class
//-------------------------------------------------------------------------
}
// namespace
//-----------------------------------------------------------------------------
?>