Subversion-Projekte lars-tiefland.ci

Revision

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

Revision Autor Zeilennr. Zeile
1811 lars 1
<?php
2
 
3
/**
4
 *
5
 * @package WebanOS CI
6
 * @author Lars Tiefland <ltiefland@gmail.com>
7
 * @copyright 2016
8
 * @version $Rev: 1836 $
9
 */
10
 
11
/**
12
 * Auspraegung_model
13
 *
14
 * @package WebanOS CI
15
 * @author Lars Tiefland
16
 * @copyright 2016
17
 * @version $Id: Artikel_to_auspraegung_model.php 1836 2016-12-21 22:48:38Z lars $
18
 * @access public
19
 */
20
class Artikel_to_auspraegung_model extends CI_Model
21
{
22
	/**
23
	 * Auspraegung_model::__construct()
24
	 *
25
	 * @return
26
	 */
27
	public function __construct()
28
	{
29
		parent::__construct();
1836 lars 30
		$this->load->model('directory_to_auspraegung_model', 'directory_to_auspraegung');
31
		$this->load->model('auspraegung_model', 'auspraegung');
1811 lars 32
	}
33
 
34
	/**
35
	 * Auspraegung_model::get_list()
36
	 *
37
	 * @return
38
	 */
39
	public function get_list($artikel)
40
	{
1836 lars 41
		$sql = "SELECT
42
				father
43
			FROM
44
				artikel
45
			WHERE
46
				id=".$artikel."
47
		";
48
		$res = $this->db->query($sql);
49
		$row = $res->unbuffered_row('array');
50
		$father = $row["father"];
1823 lars 51
		$sql = "SELECT DISTINCT
52
				auspraegung AS id
1811 lars 53
			FROM
54
				artikel_to_auspraegung
1812 lars 55
			WHERE
1815 lars 56
				artikel=".$artikel."
1811 lars 57
		";
58
		$res = $this->db->query($sql);
59
		$rows = array();
60
		while ($row = $res->unbuffered_row('array'))
61
		{
1824 lars 62
			$row = $this->auspraegung->get($row["id"]);
1829 lars 63
			$row["werte"] = $this->get_werte($row["id"], $artikel);
1836 lars 64
			$row["wertebereich"] = $this->directory_to_auspraegung->get_werte($row["id"], $father);
1832 lars 65
			$rows[$row["id"]] = $row;
1811 lars 66
		}
67
		return $rows;
68
	}
69
 
70
	/**
71
	 * Auspraegung_model::get()
72
	 *
73
	 * @param mixed $id
74
	 * @return
75
	 */
1829 lars 76
	private function get_werte($id, $artikel)
1811 lars 77
	{
78
		$sql = "SELECT
1823 lars 79
				ata.wert
1811 lars 80
			FROM
81
				artikel_to_auspraegung ata
82
			WHERE
1824 lars 83
				auspraegung=".$id."
1829 lars 84
			AND
85
				artikel=".$artikel."
1811 lars 86
		";
87
		$res = $this->db->query($sql);
1823 lars 88
		$werte = array();
1824 lars 89
		$werte = array();
1823 lars 90
		while ($row = $res->unbuffered_row('array'))
91
		{
92
			$werte[] = $row["wert"];
93
		}
1824 lars 94
		return $werte;
1811 lars 95
	}
96
}
97
 
98
?>