Location: PHPKode > projects > Entier Studio > entierstudio/studio/classes/datas/data.RepositoryCoreComponent.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.RepositoryCoreComponent.php 81 2008-01-17 23:08:21Z yannromefort $
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefRepositoryCoreComponent")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefRepositoryCoreComponent", "1");
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . DATAROWOBJECT);
    @require_once (FRAMEWORK_DIR . "./filters/filter.forminput.php");
    @require_once (FRAMEWORK_DIR . "./validators/validator.locator.php");
    @require_once (FRAMEWORK_DIR . "./validators/validator.identifier.php");
    //-------------------------------------------------------------------------
    //	Class
    class RepositoryCoreComponent extends DataRow {
        //---------------------------------------------------------------------
        //	Constructor
        
        /**
         *
         * @param	integer	 pkid	REPCCOMPKID Repository core component		//	primary key
         *
         */
        function RepositoryCoreComponent($REPCCOMPKID = 0) {
            //
            $this->m_tableSet[PRIMARYKEY] = "tbl_repository_core_component";
            //
            $this->m_indexSet[PRIMARYKEY] = "REPCCOMPKID";
            $this->m_indexSet[FOREIGNKEY] = "REPCCOTPKID";
            $this->m_indexSet[NATURALKEY] = "REPCCOMNAME";
            //
            $this->m_fieldSet["REPCCOMPKID"] = $REPCCOMPKID;
        }
        //---------------------------------------------------------------------
        //	Methods
        
        /**
         *
         * @param	integer	 index type
         * @return	string
         */
        /**
         *
         * @param	integer	 index type
         * @return	string
         */
        function getInsertQuery($indexType = FOREIGNKEY) {
            //
            $table = $this->m_tableSet[PRIMARYKEY];
            //
            $insertSQL = "INSERT INTO $table ( ";
            $valuesSQL = "VALUES ( ";
            //	REPOSITPKID = Repository pkid (foreign key)
            $value = $this->m_fieldSet["REPOSITPKID"];
            if (!empty($value)) {
                $insertSQL.= "  REPOSITPKID";
                $valuesSQL.= "  $value";
            } else {
                $this->m_errorSet["REPOSITPKID"] = true;
                return ("");
            }
            //	REPCCOTPKID = RepositoryCoreComponentType pkid (foreign key)
            $value = $this->m_fieldSet["REPCCOTPKID"];
            if (!empty($value)) {
                $insertSQL.= " ,REPCCOTPKID";
                $valuesSQL.= " ,$value";
            } else {
                $this->m_errorSet["REPCCOTPKID"] = true;
                return ("");
            }
            //	REPCCOMNAME = RepositoryCoreComponent name
            $value = FilterFormInput::filter($this->m_fieldSet["REPCCOMNAME"]);
            if (!empty($value)) {
                $insertSQL.= " ,REPCCOMNAME";
                $valuesSQL.= " ,$value";
            } else {
                $this->m_errorSet["REPCCOMNAME"] = true;
                return ("");
            }
            //	REPCCOMTEXT = RepositoryCoreComponent description
            $value = FilterFormInput::filter($this->m_fieldSet["REPCCOMTEXT"], true);
            if (!empty($value)) {
                $insertSQL.= " ,REPCCOMTEXT";
                $valuesSQL.= " ,$value";
            }
            //	REPCCOMDATE = RepositoryCoreComponent creation date
            $value = Date("Y-m-d H:i:s");
            $insertSQL.= " ,REPCCOMDATE";
            $valuesSQL.= " ,\"$value\"";
            //	REPCCOMSTAT = RepositoryCoreComponent status
            $value = 1;
            $insertSQL.= " ,REPCCOMSTAT";
            $valuesSQL.= " ,$value";
            //	REPCCOMTYPE = RepositoryCoreComponent type
            $value = $this->m_fieldSet["REPCCOMTYPE"];
            if (!empty($value)) {
                $insertSQL.= " ,REPCCOMTYPE";
                $valuesSQL.= " ,$value";
            }
            //
            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_component
                    *	ON
                    *			REPCCOMPKID
                    *
                    */
                    //
                    $field = $this->m_indexSet[PRIMARYKEY];
                    $index = $this->m_fieldSet["$field"];
                    if ($index != 0) {
                        //
                        $updateSQL = "UPDATE $table SET ";
                        //	REPCCOMNAME = RepositoryCoreComponent name
                        $value = FilterFormInput::filter($this->m_fieldSet["REPCCOMNAME"]);
                        if (!empty($value)) $updateSQL.= " REPCCOMNAME=$value";
                        else {
                            $this->m_errorSet["REPCCOMNAME"] = true;
                            return ("");
                        }
                        //	REPCCOMTEXT = RepositoryCoreComponent description
                        $value = FilterFormInput::filter($this->m_fieldSet["REPCCOMTEXT"], true);
                        $updateSQL.= ",REPCCOMTEXT=$value";
                        //	REPCCOMSTAT = RepositoryCoreComponent status
                        $value = $this->m_fieldSet["REPCCOMSTAT"];
                        $updateSQL.= ",REPCCOMSTAT=$value";
                        //
                        return ($updateSQL . " WHERE $field=$index");
                    }
                    break;
                case DISPLAYKEY:
                    /*
                    *	UPDATE
                    *			tbl_repository_core_component
                    *	SET
                    *			REPCCOMNAME='~REPCCOMNAME'
                    *			REPCCOMSTAT=0
                    *	ON
                    *			REPCCOMPKID
                    *
                    */
                    //
                    $field = $this->m_indexSet[PRIMARYKEY];
                    $index = $this->m_fieldSet["$field"];
                    if ($index != 0) return ("UPDATE 
									$table 
								SET
									REPCCOMNAME= CONCAT('~', REPCCOMNAME, '$index' ),
									REPCCOMSTAT=0 
								WHERE 
									$field=$index 
								AND 
									REPCCOMSTAT=1");
                    //
                    break;
                }
                //
                return ("");
            }
            /**
             *
             * @param	integer	 index type
             * @return	string
             */
            function getSelectQuery($indexType = PRIMARYKEY) {
                //
                switch ($indexType) {
                    case PRIMARYKEY:
                        /*
                        *
                        *	SELECT
                        *			tbl_repository_core_component		as t1
                        *		<-> tbl_repository_core_component_type	as t2
                        *	ON
                        *			REPCCOMPKID
                        *
                        */
                        //
                        $index = $this->m_fieldSet["REPCCOMPKID"];
                        if ($index != 0) return ("SELECT
									t1.*,
									t2.REPCCOTNAME,
									t2.REPCCOTTYPE
								FROM
									tbl_repository_core_component as t1,
									tbl_repository_core_component_type as t2
								WHERE
									t1.REPCCOMPKID=$index
								AND 
									REPCCOMSTAT>0
								AND
									t1.REPCCOTPKID=t2.REPCCOTPKID");
                        //
                        break;
                    }
                    //
                    return ("");
            }
        };
        //	Class
        //-------------------------------------------------------------------------
        
}
//	namespace
//-----------------------------------------------------------------------------
?>
Return current item: Entier Studio