Subversion-Projekte lars-tiefland.ci

Revision

Revision 1850 | 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: 1871 $
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 1871 2016-12-22 16:39:37Z 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();
30
	}
31
 
32
	/**
33
	 * Auspraegung_model::get_list()
34
	 *
35
	 * @return
36
	 */
37
	public function get_list($dir)
38
	{
1836 lars 39
		$sql = "SELECT DISTINCT
40
				auspraegung AS id
1813 lars 41
			FROM
42
				directory_to_auspraegung
43
			WHERE
44
				directory_id=".$dir."
45
		";
46
		$res = $this->db->query($sql);
47
		$rows = array();
48
		while ($row = $res->unbuffered_row('array'))
49
		{
50
			$row = $this->get($row["id"]);
1871 lars 51
			$row["wertebereich"] = $this->get_werte($row["id"], $dir, false);
1813 lars 52
			$rows[] = $row;
53
		}
54
		return $rows;
55
	}
56
 
1836 lars 57
	public function get($ausp)
1813 lars 58
	{
59
		$sql = "SELECT
1836 lars 60
				*
1813 lars 61
			FROM
1836 lars 62
				auspraegung
1813 lars 63
			WHERE
1836 lars 64
				id=".$ausp."
1813 lars 65
		";
66
		$res = $this->db->query($sql);
1836 lars 67
		$row = $res->unbuffered_row('array');
1813 lars 68
		return $row;
69
	}
1836 lars 70
 
71
	/**
72
	 * Auspraegung_model::get()
73
	 *
74
	 * @param mixed $id
75
	 * @return
76
	 */
1871 lars 77
	public function get_werte($id, $father, $vererbung = true)
1836 lars 78
	{
1871 lars 79
		if ($vererbung === true)
1836 lars 80
		{
1871 lars 81
			$path = array_reverse(getPath($father, true));
82
			$werte = array();
83
			foreach ($path as $dir)
84
			{
85
				$directory = $dir["ID"];
86
				$sql = "SELECT
87
						dta.wertebereich
88
					FROM
89
						directory_to_auspraegung dta
90
					WHERE
91
						auspraegung=".$id."
92
					AND
93
						directory=".$directory."
94
				";
95
				$res = $this->db->query($sql);
96
				while ($row = $res->unbuffered_row('array'))
97
				{
98
					$werte[$row["wertebereich"]] = $row["wertebereich"];
99
				}
100
			}
101
		}
102
		else
103
		{
1836 lars 104
			$sql = "SELECT
105
					dta.wertebereich
106
				FROM
107
					directory_to_auspraegung dta
108
				WHERE
109
					auspraegung=".$id."
110
				AND
1871 lars 111
					directory=".$father."
1836 lars 112
			";
113
			$res = $this->db->query($sql);
114
			while ($row = $res->unbuffered_row('array'))
115
			{
1850 lars 116
				$werte[$row["wertebereich"]] = $row["wertebereich"];
1836 lars 117
			}
118
		}
119
		return $werte;
120
	}
1813 lars 121
}
122
 
123
?>