-
Notifications
You must be signed in to change notification settings - Fork 0
/
CleanCodeModelDAO.php
52 lines (43 loc) · 1.17 KB
/
CleanCodeModelDAO.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
require_once 'CleanCodeModel.php';
class CleanCodeModelDAO extends CleanCodeModel
{
protected static $table = '(mytable)';
protected $data = array();
public static function getTable($alias = '')
{
return $alias? static::$table . ' ' . $alias : static::$table;
}
protected function get_column($name, $default = '')
{
return self::searchPos($this->data, $name, $default);
}
protected function set_column($name, $value, $regex, $min = 1, $max = '')
{
if($this->validateData($value, $regex, $min, $max))
{
$this->data[$name] = $this->formatValue($value, $regex);
}
else if($this->checkErrors())
{
$this->setErrorByField($name);
}
}
protected function loadData($bdData)
{
$this->data = is_array($bdData)? $bdData : array();
}
public function isLoaded()
{
return $this->data && count($this->data);
}
public function toArray()
{
return $this->data;
}
protected static function sql($alias = '')
{
return new CleanCodeSQL(self::getTable($alias));
}
}
?>