Location: PHPKode > projects > Entier Studio > entierstudio/studio/classes/datas/data.TemporaryElementPropertyValue.php
<?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.TemporaryElementPropertyValue.php 81 2008-01-17 23:08:21Z yannromefort $
 */
//-----------------------------------------------------------------------------
if (!defined("DefTemporaryElementPropertyValue")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefTemporaryElementPropertyValue", "1");
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . DATAROWOBJECT);
    //-------------------------------------------------------------------------
    //	Class
    class TemporaryElementPropertyValue extends DataRow {
        //---------------------------------------------------------------------
        //	Constructor
        
        /**
         *
         * @param	integer	 TemporaryElementPropertyValue	TMPEPROPKID primary key
         */
        function TemporaryElementPropertyValue($TMPEPROPKID = 0) {
            //
            $this->m_tableSet[PRIMARYKEY] = "tbl_temporary_element_property_value";
            //
            $this->m_indexSet[PRIMARYKEY] = "TMPEPROPKID";
            $this->m_indexSet[FOREIGNKEY] = "TMPELEMPKID";
            $this->m_indexSet[NATURALKEY] = "DICPROPNAME";
            //
            $this->m_fieldSet["TMPEPROPKID"] = $TMPEPROPKID;
        }
        //-------------------------------------------------------------------------
        //	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 ( ";
            // TMPELEMPKID ObjectoryElement pkid
            $value = $this->m_fieldSet["TMPELEMPKID"];
            if (!empty($value)) {
                $insertSQL.= "  TMPELEMPKID";
                $valuesSQL.= "  $value";
            } else {
                $this->m_errorSet["TMPELEMPKID"] = 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 ("");
            }
            // TMPEPRODATA TemporaryElementPropertyValue data
            $value = $this->m_fieldSet["TMPEPRODATA"];
            if (!empty($value)) {
                $insertSQL.= " ,TMPEPRODATA";
                $valuesSQL.= " ,\"$value\"";
            }
            // TMPEPRODATE TemporaryElementPropertyValue creation date
            $value = Date("Y-m-d H:i:s");
            $insertSQL.= " ,TMPEPRODATE";
            $valuesSQL.= " ,\"$value\"";
            // TMPEPROSTAT TemporaryElementPropertyValue status
            $value = 1;
            $insertSQL.= " ,TMPEPROSTAT";
            $valuesSQL.= " ,$value";
            // TMPEPROTYPE TemporaryElementPropertyValue type
            $value = $this->m_fieldSet["TMPEPROTYPE"];
            if (!empty($value)) {
                $insertSQL.= " ,TMPEPROTYPE";
                $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["TMPEPRODATA"];
                        $updateSQL.= ",TMPEPRODATA=\"$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 TMPEPROSTAT=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:
                        # index = TMPEPROPKID
                        $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
//-----------------------------------------------------------------------------
?>
Return current item: Entier Studio