-
Notifications
You must be signed in to change notification settings - Fork 0
/
Model.php
44 lines (39 loc) · 1.17 KB
/
Model.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
<?php namespace Devtools;
abstract class Model
{
protected $connection;
public abstract function get($key, $collection);
public abstract function getAll($collection);
public abstract function set($key, $value, $collection);
public abstract function query($queryString);
/* public abstract function connect($options); */
protected function reduceResult($result)
{
if (is_array($result) && (count($result) == 1)) {
reset($result);
return $this->reduceResult($result[key($result)]);
} else {
return $result;
}
}
public static function stringify($array, $force = false, $quotation="'")
{
$ret = "";
if (!is_array($array)) {
$array = array($array);
}
foreach ($array as $element) {
if (!empty($ret)) {
$ret .= ",";
}
$ret .= (!$force && is_numeric($element))
? $element
: $quotation.$element.$quotation;
}
return $ret;
}
protected function stripWhitespace($dirty)
{
return preg_replace("/[ \\t\\n]+/u", " ", $dirty);
}
}