Location: PHPKode > projects > Entier Studio > entierstudio/studio/classes/datas/data.RepositoryCoreElementProperty.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.RepositoryCoreElementProperty.php 81 2008-01-17 23:08:21Z yannromefort $
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefRepositoryCoreElementProperty")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefRepositoryCoreElementProperty", "1");
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . DATAROWOBJECT);
    @require_once (FRAMEWORK_DIR . "./filters/filter.forminput.php");
    @require_once (FRAMEWORK_DIR . "./validators/validator.identifier.php");
    //-------------------------------------------------------------------------
    //	Class
    class RepositoryCoreElementProperty extends DataRow {
        //---------------------------------------------------------------------
        //	Constructor
        
        /**
         *
         * @param	integer	 RepositoryCoreElementProperty	REPCEPRPKID primary key
         */
        function RepositoryCoreElementProperty($REPCEPRPKID = 0) {
            //
            $this->m_tableSet[PRIMARYKEY] = "tbl_repository_core_element_property";
            //
            $this->m_indexSet[PRIMARYKEY] = "REPCEPRPKID";
            $this->m_indexSet[FOREIGNKEY] = array(
                "REPCELTPKID",
                "DICPROPPKID"
            );
            $this->m_indexSet[NATURALKEY] = "DICPROPNAME";
            //
            $this->m_fieldSet["REPCEPRPKID"] = $REPCEPRPKID;
        }
        //-------------------------------------------------------------------------
        //	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 ( ";
            //	REPCELTPKID RepositoryCoreElementType foreign key
            $value = $this->m_fieldSet["REPCELTPKID"];
            if (!empty($value)) {
                $insertSQL.= "  REPCELTPKID";
                $valuesSQL.= "  $value";
            } else {
                $this->m_errorSet["REPCELTPKID"] = true;
                return ("");
            }
            //	DICPROPPKID DictionaryProperty foreign key
            $value = $this->m_fieldSet["DICPROPPKID"];
            if (!empty($value)) {
                $insertSQL.= " ,DICPROPPKID";
                $valuesSQL.= " ,$value";
            } else {
                $this->m_errorSet["DICPROPPKID"] = true;
                return ("");
            }
            //	REPCEPRTEXT = RepositoryCoreElementProperty description
            $value = FilterFormInput::filter($this->m_fieldSet["REPCEPRTEXT"], true);
            if (!empty($value)) {
                $insertSQL.= " ,REPCEPRTEXT";
                $valuesSQL.= " ,$value";
            }
            //	REPCEPRDATE = RepositoryCoreElementProperty creation date
            $value = Date("Y-m-d H:i:s");
            $insertSQL.= " ,REPCEPRDATE";
            $valuesSQL.= " ,\"$value\"";
            //	REPCEPRSTAT = RepositoryCoreElementProperty status
            $value = 1;
            $insertSQL.= " ,REPCEPRSTAT";
            $valuesSQL.= " ,$value";
            //	REPCEPRTYPE = RepositoryCoreElementProperty type
            $value = $this->m_fieldSet["REPCEPRTYPE"];
            if (!empty($value)) {
                $insertSQL.= " ,REPCEPRTYPE";
                $valuesSQL.= " ,$value";
            } else {
                $this->m_errorSet["REPCEPRTYPE"] = true;
                return ("");
            }
            //
            return ($insertSQL . ") " . $valuesSQL . ")");
        }
        /**
         *
         * @param	integer	 index type
         * @return	string
         */
        function getUpdateQuery($indexType = PRIMARYKEY) {
            //
            $table = $this->m_tableSet[PRIMARYKEY];
            //
            switch ($indexType) {
                case PRIMARYKEY:
                    /*
                    *	UPDATE
                    *			tbl_repository_core_element_property
                    *	ON
                    *			REPCEPRPKID
                    *
                    */
                    //
                    $field = $this->m_indexSet[PRIMARYKEY];
                    $index = $this->m_fieldSet["$field"];
                    if ($index != 0) {
                        //
                        $updateSQL = "UPDATE $table SET ";
                        //	REPCEPRTEXT = RepositoryCoreElementProperty description
                        $value = FilterFormInput::filter($this->m_fieldSet["REPCEPRTEXT"], true);
                        $updateSQL.= " REPCEPRTEXT=$value";
                        //	REPCEPRSTAT = RepositoryCoreElementProperty status
                        $value = $this->m_fieldSet["REPCEPRSTAT"];
                        $updateSQL.= ",REPCEPRSTAT=$value";
                        //	REPCEPRTYPE = RepositoryCoreElementProperty type
                        $value = $this->m_fieldSet["REPCEPRTYPE"];
                        if (!empty($value)) $updateSQL.= ",REPCEPRTYPE=$value";
                        //
                        return ($updateSQL . " WHERE $field=$index");
                    }
                    break;
                case DISPLAYKEY:
                    /*
                    *	UPDATE
                    *			tbl_repository_core_element_property
                    *	SET
                    *			REPCELTPKID= -REPCEPRPKID
                    *			REPCEPRSTAT=0
                    *	ON
                    *			REPCEPRPKID
                    *
                    */
                    //
                    $field = $this->m_indexSet[PRIMARYKEY];
                    $index = $this->m_fieldSet["$field"];
                    if ($index != 0) return ("UPDATE $table 
								SET 
									REPCELTPKID= -REPCEPRPKID, 
									REPCEPRSTAT=0 
								WHERE 
									$field=$index 
								AND 
									REPCEPRSTAT=1");
                    break;
                }
                //
                return ("");
            }
            /**
             *
             * @param	integer	 index type
             * @return	string
             */
            function getSelectQuery($indexType = PRIMARYKEY) {
                //
                switch ($indexType) {
                    case PRIMARYKEY:
                        /*
                        *	SELECT
                        *				tbl_repository_core_element_property as t1
                        *			<-> tbl_repository_core_element_type as t2
                        *			<-> tbl_dictionary_property as t3
                        *	ON
                        *			REPMEPRPKID
                        *
                        */
                        //
                        $index = $this->m_fieldSet["REPCEPRPKID"];
                        if ($index != 0) return ("SELECT 
									t1.*, 
									t2.REPCELTNAME, 
									t2.REPCELTCODE, 
									t3.DICPROPNAME,
									t3.DICPROPCODE
								FROM 
									tbl_repository_core_element_property as t1, 
									tbl_repository_core_element_type as t2, 
									tbl_dictionary_property as t3 
								WHERE 
									t1.REPCEPRPKID=$index 
								AND	
									t1.REPCELTPKID=t2.REPCELTPKID 
								AND 
									t1.DICPROPPKID=t3.DICPROPPKID 
								AND 
									t3.DICPROPSTAT>0");
                        //
                        break;
                    case FOREIGNKEY:
                        /*
                        *	SELECT
                        *				tbl_repository_core_element_property as t1
                        *	ON
                        *			REPCELTPKID & DICPROPPKID
                        *
                        */
                        //
                        $index1 = $this->m_fieldSet["REPCELTPKID"];
                        $index2 = $this->m_fieldSet["DICPROPPKID"];
                        if (($index1 != 0) && ($index2 != 0)) return ("SELECT 
									t1.* 
								FROM 
									tbl_repository_core_element_property as t1 
								WHERE 
									t1.REPCELTPKID=$index1
								AND 
									t1.DICPROPPKID=$index2 
								AND 
									t1.REPCEPRSTAT>0");
                        //
                        break;
                    }
                    //
                    return ("");
                }
        };
        //	Class
        //-------------------------------------------------------------------------
        
    }
    //	namespace
    //-----------------------------------------------------------------------------
    
?>
Return current item: Entier Studio