1 | <?php |
||
14 | class Sql |
||
15 | { |
||
16 | /** |
||
17 | * @var \BfwSql\SqlConnect $sqlConnect SqlConnect object |
||
18 | */ |
||
19 | protected $sqlConnect; |
||
20 | |||
21 | /** |
||
22 | * @var string $prefix Tables prefix |
||
23 | */ |
||
24 | protected $prefix = ''; |
||
25 | |||
26 | /** |
||
27 | * Constructor |
||
28 | * |
||
29 | * @param \BfwSql\SqlConnect $sqlConnect SqlConnect instance |
||
30 | * |
||
31 | * @throws \Exception |
||
32 | */ |
||
33 | public function __construct(\BfwSql\SqlConnect $sqlConnect) |
||
38 | |||
39 | /** |
||
40 | * Getter to the property sqlConnect |
||
41 | * |
||
42 | * @return \BFWSql\SqlConnect |
||
43 | */ |
||
44 | public function getSqlConnect() |
||
48 | |||
49 | /** |
||
50 | * Getter to the property prefix |
||
51 | * |
||
52 | * @return string |
||
53 | */ |
||
54 | public function getPrefix() |
||
58 | |||
59 | /** |
||
60 | * Get the id for the last item has been insert in database |
||
61 | * |
||
62 | * @param string|null $name (default: null) Name of the sequence for the id |
||
63 | * Used for SGDB like PostgreSQL. Not use it for mysql. |
||
64 | * |
||
65 | * @return integer |
||
66 | */ |
||
67 | public function getLastInsertedId($name = null) |
||
71 | |||
72 | /** |
||
73 | * Get the id for the last item has been insert in database for a table |
||
74 | * without auto-increment |
||
75 | * |
||
76 | * @param string $table The table name |
||
77 | * @param string $colId The column name for the ID |
||
78 | * @param string|array $order Columns to sort table content |
||
79 | * @param string|array $where All where instruction used for filter content |
||
80 | * |
||
81 | * @return integer |
||
82 | */ |
||
83 | public function getLastInsertedIdWithoutAI( |
||
118 | |||
119 | /** |
||
120 | * Return a new instance of SqlSelect |
||
121 | * |
||
122 | * @param string $type (default: "array") Return PHP type |
||
123 | * Possible value : "array" or "object" |
||
124 | * |
||
125 | * @return \BfwSql\SqlSelect |
||
126 | */ |
||
127 | public function select($type = 'array') |
||
131 | |||
132 | /** |
||
133 | * Return a new instance of SqlInsert |
||
134 | * |
||
135 | * @param string $table The table concerned by the request |
||
136 | * @param array $columns (default: null) All datas to add |
||
137 | * Format is array('columnName' => 'value', ...); |
||
138 | * |
||
139 | * @return \BfwSql\SqlInsert |
||
140 | */ |
||
141 | public function insert($table, $columns = null) |
||
145 | |||
146 | /** |
||
147 | * Return a new instance of SqlUpdate |
||
148 | * |
||
149 | * @param string $table The table concerned by the request |
||
150 | * @param array $columns (default: null) All datas to update |
||
151 | * Format is array('columnName' => 'newValue', ...); |
||
152 | * |
||
153 | * @return \BfwSql\SqlUpdate |
||
154 | */ |
||
155 | public function update($table, $columns = null) |
||
159 | |||
160 | /** |
||
161 | * Return a new instance of SqlDelete |
||
162 | * |
||
163 | * @param string $table The table concerned by the request |
||
164 | * |
||
165 | * @return \BfwSql\SqlDelete |
||
166 | */ |
||
167 | public function delete($table) |
||
171 | |||
172 | /** |
||
173 | * Find the first vacant id on a table and for a column |
||
174 | * |
||
175 | * @param string $table The table concerned by the request |
||
176 | * @param string $column The id column. Must be an integer.. |
||
177 | * |
||
178 | * @throws \Exception If a error has been throw during the search |
||
179 | * |
||
180 | * @return integer |
||
181 | */ |
||
182 | public function createId($table, $column) |
||
215 | |||
216 | /** |
||
217 | * Run the query in parameter |
||
218 | * |
||
219 | * @param string $request The request to run |
||
220 | * |
||
221 | * @throws \Exception If the request has failed |
||
222 | * |
||
223 | * @return \PDOStatement |
||
224 | */ |
||
225 | public function query($request) |
||
243 | } |
||
244 |