Subversion-Projekte lars-tiefland.ci

Revision

Revision 1850 | Revision 1882 | Zur aktuellen Revision | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

<?php

/**
 *
 * @package WebanOS CI
 * @author Lars Tiefland <ltiefland@gmail.com> 
 * @copyright 2016
 * @version $Rev: 1871 $
 */

/**
 * Auspraegung_model
 * 
 * @package WebanOS CI
 * @author Lars Tiefland
 * @copyright 2016
 * @version $Id: Directory_to_auspraegung_model.php 1871 2016-12-22 16:39:37Z lars $
 * @access public
 */
class Directory_to_auspraegung_model extends CI_Model
{
        /**
         * Auspraegung_model::__construct()
         * 
         * @return
         */
        public function __construct()
        {
                parent::__construct();
        }

        /**
         * Auspraegung_model::get_list()
         * 
         * @return
         */
        public function get_list($dir)
        {
                $sql = "SELECT DISTINCT
                                auspraegung AS id
                        FROM
                                directory_to_auspraegung
                        WHERE
                                directory_id=".$dir."
                ";
                $res = $this->db->query($sql);
                $rows = array();
                while ($row = $res->unbuffered_row('array'))
                {
                        $row = $this->get($row["id"]);
                        $row["wertebereich"] = $this->get_werte($row["id"], $dir, false);
                        $rows[] = $row;
                }
                return $rows;
        }

        public function get($ausp)
        {
                $sql = "SELECT
                                *
                        FROM
                                auspraegung
                        WHERE
                                id=".$ausp."
                ";
                $res = $this->db->query($sql);
                $row = $res->unbuffered_row('array');
                return $row;
        }

        /**
         * Auspraegung_model::get()
         * 
         * @param mixed $id
         * @return
         */
        public function get_werte($id, $father, $vererbung = true)
        {
                if ($vererbung === true)
                {
                        $path = array_reverse(getPath($father, true));
                        $werte = array();
                        foreach ($path as $dir)
                        {
                                $directory = $dir["ID"];
                                $sql = "SELECT
                                                dta.wertebereich
                                        FROM
                                                directory_to_auspraegung dta
                                        WHERE
                                                auspraegung=".$id."
                                        AND
                                                directory=".$directory."
                                ";
                                $res = $this->db->query($sql);
                                while ($row = $res->unbuffered_row('array'))
                                {
                                        $werte[$row["wertebereich"]] = $row["wertebereich"];
                                }
                        }
                }
                else
                {
                        $sql = "SELECT
                                        dta.wertebereich
                                FROM
                                        directory_to_auspraegung dta
                                WHERE
                                        auspraegung=".$id."
                                AND
                                        directory=".$father."
                        ";
                        $res = $this->db->query($sql);
                        while ($row = $res->unbuffered_row('array'))
                        {
                                $werte[$row["wertebereich"]] = $row["wertebereich"];
                        }
                }
                return $werte;
        }
}

?>