Subversion-Projekte lars-tiefland.ci

Revision

Revision 1855 | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

<?php

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

/**
 * Auspraegung_model
 * 
 * @package WebanOS CI
 * @author Lars Tiefland
 * @copyright 2016
 * @version $Id: Artikel_to_auspraegung_model.php 2241 2017-12-24 22:46:36Z lars $
 * @access public
 */
class Artikel_to_auspraegung_model extends CI_Model
{
        /**
         * Auspraegung_model::__construct()
         * 
         * @return
         */
        public function __construct()
        {
                parent::__construct();
                $this->load->model('directory_to_auspraegung_model', 'directory_to_auspraegung');
                $this->load->model('auspraegung_model', 'auspraegung');
        }

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

        /**
         * Auspraegung_model::get()
         * 
         * @param mixed $id
         * @return
         */
        private function get_werte($id, $artikel)
        {
                $sql = "SELECT
                                ata.wert
                        FROM
                                artikel_to_auspraegung ata
                        WHERE
                                auspraegung=".$id."
                        AND
                                artikel=".$artikel."
                ";
                $res = $this->db->query($sql);
                $werte = array();
                $werte = array();
                while ($row = $res->unbuffered_row('array'))
                {
                        $werte[] = $row["wert"];
                }
                return $werte;
        }
}

?>