<?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.TemporaryElementReference.php 81 2008-01-17 23:08:21Z yannromefort $
*/
//-----------------------------------------------------------------------------
// namespace
if (!defined("DefTemporaryElementReference")) {
//-------------------------------------------------------------------------
// Define
define("DefTemporaryElementReference", "1");
//-------------------------------------------------------------------------
// Include
@require_once (FRAMEWORK_DIR . DATAROWOBJECT);
//-------------------------------------------------------------------------
// Class
class TemporaryElementReference extends DataRow {
//---------------------------------------------------------------------
// Constructor
/**
*
* @param integer TemporaryElementReference $TMPEREFPKID primary key
* @param integer TemporaryElement $TMPELEMPKID foreign key
*
*/
function TemporaryElementReference($TMPEREFPKID = 0, $TMPELEMPKID = 0) {
//
$this->m_tableSet[PRIMARYKEY] = "tbl_temporary_element_reference";
//
$this->m_indexSet[PRIMARYKEY] = "TMPEREFPKID";
$this->m_indexSet[FOREIGNKEY] = "TMPELEMPKID";
//
$this->m_fieldSet["TMPEREFPKID"] = $TMPEREFPKID;
$this->m_fieldSet["TMPELEMPKID"] = $TMPELEMPKID;
}
//---------------------------------------------------------------------
// Methods
/**
*
* @param integer index type
* @return string
*/
function getInsertQuery($indexType = FOREIGNKEY) {
//
$table = $this->m_tableSet[PRIMARYKEY];
//
$insertSQL = "INSERT INTO $table ( ";
$valuesSQL = "VALUES ( ";
// OBJERETPKID ObjectoryElementReferenceType id
$value = $this->m_fieldSet["OBJERETPKID"];
if (!empty($value)) {
$insertSQL.= " OBJERETPKID";
$valuesSQL.= " $value";
} else {
$this->m_errorSet["OBJERETPKID"] = true;
return ("");
}
// TMPELEMLINK TemporaryElement assocation id
$value = $this->m_fieldSet["TMPELEMLINK"];
if (!empty($value)) {
$insertSQL.= " ,TMPELEMLINK";
$valuesSQL.= " ,$value";
} else {
$this->m_errorSet["TMPELEMLINK"] = true;
return ("");
}
// TMPELEMPKID TemporaryElement assocation end id
$value = $this->m_fieldSet["TMPELEMPKID"];
if (!empty($value)) {
$insertSQL.= " ,TMPELEMPKID";
$valuesSQL.= " ,$value";
} else {
$this->m_errorSet["TMPELEMPKID"] = true;
return ("");
}
// TMPELEMRFID TemporaryElement related element id
$value = $this->m_fieldSet["TMPELEMRFID"];
if (!empty($value)) {
$insertSQL.= " ,TMPELEMRFID";
$valuesSQL.= " ,$value";
} else {
$this->m_errorSet["TMPELEMRFID"] = true;
return ("");
}
// TMPEREFDATE TemporaryElementReference creation date
$value = Date("Y-m-d H:i:s");
$insertSQL.= " ,TMPEREFDATE";
$valuesSQL.= " ,\"$value\"";
// TMPEREFSTAT TemporaryElementReference status
$value = 1;
$insertSQL.= " ,TMPEREFSTAT";
$valuesSQL.= " ,$value";
// TMPEREFTYPE TemporaryElementReference type
$value = 1;
$insertSQL.= " ,TMPEREFTYPE";
$valuesSQL.= " ,$value";
//
return ($insertSQL . ") " . $valuesSQL . ")");
}
/**
*
* @param integer index type
* @return string
*/
function getUpdateQuery($indexType = PRIMARYKEY) {
//
$table = $this->m_tableSet[PRIMARYKEY];
//
switch ($indexType) {
case FOREIGNKEY:
//
$field = $this->m_indexSet[FOREIGNKEY];
$index = $this->m_fieldSet["$field"];
if ($index != 0) {
//
$updateSQL = "UPDATE $table SET ";
// TMPELEMRFID TemporaryElement related element
$value = $this->m_fieldSet["TMPELEMRFID"];
if (!empty($value)) $updateSQL.= " TMPELEMRFID=$value";
else {
$this->m_errorSet["TMPELEMRFID"] = true;
return ("");
}
//
return ($updateSQL . " WHERE $field=$index");
}
//
break;
case PRIMARYKEY:
//
$field = $this->m_indexSet[PRIMARYKEY];
$index = $this->m_fieldSet["$field"];
if ($index != 0) {
//
$updateSQL = "UPDATE $table SET ";
// TMPELEMRFID TemporaryElement related element
$value = $this->m_fieldSet["TMPELEMRFID"];
if (!empty($value)) $updateSQL.= " TMPELEMRFID=$value";
else {
$this->m_errorSet["TMPELEMRFID"] = true;
return ("");
}
//
return ($updateSQL . " WHERE $field=$index");
}
//
break;
case DISPLAYKEY:
# index = Pkid
$field = $this->m_indexSet[PRIMARYKEY];
$index = $this->m_fieldSet["$field"];
if ($index != 0) return ("UPDATE $table SET TMPEREFSTAT=0 WHERE $field=$index");
break;
}
//
return ("");
}
/**
*
* @param integer index type
* @return string
*/
function getSelectQuery($indexType = PRIMARYKEY) {
//
switch ($indexType) {
case FOREIGNKEY:
/*
*
* SELECT
* tbl_temporary_element_reference as t1
* <-> tbl_temporary_element as t2
* ON OBJELEMPKID
*
*/
//
$index = $this->m_fieldSet["TMPELEMPKID"];
if ($index != 0) return ("SELECT
t1.TMPEREFPKID,
t1.TMPELEMPKID,
t1.OBJERETPKID,
t1.TMPELEMRFID,
t2.TMPELEMNAME
FROM
tbl_temporary_element_reference as t1,
tbl_temporary_element as t2
WHERE
t1.TMPELEMPKID=$index
AND
t1.TMPEREFSTAT>0
AND
t1.TMPELEMRFID=t2.TMPELEMPKID
AND
t2.TMPELEMSTAT>0");
break;
case PRIMARYKEY:
/*
*
* SELECT
* tbl_temporary_element_reference as t1
* <-> tbl_temporary_element as t2
* ON TMPEREFPKID
*
*/
//
$index = $this->m_fieldSet["TMPEREFPKID"];
if ($index != 0) return ("SELECT
t1.TMPEREFPKID,
t1.TMPELEMPKID,
t1.OBJERETPKID,
t1.TMPELEMRFID,
t2.TMPELEMNAME
FROM
tbl_temporary_element_reference as t1,
tbl_temporary_element as t2
WHERE
t1.TMPEREFPKID=$index
AND
t1.TMPEREFSTAT>0
AND
t1.TMPELEMRFID=t2.TMPELEMPKID
AND
t2.TMPELEMSTAT>0");
break;
}
//
return ("");
}
};
// Class
//-------------------------------------------------------------------------
}
// namespace
//-----------------------------------------------------------------------------
?>