PluginProbe
FluentSnippets – High-Performance Code Snippets, Header & Footer Code, Custom CSS & PHP Code Manager / 1.2.1
FluentSnippets – High-Performance Code Snippets, Header & Footer Code, Custom CSS & PHP Code Manager v1.2.1
10.56 1.2.1 10 10.1 10.2 10.3 10.31 10.32 10.33 10.34 10.50 10.51 10.52 10.53 10.55 9.0 9.0.1 9.4 trunk 1.0.0 1.1 1.2
easy-code-manager / framework / db / mysql / sql-view.inc.php

sql-view.inc.php in FluentSnippets – High-Performance Code Snippets, Header & Footer Code, Custom CSS & PHP Code Manager 1.2.1, 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.