KexiDB::Parser Class Reference
#include <parser.h>
Detailed Description
Parser for SQL statements.The best and prefeerred way to run queries is using the KexiDB::Parser functionality and use the resulting QuerySchema object since this offers a database-backend-independent way to deal with SQL statements on the one hand and offers high level functionality on the other. Also BLOBs like images are handled that way.
For example if we like to use the SELECT statement "SELECT dir.path, media.filename FROM dir, media WHERE dir.id=media.dirId AND media.id=%s" we are able to use the Connection::prepareStatement method which takes the type of the statement (in our case PreparedStatement::SelectStatement ), a list of fields (in our case dir.path and media.filename) and returns a PreparedStatement::Ptr instance. By using the QuerySchema::addRelationship and QuerySchema::addToWhereExpression methods the SQL statement could be extended with relationships and WHERE expressions.
For more, see KexiDB::PreparedStatement and Connection::selectStatement() . A more complex example that looks at what the user has defined and carefully builds KexiDB::QuerySchema object, including the WHERE expression can be found in the Query Designer's source code in the method KexiQueryDesignerGuiEditor::buildSchema().
Definition at line 112 of file parser.h.
Public Types | |
| enum | OPCode { OP_None = 0, OP_Error, OP_CreateTable, OP_AlterTable, OP_Select, OP_Insert, OP_Update, OP_Delete } |
| The operation-code of the statement. More... | |
Public Member Functions | |
| Parser (Connection *connection) | |
| constructs an empty object of the parser | |
| ~Parser () | |
| bool | parse (const QString &statement) |
| clears previous results and runs the parser | |
| void | clear () |
| rests results | |
| OPCode | operation () const |
| QString | operationString () const |
| TableSchema * | table () |
| QuerySchema * | query () |
| Connection * | db () const |
| ParserError | error () const |
| QString | statement () const |
| void | setOperation (OPCode op) |
| void | createTable (const char *t) |
| void | setQuerySchema (QuerySchema *query) |
| QuerySchema * | select () const |
| void | setError (const ParserError &err) |
| bool | isReservedKeyword (const char *str) |
Protected Member Functions | |
| void | init () |
Protected Attributes | |
| ParserError | m_error |
| detailed information about last error. | |
| ParserPrivate * | d |
Member Enumeration Documentation
|
|
The operation-code of the statement.
|
Constructor & Destructor Documentation
|
|
constructs an empty object of the parser
Definition at line 31 of file parser.cpp. References d, and KexiDB::ParserPrivate::db. |
|
|
Definition at line 37 of file parser.cpp. References d. |
Member Function Documentation
|
|
rests results
Definition at line 125 of file parser.cpp. References KexiDB::ParserPrivate::clear(), and d. Referenced by parse(), and parseData(). |
|
|
Definition at line 84 of file parser.cpp. References d, and KexiDB::ParserPrivate::table. Referenced by yyparse(). |
|
|
Definition at line 71 of file parser.cpp. References d, and KexiDB::ParserPrivate::db. Referenced by buildSelectQuery(). |
|
|
Definition at line 73 of file parser.cpp. References d, and KexiDB::ParserPrivate::error. Referenced by parseData(), KexiQueryDesignerSQLView::slotCheckQuery(), and yyerror(). |
|
|
Definition at line 101 of file parser.cpp. References d, and KexiDB::ParserPrivate::initialized. Referenced by parse(). |
|
|
Definition at line 110 of file parser.cpp. References d, and KexiDB::ParserPrivate::reservedKeywords. Referenced by yyerror(). |
|
|
Definition at line 42 of file parser.cpp. References d, and KexiDB::ParserPrivate::operation. Referenced by parseData(). |
|
|
Definition at line 45 of file parser.cpp. References d, OP_AlterTable, OP_CreateTable, OP_Delete, OP_Error, OP_Insert, OP_Select, OP_Update, and KexiDB::ParserPrivate::operation. |
|
|
clears previous results and runs the parser
Definition at line 116 of file parser.cpp. References clear(), d, init(), parseData(), and KexiDB::ParserPrivate::statement. Referenced by KexiQueryPart::loadSchemaData(), and KexiQueryDesignerSQLView::slotCheckQuery(). |
|
|
Definition at line 69 of file parser.cpp. References d, and KexiDB::ParserPrivate::select. Referenced by KexiQueryPart::loadSchemaData(), and KexiQueryDesignerSQLView::slotCheckQuery(). |
|
|
Definition at line 79 of file parser.cpp. References d, and KexiDB::ParserPrivate::select. |
|
|
Definition at line 81 of file parser.cpp. References d, and KexiDB::ParserPrivate::error. Referenced by parseData(), setError(), and yyerror(). |
|
|
Definition at line 77 of file parser.cpp. References d, and KexiDB::ParserPrivate::operation. |
|
|
Definition at line 93 of file parser.cpp. References d, and KexiDB::ParserPrivate::select. Referenced by yyparse(). |
|
|
Definition at line 75 of file parser.cpp. References d, and KexiDB::ParserPrivate::statement. Referenced by yyerror(). |
|
|
Definition at line 67 of file parser.cpp. References d, and KexiDB::ParserPrivate::table. Referenced by yyparse(). |
Member Data Documentation
|
|
Definition at line 234 of file parser.h. Referenced by clear(), createTable(), db(), error(), init(), isReservedKeyword(), operation(), operationString(), parse(), Parser(), query(), select(), setError(), setOperation(), setQuerySchema(), statement(), table(), and ~Parser(). |
|
|
detailed information about last error.
|
The documentation for this class was generated from the following files:
