PluginProbe
CSS & JavaScript Toolbox / 11
CSS & JavaScript Toolbox v11
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
css-javascript-toolbox / framework / db / mysql / sql-view.inc.php

sql-view.inc.php in CSS & JavaScript Toolbox 11, at framework/db/mysql/sql-view.inc.php

121 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @version $ Id; ?FILE_NAME ?DATE ?TIME ?AUTHOR $
4 */
5
6 /**
7 * No direct access.
8 */
9 // No Direct Accesss code
10
11 /**
12 *
13 * DESCRIPTION
14 *
15 * @author ??
16 * @version ??
17 */
18 abstract class CJTSQLView {
19
20 /**
21 * put your comment there...
22 *
23 * @var mixed
24 */
25 protected $driver = null;
26
27 /**
28 * put your comment there...
29 *
30 * @var mixed
31 */
32 protected $query = array(
33 'columns' => array('*'),
34 'filter' => array(),
35 'orderBy' => array(),
36 'limits' => array(),
37 );
38
39 /**
40 * put your comment there...
41 *
42 * @param mixed $dbDriver
43 * @return CJTPinsBlockView
44 */
45 public function __construct($driver) {
46 $this->driver = $driver;
47 // Initialize locals.
48 $this->query = (object) $this->query;
49 }
50
51 /**
52 * put your comment there...
53 *
54 */
55 abstract public function __toString();
56
57
58 /**
59 * put your comment there...
60 *
61 * @param mixed $from
62 * @param mixed $filter
63 */
64 protected function buildQuery($from, $filter)
65 {
66
67 $query = $this->query;
68
69 $sql = array
70 (
71 'columns' => null,
72 'from' => null,
73 'filter' => null,
74 'orderBy' => null,
75 'limits' => null
76 );
77
78 $sql[ 'columns' ] = implode( ', ', $query->columns );
79
80 // From.
81 $sql[ 'from' ] = " FROM {$from}";
82
83 // Where clause.
84 if ( ! empty( $filter ) )
85 {
86 $sql[ 'filter' ] = " WHERE {$filter}";
87 }
88
89 // Order By.
90 if ( ! empty( $query->orderBy ) )
91 {
92 $sql[ 'orderBy' ] = ' ORDER BY ' . implode( ',', $order );
93 }
94
95 // Limits.
96 if ( ! empty( $query->limits ) )
97 {
98 $sql[ 'limits' ] = " LIMIT {$limits[0]}" . ( isset( $limits[ 1 ] ) ? ",{$limits}" : '' );
99 }
100
101 // Buile query
102 $sql = "SELECT {$sql['columns']}\n\n{$sql['from']}\n\n{$sql['filter']}{$sql['orderBy']}{$sql['limits']};";
103
104 return $sql;
105 }
106
107 /**
108 * put your comment there...
109 *
110 */
111 abstract public function exec();
112
113 /**
114 * put your comment there...
115 *
116 */
117 public function &getQueryObject() {
118 return $this->query;
119 }
120
121 } // End class.