@@ -18,85 +18,85 @@ |
||
18 | 18 | public $filterTypes = null; |
19 | 19 | |
20 | 20 | |
21 | - public function start($queryText = false) { |
|
22 | - if (!$this->checkEnabled()) { |
|
23 | - return; |
|
24 | - } |
|
25 | - |
|
26 | - // make sure we have a query type |
|
27 | - switch (strtolower(substr($queryText, 0, 6))) { |
|
28 | - case 'insert': |
|
29 | - $queryType = 'INSERT'; |
|
30 | - break; |
|
31 | - |
|
32 | - case 'update': |
|
33 | - $queryType = 'UPDATE'; |
|
34 | - break; |
|
35 | - |
|
36 | - case 'delete': |
|
37 | - $queryType = 'DELETE'; |
|
38 | - break; |
|
39 | - |
|
40 | - case 'select': |
|
41 | - $queryType = 'SELECT'; |
|
42 | - break; |
|
43 | - |
|
44 | - default: |
|
45 | - $queryType = 'QUERY'; |
|
46 | - break; |
|
47 | - } |
|
48 | - |
|
49 | - $this->profiles[] = new Nip_DB_Profiler_Query($queryText, $queryType); |
|
50 | - |
|
51 | - $profileID = $this->lastProcessID(); |
|
52 | - $this->addRunningProces($profileID); |
|
53 | - return $profileID; |
|
54 | - } |
|
21 | + public function start($queryText = false) { |
|
22 | + if (!$this->checkEnabled()) { |
|
23 | + return; |
|
24 | + } |
|
25 | + |
|
26 | + // make sure we have a query type |
|
27 | + switch (strtolower(substr($queryText, 0, 6))) { |
|
28 | + case 'insert': |
|
29 | + $queryType = 'INSERT'; |
|
30 | + break; |
|
31 | + |
|
32 | + case 'update': |
|
33 | + $queryType = 'UPDATE'; |
|
34 | + break; |
|
35 | + |
|
36 | + case 'delete': |
|
37 | + $queryType = 'DELETE'; |
|
38 | + break; |
|
39 | + |
|
40 | + case 'select': |
|
41 | + $queryType = 'SELECT'; |
|
42 | + break; |
|
43 | + |
|
44 | + default: |
|
45 | + $queryType = 'QUERY'; |
|
46 | + break; |
|
47 | + } |
|
48 | + |
|
49 | + $this->profiles[] = new Nip_DB_Profiler_Query($queryText, $queryType); |
|
50 | + |
|
51 | + $profileID = $this->lastProcessID(); |
|
52 | + $this->addRunningProces($profileID); |
|
53 | + return $profileID; |
|
54 | + } |
|
55 | 55 | |
56 | 56 | |
57 | - public function end($profileID = false) { |
|
58 | - if (!$this->checkEnabled()) { |
|
59 | - return; |
|
60 | - } |
|
61 | - |
|
62 | - if ($profileID == false) { |
|
63 | - $profileID = $this->getLastRunningProces(); |
|
64 | - } |
|
65 | - |
|
66 | - $profile = $this->endProfile($profileID); |
|
67 | - if (is_object($profile)) { |
|
68 | - $this->secondsFilter($profile); |
|
69 | - $this->typeFilter($profile); |
|
70 | - } |
|
71 | - return; |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - public function typeFilter($profile){ |
|
76 | - if (is_array($this->filterTypes) && in_array($profile->type, $this->filterTypes)) { |
|
77 | - $this->deleteProfile($profileID); |
|
78 | - return; |
|
79 | - } |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - public function setFilterQueryType($queryTypes = null){ |
|
84 | - $this->filterTypes = $queryTypes; |
|
85 | - |
|
86 | - return $this; |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * Singleton |
|
92 | - * |
|
93 | - * @return Nip_DB_Profiler |
|
94 | - */ |
|
95 | - public static function instance() { |
|
96 | - static $instance; |
|
97 | - if (!($instance instanceof self)) { |
|
98 | - $instance = new self(); |
|
99 | - } |
|
100 | - return $instance; |
|
101 | - } |
|
57 | + public function end($profileID = false) { |
|
58 | + if (!$this->checkEnabled()) { |
|
59 | + return; |
|
60 | + } |
|
61 | + |
|
62 | + if ($profileID == false) { |
|
63 | + $profileID = $this->getLastRunningProces(); |
|
64 | + } |
|
65 | + |
|
66 | + $profile = $this->endProfile($profileID); |
|
67 | + if (is_object($profile)) { |
|
68 | + $this->secondsFilter($profile); |
|
69 | + $this->typeFilter($profile); |
|
70 | + } |
|
71 | + return; |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + public function typeFilter($profile){ |
|
76 | + if (is_array($this->filterTypes) && in_array($profile->type, $this->filterTypes)) { |
|
77 | + $this->deleteProfile($profileID); |
|
78 | + return; |
|
79 | + } |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + public function setFilterQueryType($queryTypes = null){ |
|
84 | + $this->filterTypes = $queryTypes; |
|
85 | + |
|
86 | + return $this; |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * Singleton |
|
92 | + * |
|
93 | + * @return Nip_DB_Profiler |
|
94 | + */ |
|
95 | + public static function instance() { |
|
96 | + static $instance; |
|
97 | + if (!($instance instanceof self)) { |
|
98 | + $instance = new self(); |
|
99 | + } |
|
100 | + return $instance; |
|
101 | + } |
|
102 | 102 | } |
103 | 103 | \ No newline at end of file |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | |
75 | - public function typeFilter($profile){ |
|
75 | + public function typeFilter($profile) { |
|
76 | 76 | if (is_array($this->filterTypes) && in_array($profile->type, $this->filterTypes)) { |
77 | 77 | $this->deleteProfile($profileID); |
78 | 78 | return; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | |
83 | - public function setFilterQueryType($queryTypes = null){ |
|
83 | + public function setFilterQueryType($queryTypes = null) { |
|
84 | 84 | $this->filterTypes = $queryTypes; |
85 | 85 | |
86 | 86 | return $this; |
@@ -3,9 +3,9 @@ |
||
3 | 3 | class Nip_DB_Exception extends Exception |
4 | 4 | { |
5 | 5 | |
6 | - public function __construct($message, $code = E_USER_ERROR) |
|
7 | - { |
|
8 | - parent::__construct($message, $code); |
|
9 | - } |
|
6 | + public function __construct($message, $code = E_USER_ERROR) |
|
7 | + { |
|
8 | + parent::__construct($message, $code); |
|
9 | + } |
|
10 | 10 | |
11 | 11 | } |
12 | 12 | \ No newline at end of file |
@@ -5,30 +5,30 @@ |
||
5 | 5 | class Nip_DB_Query_Delete extends _Abstract |
6 | 6 | { |
7 | 7 | |
8 | - /** |
|
9 | - * Joins together DELETE, FROM, WHERE, ORDER, and LIMIT parts of SQL query |
|
10 | - * @return string |
|
11 | - */ |
|
12 | - public function assemble() |
|
13 | - { |
|
14 | - $where = $this->parseWhere(); |
|
15 | - $order = $this->parseOrder(); |
|
16 | - |
|
17 | - $query = 'DELETE FROM ' . $this->getManager()->protect($this->getTable()); |
|
18 | - |
|
19 | - if (!empty($where)) { |
|
20 | - $query .= ' WHERE ' . $where; |
|
21 | - } |
|
22 | - |
|
23 | - if (!empty($order)) { |
|
24 | - $query .= ' ORDER BY ' . $order; |
|
25 | - } |
|
26 | - |
|
27 | - if (!empty($this->limit)) { |
|
28 | - $query .= ' LIMIT ' . $this->limit; |
|
29 | - } |
|
30 | - |
|
31 | - return $query; |
|
32 | - } |
|
8 | + /** |
|
9 | + * Joins together DELETE, FROM, WHERE, ORDER, and LIMIT parts of SQL query |
|
10 | + * @return string |
|
11 | + */ |
|
12 | + public function assemble() |
|
13 | + { |
|
14 | + $where = $this->parseWhere(); |
|
15 | + $order = $this->parseOrder(); |
|
16 | + |
|
17 | + $query = 'DELETE FROM ' . $this->getManager()->protect($this->getTable()); |
|
18 | + |
|
19 | + if (!empty($where)) { |
|
20 | + $query .= ' WHERE ' . $where; |
|
21 | + } |
|
22 | + |
|
23 | + if (!empty($order)) { |
|
24 | + $query .= ' ORDER BY ' . $order; |
|
25 | + } |
|
26 | + |
|
27 | + if (!empty($this->limit)) { |
|
28 | + $query .= ' LIMIT ' . $this->limit; |
|
29 | + } |
|
30 | + |
|
31 | + return $query; |
|
32 | + } |
|
33 | 33 | |
34 | 34 | } |
35 | 35 | \ No newline at end of file |
@@ -5,9 +5,9 @@ |
||
5 | 5 | class Nip_DB_Query_Truncate extends _Abstract |
6 | 6 | { |
7 | 7 | |
8 | - public function assemble() |
|
9 | - { |
|
10 | - return 'TRUNCATE TABLE ' . $this->getTable(); |
|
11 | - } |
|
8 | + public function assemble() |
|
9 | + { |
|
10 | + return 'TRUNCATE TABLE ' . $this->getTable(); |
|
11 | + } |
|
12 | 12 | |
13 | 13 | } |
14 | 14 | \ No newline at end of file |
@@ -10,6 +10,6 @@ |
||
10 | 10 | } |
11 | 11 | |
12 | 12 | public function getString() { |
13 | - return $this->protectCondition($this->_condition->getString()) ." OR ". $this->protectCondition($this->_orCondition->getString()) .""; |
|
13 | + return $this->protectCondition($this->_condition->getString()) . " OR " . $this->protectCondition($this->_orCondition->getString()) . ""; |
|
14 | 14 | } |
15 | 15 | } |
16 | 16 | \ No newline at end of file |
@@ -3,18 +3,18 @@ |
||
3 | 3 | class Nip_DB_Query_AndCondition extends Nip_DB_Query_Condition |
4 | 4 | { |
5 | 5 | |
6 | - protected $_condition; |
|
7 | - protected $_andCondition; |
|
6 | + protected $_condition; |
|
7 | + protected $_andCondition; |
|
8 | 8 | |
9 | - public function __construct($condition, $andCondition) |
|
10 | - { |
|
11 | - $this->_condition = $condition; |
|
12 | - $this->_andCondition = $andCondition; |
|
13 | - } |
|
9 | + public function __construct($condition, $andCondition) |
|
10 | + { |
|
11 | + $this->_condition = $condition; |
|
12 | + $this->_andCondition = $andCondition; |
|
13 | + } |
|
14 | 14 | |
15 | - public function getString() |
|
16 | - { |
|
17 | - return $this->protectCondition($this->_condition->getString()) . " AND " . $this->protectCondition($this->_andCondition->getString()) . ""; |
|
18 | - } |
|
15 | + public function getString() |
|
16 | + { |
|
17 | + return $this->protectCondition($this->_condition->getString()) . " AND " . $this->protectCondition($this->_andCondition->getString()) . ""; |
|
18 | + } |
|
19 | 19 | |
20 | 20 | } |
21 | 21 | \ No newline at end of file |
@@ -3,10 +3,10 @@ |
||
3 | 3 | class Nip_DB_Query_Replace extends Nip_DB_Query_Insert |
4 | 4 | { |
5 | 5 | |
6 | - public function assemble() |
|
7 | - { |
|
8 | - $query = "REPLACE INTO " . $this->protect($this->getTable()) . $this->parseCols() . $this->parseValues(); |
|
9 | - return $query; |
|
10 | - } |
|
6 | + public function assemble() |
|
7 | + { |
|
8 | + $query = "REPLACE INTO " . $this->protect($this->getTable()) . $this->parseCols() . $this->parseValues(); |
|
9 | + return $query; |
|
10 | + } |
|
11 | 11 | |
12 | 12 | } |
13 | 13 | \ No newline at end of file |
@@ -2,29 +2,29 @@ |
||
2 | 2 | interface Nip_DB_Adapters_Interface |
3 | 3 | { |
4 | 4 | |
5 | - function execute($sql); |
|
5 | + function execute($sql); |
|
6 | 6 | |
7 | - function lastInsertID(); |
|
7 | + function lastInsertID(); |
|
8 | 8 | |
9 | - function affectedRows(); |
|
9 | + function affectedRows(); |
|
10 | 10 | |
11 | - function numRows($result); |
|
11 | + function numRows($result); |
|
12 | 12 | |
13 | - function fetchArray($result); |
|
13 | + function fetchArray($result); |
|
14 | 14 | |
15 | - function fetchAssoc($result); |
|
15 | + function fetchAssoc($result); |
|
16 | 16 | |
17 | - function fetchObject($result); |
|
17 | + function fetchObject($result); |
|
18 | 18 | |
19 | - function result($result, $row, $field); |
|
19 | + function result($result, $row, $field); |
|
20 | 20 | |
21 | - function freeResults($result); |
|
21 | + function freeResults($result); |
|
22 | 22 | |
23 | - function describeTable($table); |
|
23 | + function describeTable($table); |
|
24 | 24 | |
25 | - function cleanData($data); |
|
25 | + function cleanData($data); |
|
26 | 26 | |
27 | - function error(); |
|
27 | + function error(); |
|
28 | 28 | |
29 | - function disconnect(); |
|
29 | + function disconnect(); |
|
30 | 30 | } |
31 | 31 | \ No newline at end of file |
@@ -3,39 +3,39 @@ discard block |
||
3 | 3 | class Nip_DB_Adapters_MySQLi extends Nip_DB_Adapters_Abstract implements Nip_DB_Adapters_Interface |
4 | 4 | { |
5 | 5 | |
6 | - protected $_connection; |
|
7 | - |
|
8 | - /** |
|
9 | - * Connects to MySQL server |
|
10 | - * |
|
11 | - * @param string $host |
|
12 | - * @param string $user |
|
13 | - * @param string $password |
|
14 | - * @param string $database |
|
15 | - * @return resource |
|
16 | - */ |
|
17 | - public function connect($host = false, $user = false, $password = false, $database = false, $newLink = false) |
|
18 | - { |
|
19 | - $this->_connection = mysqli_connect($host, $user, $password, $newLink); |
|
6 | + protected $_connection; |
|
7 | + |
|
8 | + /** |
|
9 | + * Connects to MySQL server |
|
10 | + * |
|
11 | + * @param string $host |
|
12 | + * @param string $user |
|
13 | + * @param string $password |
|
14 | + * @param string $database |
|
15 | + * @return resource |
|
16 | + */ |
|
17 | + public function connect($host = false, $user = false, $password = false, $database = false, $newLink = false) |
|
18 | + { |
|
19 | + $this->_connection = mysqli_connect($host, $user, $password, $newLink); |
|
20 | 20 | |
21 | - if ($this->_connection) { |
|
22 | - if ($this->selectDatabase($database)) { |
|
23 | - $this->query("SET CHARACTER SET utf8"); |
|
24 | - $this->query("SET NAMES utf8"); |
|
25 | - return $this->_connection; |
|
26 | - } else { |
|
27 | - $message = 'Cannot select database ' . $database; |
|
28 | - } |
|
29 | - } else { |
|
30 | - $message = mysqli_error(); |
|
31 | - } |
|
32 | - |
|
33 | - if (!$this->_connection) { |
|
34 | - trigger_error($message, E_USER_WARNING); |
|
35 | - } |
|
36 | - |
|
37 | - return false; |
|
38 | - } |
|
21 | + if ($this->_connection) { |
|
22 | + if ($this->selectDatabase($database)) { |
|
23 | + $this->query("SET CHARACTER SET utf8"); |
|
24 | + $this->query("SET NAMES utf8"); |
|
25 | + return $this->_connection; |
|
26 | + } else { |
|
27 | + $message = 'Cannot select database ' . $database; |
|
28 | + } |
|
29 | + } else { |
|
30 | + $message = mysqli_error(); |
|
31 | + } |
|
32 | + |
|
33 | + if (!$this->_connection) { |
|
34 | + trigger_error($message, E_USER_WARNING); |
|
35 | + } |
|
36 | + |
|
37 | + return false; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | 41 | public function selectDatabase($database) |
@@ -43,130 +43,130 @@ discard block |
||
43 | 43 | return mysqli_select_db($this->_connection, $database); |
44 | 44 | } |
45 | 45 | |
46 | - /** |
|
47 | - * Executes SQL query |
|
48 | - * |
|
49 | - * @param string $sql |
|
50 | - * @return result ID |
|
51 | - */ |
|
52 | - public function query($sql) |
|
53 | - { |
|
54 | - return mysqli_query($this->_connection, $sql); |
|
55 | - } |
|
56 | - |
|
57 | - public function lastInsertID() |
|
58 | - { |
|
59 | - return mysqli_insert_id($this->_connection); |
|
60 | - } |
|
61 | - |
|
62 | - public function affectedRows() |
|
63 | - { |
|
64 | - return mysqli_affected_rows($this->_connection); |
|
65 | - } |
|
66 | - |
|
67 | - public function info() |
|
68 | - { |
|
69 | - return mysqli_info($this->_connection); |
|
70 | - } |
|
71 | - |
|
72 | - public function numRows($result) |
|
73 | - { |
|
74 | - return mysqli_num_rows($result); |
|
75 | - } |
|
76 | - |
|
77 | - public function fetchArray($result) |
|
78 | - { |
|
79 | - return mysqli_fetch_array($result); |
|
80 | - } |
|
81 | - |
|
82 | - public function fetchAssoc($result) |
|
83 | - { |
|
84 | - return mysqli_fetch_assoc($result); |
|
85 | - } |
|
86 | - |
|
87 | - public function fetchObject($result) |
|
88 | - { |
|
89 | - return mysqli_fetch_object($result); |
|
90 | - } |
|
91 | - |
|
92 | - public function result($result, $row, $field) |
|
93 | - { |
|
94 | - return mysqli_result($result, $row, $field); |
|
95 | - } |
|
96 | - |
|
97 | - public function freeResults($result) |
|
98 | - { |
|
99 | - return mysqli_free_result($result); |
|
100 | - } |
|
101 | - |
|
102 | - public function describeTable($table) |
|
103 | - { |
|
104 | - $return = array('fields' => array(), 'indexes' => array()); |
|
105 | - |
|
106 | - $result = $this->execute('SHOW INDEX IN ' . $table); |
|
107 | - if (mysqli_num_rows($result)) { |
|
108 | - while ($row = $this->fetchAssoc($result)) { |
|
109 | - if (!$return['indexes'][$row['Key_name']]) { |
|
110 | - $return['indexes'][$row['Key_name']] = array(); |
|
111 | - } |
|
112 | - $return['indexes'][$row['Key_name']]['fields'][] = $row['Column_name']; |
|
113 | - $return['indexes'][$row['Key_name']]['unique'] = $row['Non_unique'] == '0'; |
|
114 | - $return['indexes'][$row['Key_name']]['fulltext'] = $row['Index_type'] == 'FULLTEXT'; |
|
115 | - $return['indexes'][$row['Key_name']]['type'] = $row['Index_type']; |
|
116 | - } |
|
117 | - } |
|
118 | - |
|
119 | - $result = $this->execute('DESCRIBE ' . $table); |
|
120 | - if (mysqli_num_rows($result)) { |
|
121 | - while ($row = $this->fetchAssoc($result)) { |
|
122 | - $return['fields'][$row['Field']] = array( |
|
123 | - 'field' => $row['Field'], |
|
124 | - 'type' => $row['Type'], |
|
125 | - 'primary' => ($return['indexes']['PRIMARY']['fields'][0] == $row['Field']), |
|
126 | - 'default' => $row['Default'], |
|
127 | - 'auto_increment' => ($row['Extra'] === 'auto_increment') |
|
128 | - ); |
|
129 | - } |
|
130 | - } |
|
131 | - |
|
132 | - return $return; |
|
133 | - } |
|
134 | - |
|
135 | - public function getTables() |
|
136 | - { |
|
137 | - $return = array(); |
|
46 | + /** |
|
47 | + * Executes SQL query |
|
48 | + * |
|
49 | + * @param string $sql |
|
50 | + * @return result ID |
|
51 | + */ |
|
52 | + public function query($sql) |
|
53 | + { |
|
54 | + return mysqli_query($this->_connection, $sql); |
|
55 | + } |
|
56 | + |
|
57 | + public function lastInsertID() |
|
58 | + { |
|
59 | + return mysqli_insert_id($this->_connection); |
|
60 | + } |
|
61 | + |
|
62 | + public function affectedRows() |
|
63 | + { |
|
64 | + return mysqli_affected_rows($this->_connection); |
|
65 | + } |
|
66 | + |
|
67 | + public function info() |
|
68 | + { |
|
69 | + return mysqli_info($this->_connection); |
|
70 | + } |
|
71 | + |
|
72 | + public function numRows($result) |
|
73 | + { |
|
74 | + return mysqli_num_rows($result); |
|
75 | + } |
|
76 | + |
|
77 | + public function fetchArray($result) |
|
78 | + { |
|
79 | + return mysqli_fetch_array($result); |
|
80 | + } |
|
81 | + |
|
82 | + public function fetchAssoc($result) |
|
83 | + { |
|
84 | + return mysqli_fetch_assoc($result); |
|
85 | + } |
|
86 | + |
|
87 | + public function fetchObject($result) |
|
88 | + { |
|
89 | + return mysqli_fetch_object($result); |
|
90 | + } |
|
91 | + |
|
92 | + public function result($result, $row, $field) |
|
93 | + { |
|
94 | + return mysqli_result($result, $row, $field); |
|
95 | + } |
|
96 | + |
|
97 | + public function freeResults($result) |
|
98 | + { |
|
99 | + return mysqli_free_result($result); |
|
100 | + } |
|
101 | + |
|
102 | + public function describeTable($table) |
|
103 | + { |
|
104 | + $return = array('fields' => array(), 'indexes' => array()); |
|
105 | + |
|
106 | + $result = $this->execute('SHOW INDEX IN ' . $table); |
|
107 | + if (mysqli_num_rows($result)) { |
|
108 | + while ($row = $this->fetchAssoc($result)) { |
|
109 | + if (!$return['indexes'][$row['Key_name']]) { |
|
110 | + $return['indexes'][$row['Key_name']] = array(); |
|
111 | + } |
|
112 | + $return['indexes'][$row['Key_name']]['fields'][] = $row['Column_name']; |
|
113 | + $return['indexes'][$row['Key_name']]['unique'] = $row['Non_unique'] == '0'; |
|
114 | + $return['indexes'][$row['Key_name']]['fulltext'] = $row['Index_type'] == 'FULLTEXT'; |
|
115 | + $return['indexes'][$row['Key_name']]['type'] = $row['Index_type']; |
|
116 | + } |
|
117 | + } |
|
118 | + |
|
119 | + $result = $this->execute('DESCRIBE ' . $table); |
|
120 | + if (mysqli_num_rows($result)) { |
|
121 | + while ($row = $this->fetchAssoc($result)) { |
|
122 | + $return['fields'][$row['Field']] = array( |
|
123 | + 'field' => $row['Field'], |
|
124 | + 'type' => $row['Type'], |
|
125 | + 'primary' => ($return['indexes']['PRIMARY']['fields'][0] == $row['Field']), |
|
126 | + 'default' => $row['Default'], |
|
127 | + 'auto_increment' => ($row['Extra'] === 'auto_increment') |
|
128 | + ); |
|
129 | + } |
|
130 | + } |
|
131 | + |
|
132 | + return $return; |
|
133 | + } |
|
134 | + |
|
135 | + public function getTables() |
|
136 | + { |
|
137 | + $return = array(); |
|
138 | 138 | |
139 | - $result = $this->execute("SHOW FULL TABLES"); |
|
140 | - if ($this->numRows($result)) { |
|
141 | - while ($row = $this->fetchArray($result)) { |
|
142 | - $return[$row[0]] = array( |
|
143 | - "type" => $row[1] == "BASE TABLE" ? "table" : "view" |
|
144 | - ); |
|
145 | - } |
|
146 | - } |
|
147 | - |
|
148 | - return $return; |
|
149 | - } |
|
150 | - |
|
151 | - public function quote($value) |
|
152 | - { |
|
153 | - $value = $this->cleanData($value); |
|
154 | - return is_numeric($value) ? $value : "'$value'"; |
|
155 | - } |
|
156 | - |
|
157 | - public function cleanData($data) |
|
158 | - { |
|
159 | - return mysqli_real_escape_string($this->_connection, $data); |
|
160 | - } |
|
161 | - |
|
162 | - public function error() |
|
163 | - { |
|
164 | - return mysqli_error($this->_connection); |
|
165 | - } |
|
166 | - |
|
167 | - public function disconnect() |
|
168 | - { |
|
169 | - mysqli_close($this->_connection); |
|
170 | - } |
|
139 | + $result = $this->execute("SHOW FULL TABLES"); |
|
140 | + if ($this->numRows($result)) { |
|
141 | + while ($row = $this->fetchArray($result)) { |
|
142 | + $return[$row[0]] = array( |
|
143 | + "type" => $row[1] == "BASE TABLE" ? "table" : "view" |
|
144 | + ); |
|
145 | + } |
|
146 | + } |
|
147 | + |
|
148 | + return $return; |
|
149 | + } |
|
150 | + |
|
151 | + public function quote($value) |
|
152 | + { |
|
153 | + $value = $this->cleanData($value); |
|
154 | + return is_numeric($value) ? $value : "'$value'"; |
|
155 | + } |
|
156 | + |
|
157 | + public function cleanData($data) |
|
158 | + { |
|
159 | + return mysqli_real_escape_string($this->_connection, $data); |
|
160 | + } |
|
161 | + |
|
162 | + public function error() |
|
163 | + { |
|
164 | + return mysqli_error($this->_connection); |
|
165 | + } |
|
166 | + |
|
167 | + public function disconnect() |
|
168 | + { |
|
169 | + mysqli_close($this->_connection); |
|
170 | + } |
|
171 | 171 | |
172 | 172 | } |
173 | 173 | \ No newline at end of file |