Subversion-Projekte lars-tiefland.ci

Revision

Revision 1874 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1813 lars 1
<?php
2
 
3
/**
4
 *
5
 * @package WebanOS CI
6
 * @author Lars Tiefland <ltiefland@gmail.com>
7
 * @copyright 2016
8
 * @version $Rev: 1882 $
9
 */
10
 
11
/**
12
 * Auspraegung_model
13
 *
14
 * @package WebanOS CI
15
 * @author Lars Tiefland
16
 * @copyright 2016
17
 * @version $Id: Directory_to_auspraegung_model.php 1882 2016-12-22 18:16:27Z lars $
18
 * @access public
19
 */
20
class Directory_to_auspraegung_model extends CI_Model
21
{
22
	/**
23
	 * Auspraegung_model::__construct()
24
	 *
25
	 * @return
26
	 */
27
	public function __construct()
28
	{
29
		parent::__construct();
1882 lars 30
		$this->load->model('auspraegung_model','auspraegung');
1813 lars 31
	}
32
 
33
	/**
34
	 * Auspraegung_model::get_list()
35
	 *
36
	 * @return
37
	 */
38
	public function get_list($dir)
39
	{
1836 lars 40
		$sql = "SELECT DISTINCT
41
				auspraegung AS id
1813 lars 42
			FROM
43
				directory_to_auspraegung
44
			WHERE
1874 lars 45
				directory=".$dir."
1813 lars 46
		";
47
		$res = $this->db->query($sql);
48
		$rows = array();
49
		while ($row = $res->unbuffered_row('array'))
50
		{
1882 lars 51
			$row = $this->auspraegung->get($row["id"]);
1871 lars 52
			$row["wertebereich"] = $this->get_werte($row["id"], $dir, false);
1813 lars 53
			$rows[] = $row;
54
		}
55
		return $rows;
56
	}
57
 
1836 lars 58
	/**
59
	 * Auspraegung_model::get()
60
	 *
61
	 * @param mixed $id
62
	 * @return
63
	 */
1871 lars 64
	public function get_werte($id, $father, $vererbung = true)
1836 lars 65
	{
1871 lars 66
		if ($vererbung === true)
1836 lars 67
		{
1871 lars 68
			$path = array_reverse(getPath($father, true));
69
			$werte = array();
70
			foreach ($path as $dir)
71
			{
72
				$directory = $dir["ID"];
73
				$sql = "SELECT
74
						dta.wertebereich
75
					FROM
76
						directory_to_auspraegung dta
77
					WHERE
78
						auspraegung=".$id."
79
					AND
80
						directory=".$directory."
81
				";
82
				$res = $this->db->query($sql);
83
				while ($row = $res->unbuffered_row('array'))
84
				{
85
					$werte[$row["wertebereich"]] = $row["wertebereich"];
86
				}
87
			}
88
		}
89
		else
90
		{
1836 lars 91
			$sql = "SELECT
92
					dta.wertebereich
93
				FROM
94
					directory_to_auspraegung dta
95
				WHERE
96
					auspraegung=".$id."
97
				AND
1871 lars 98
					directory=".$father."
1836 lars 99
			";
100
			$res = $this->db->query($sql);
101
			while ($row = $res->unbuffered_row('array'))
102
			{
1850 lars 103
				$werte[$row["wertebereich"]] = $row["wertebereich"];
1836 lars 104
			}
105
		}
106
		return $werte;
107
	}
1813 lars 108
}
109
 
110
?>