<?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.ObjectoryElementPropertyValue.php 81 2008-01-17 23:08:21Z yannromefort $
*/
//-----------------------------------------------------------------------------
if (!defined("DefObjectoryElementPropertyValue")) {
//-------------------------------------------------------------------------
// Define
define("DefObjectoryElementPropertyValue", "1");
//-------------------------------------------------------------------------
// Include
@require_once (FRAMEWORK_DIR . DATAROWOBJECT);
//-------------------------------------------------------------------------
// Class
class ObjectoryElementPropertyValue extends DataRow {
//---------------------------------------------------------------------
// Constructor
/**
*
* @param integer ObjectoryElementPropertyValue OBJEPROPKID primary key
*/
function ObjectoryElementPropertyValue($OBJEPROPKID = 0) {
//
$this->m_tableSet[PRIMARYKEY] = "tbl_objectory_element_property_value";
//
$this->m_indexSet[PRIMARYKEY] = "OBJEPROPKID";
$this->m_indexSet[FOREIGNKEY] = "OBJELEMPKID";
$this->m_indexSet[NATURALKEY] = "DICPROPNAME";
//
$this->m_fieldSet["OBJEPROPKID"] = $OBJEPROPKID;
}
//-------------------------------------------------------------------------
// Methods
/**
*
* @param integer index type
* @param integer order type
* @param integer order mode
* @return string
*/
function getInsertQuery($indexType = FOREIGNKEY) {
//
$table = $this->m_tableSet[PRIMARYKEY];
//
$insertSQL = "INSERT INTO $table ( ";
$valuesSQL = "VALUES ( ";
// OBJELEMPKID ObjectoryElement pkid
$value = $this->m_fieldSet["OBJELEMPKID"];
if (!empty($value)) {
$insertSQL.= " OBJELEMPKID";
$valuesSQL.= " $value";
} else {
$this->m_errorSet["OBJELEMPKID"] = true;
return ("");
}
// DICPROPPKID DictionaryProperty pkid
$value = $this->m_fieldSet["DICPROPPKID"];
if (!empty($value)) {
$insertSQL.= " ,DICPROPPKID";
$valuesSQL.= " ,$value";
} else {
$this->m_errorSet["DICPROPPKID"] = true;
return ("");
}
// DICPVALPKID DictionaryPropertyValue pkid
$value = $this->m_fieldSet["DICPVALPKID"];
if (!empty($value)) {
$insertSQL.= " ,DICPVALPKID";
$valuesSQL.= " ,$value";
} else {
$this->m_errorSet["DICPTYPPKID"] = true;
return ("");
}
// OBJEPRODATA ObjectoryElementPropertyValue data
$value = $this->m_fieldSet["OBJEPRODATA"];
if (!empty($value)) {
$insertSQL.= " ,OBJEPRODATA";
$valuesSQL.= " ,\"$value\"";
}
// OBJEPRODATE ObjectoryElementPropertyValue creation date
$value = Date("Y-m-d H:i:s");
$insertSQL.= " ,OBJEPRODATE";
$valuesSQL.= " ,\"$value\"";
// OBJEPROSTAT ObjectoryElementPropertyValue status
$value = 1;
$insertSQL.= " ,OBJEPROSTAT";
$valuesSQL.= " ,$value";
// OBJEPROTYPE ObjectoryElementPropertyValue type
$value = $this->m_fieldSet["OBJEPROTYPE"];
if (!empty($value)) {
$insertSQL.= " ,OBJEPROTYPE";
$valuesSQL.= " ,$value";
}
//
return ($insertSQL . ") " . $valuesSQL . ")");
}
/**
*
* @param integer index type
* @return string
*/
function getUpdateQuery($indexType = PRIMARYKEY) {
//
$table = $this->m_tableSet[PRIMARYKEY];
//
switch ($indexType) {
case PRIMARYKEY:
# index = Pkid
$field = $this->m_indexSet[PRIMARYKEY];
$index = $this->m_fieldSet["$field"];
if ($index != 0) {
//
$updateSQL = "UPDATE $table SET ";
//
$value = $this->m_fieldSet["DICPROPPKID"];
if (!empty($value)) $updateSQL.= " DICPROPPKID=$value";
else {
$this->m_errorSet["DICPROPPKID"] = true;
return ("");
}
//
$value = $this->m_fieldSet["OBJEPRODATA"];
$updateSQL.= ",OBJEPRODATA=\"$value\"";
//
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 OBJEPROSTAT=0 WHERE $field=$index");
break;
}
//
return ("");
}
/**
*
* @param integer index type
* @return string
*/
function getSelectQuery($indexType = PRIMARYKEY) {
//
$table = $this->m_tableSet[PRIMARYKEY];
//
switch ($indexType) {
case PRIMARYKEY:
/*
*
* SELECT
* tbl_objectory_element_property_value
* ON
* OBJEPROPKID
*
*/
//
$field = $this->m_indexSet["$indexType"];
$index = $this->m_fieldSet["$field"];
if ($index != 0) return ("SELECT t1.* FROM $table as t1 WHERE t1.$field=$index");
break;
}
//
return ("");
}
};
// Class
//-------------------------------------------------------------------------
}
// namespace
//-----------------------------------------------------------------------------
?>