1
2/*
3 +------------------------------------------------------------------------+
4 | Phalcon Framework                                                      |
5 +------------------------------------------------------------------------+
6 | Copyright (c) 2011-2017 Phalcon Team (https://phalconphp.com)          |
7 +------------------------------------------------------------------------+
8 | This source file is subject to the New BSD License that is bundled     |
9 | with this package in the file LICENSE.txt.                             |
10 |                                                                        |
11 | If you did not receive a copy of the license and are unable to         |
12 | obtain it through the world-wide-web, please send an email             |
13 | to license@phalconphp.com so we can send you a copy immediately.       |
14 +------------------------------------------------------------------------+
15 | Authors: Andres Gutierrez <andres@phalconphp.com>                      |
16 |          Eduar Carvajal <eduar@phalconphp.com>                         |
17 +------------------------------------------------------------------------+
18 */
19
20namespace Phalcon\Db;
21
22
23use Phalcon\Db\ColumnInterface;
24use Phalcon\Db\ReferenceInterface;
25use Phalcon\Db\IndexInterface;
26
27
28/**
29 * Phalcon\Db\DialectInterface
30 *
31 * Interface for Phalcon\Db dialects
32 */
33interface DialectInterface
34{
35
36	/**
37	 * Generates the SQL for LIMIT clause
38	 */
39	public function limit(string! sqlQuery, var number) -> string;
40
41	/**
42	 * Returns a SQL modified with a FOR UPDATE clause
43	 */
44	public function forUpdate(string! sqlQuery) -> string;
45
46	/**
47	 * Returns a SQL modified with a LOCK IN SHARE MODE clause
48	 */
49	public function sharedLock(string! sqlQuery) -> string;
50
51	/**
52	 * Builds a SELECT statement
53	 */
54	public function select(array! definition) -> string;
55
56	/**
57	 * Gets a list of columns
58	 */
59	public function getColumnList(array! columnList) -> string;
60
61	/**
62	 * Gets the column name in RDBMS
63	 */
64	public function getColumnDefinition(<ColumnInterface> column) -> string;
65
66	/**
67	 * Generates SQL to add a column to a table
68	 */
69	public function addColumn(string! tableName, string! schemaName, <ColumnInterface> column) -> string;
70
71	/**
72	 * Generates SQL to modify a column in a table
73	 */
74	public function modifyColumn(string! tableName, string! schemaName, <ColumnInterface> column, <ColumnInterface> currentColumn = null) -> string;
75
76	/**
77	 * Generates SQL to delete a column from a table
78	 */
79	public function dropColumn(string! tableName, string! schemaName, string! columnName) -> string;
80
81	/**
82	 * Generates SQL to add an index to a table
83	 */
84	public function addIndex(string! tableName, string! schemaName, <IndexInterface> index) -> string;
85
86	/**
87 	 * Generates SQL to delete an index from a table
88	 */
89	public function dropIndex(string! tableName, string! schemaName, string! indexName) -> string;
90
91	/**
92	 * Generates SQL to add the primary key to a table
93	 */
94	public function addPrimaryKey(string! tableName, string! schemaName, <IndexInterface> index) -> string;
95
96	/**
97	 * Generates SQL to delete primary key from a table
98	 */
99	public function dropPrimaryKey(string! tableName, string! schemaName) -> string;
100
101	/**
102	 * Generates SQL to add an index to a table
103	 */
104	public function addForeignKey(string! tableName, string! schemaName, <ReferenceInterface> reference) -> string;
105
106	/**
107	 * Generates SQL to delete a foreign key from a table
108	 */
109	public function dropForeignKey(string! tableName, string! schemaName, string! referenceName) -> string;
110
111	/**
112	 * Generates SQL to create a table
113	 */
114	public function createTable(string! tableName, string! schemaName, array! definition);
115
116	/**
117	 * Generates SQL to create a view
118	 */
119	public function createView(string! viewName, array! definition, string schemaName = null) -> string;
120
121	/**
122	 * Generates SQL to drop a table
123	 */
124	public function dropTable(string! tableName, string! schemaName) -> string;
125
126	/**
127	 * Generates SQL to drop a view
128	 */
129	public function dropView(string! viewName, string schemaName = null, boolean! ifExists = true) -> string;
130
131	/**
132	 * Generates SQL checking for the existence of a schema.table
133	 */
134	public function tableExists(string! tableName, string schemaName = null) -> string;
135
136	/**
137	 * Generates SQL checking for the existence of a schema.view
138	 */
139	public function viewExists(string! viewName, string schemaName = null) -> string;
140
141	/**
142	 * Generates SQL to describe a table
143	 */
144	public function describeColumns(string! table, string schema = null) -> string;
145
146	/**
147	 * List all tables in database
148	 */
149	public function listTables(string schemaName = null) -> string;
150
151	/**
152	 * Generates SQL to query indexes on a table
153	 */
154	public function describeIndexes(string! table, string schema = null) -> string;
155
156	/**
157	 * Generates SQL to query foreign keys on a table
158	 */
159	public function describeReferences(string! table, string schema = null) -> string;
160
161	/**
162	 * Generates the SQL to describe the table creation options
163	 */
164	public function tableOptions(string! table, string schema = null) -> string;
165
166	/**
167	 * Checks whether the platform supports savepoints
168	 */
169	public function supportsSavepoints() -> boolean;
170
171	/**
172	 * Checks whether the platform supports releasing savepoints.
173	 */
174	public function supportsReleaseSavepoints() -> boolean;
175
176	/**
177	 * Generate SQL to create a new savepoint
178	 */
179	public function createSavepoint(string! name) -> string;
180
181	/**
182	 * Generate SQL to release a savepoint
183	 */
184	public function releaseSavepoint(string! name) -> string;
185
186	/**
187	 * Generate SQL to rollback a savepoint
188	 */
189	public function rollbackSavepoint(string! name) -> string;
190
191}
192