CN107818157B - SQL statement packaging method based on FMDB - Google Patents
SQL statement packaging method based on FMDB Download PDFInfo
- Publication number
- CN107818157B CN107818157B CN201711042735.0A CN201711042735A CN107818157B CN 107818157 B CN107818157 B CN 107818157B CN 201711042735 A CN201711042735 A CN 201711042735A CN 107818157 B CN107818157 B CN 107818157B
- Authority
- CN
- China
- Prior art keywords
- sql
- fmdb
- layer
- sql statement
- parameter
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/242—Query formulation
- G06F16/2433—Query languages
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/31—Programming languages or programming paradigms
- G06F8/315—Object-oriented languages
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Mathematical Physics (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Stored Programmes (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention relates to an SQL statement packaging method based on FMDB, which comprises the following steps: creating a UserDBmanager class on an FM interface layer for managing a user database, wherein the UserDBmanager class generates an object and calls a method: AllModel (), the method internally calls the FMDB encapsulation function: the table function is used for appointing a table in a user database, the selectrarray function is used for appointing an operation to be executed, the additional function is used for appointing an optional additional instruction, and after the parameters are received and analyzed, the UserDBmanager class packages an analysis result through the commit instruction and then transmits the analysis result to the SQL execution layer for processing. The invention is based on FMDB, has clear structure and easy realization, simplifies the code writing amount of SQL sentences, is beneficial to improving the development efficiency and reduces errors caused by repeated labor in programming.
Description
Technical Field
The invention relates to the technical field of SQLite API packaging, in particular to an SQL statement packaging method based on FMDB.
Background
The iOS SDK supports SQLite for a long time, and only the libsqlite3.dylib dependence needs to be added and the SQLite3.h header file needs to be introduced when the sQlite SDK is used. However, the native SQLite API is not very friendly to use and is very inconvenient to use.
Disclosure of Invention
Aiming at the defects in the prior art, the invention aims to provide the SQL statement packaging method based on the FMDB, which is clear in structure and easy to realize based on the FMDB, simplifies the code compiling amount of the SQL statement, is beneficial to improving the development efficiency and reduces errors caused by repeated labor in programming.
In order to achieve the above purposes, the technical scheme adopted by the invention is as follows:
an SQL statement packaging method based on FMDB is characterized by comprising the following steps:
at the FM interface layer, a UserDBmanager class is created for managing the user database,
the UserDBmanager class generates an object and invokes a method: AllModel (), the method internally calls the FMDB encapsulation function:
a table function for specifying a table in a user database,
a selectrarray function for specifying an operation to be performed,
an additional function for specifying optional additional instructions,
and after the parameters are received and analyzed, the UserDBmanager class packages the analysis result through the commit instruction and transmits the analysis result to the SQL execution layer for processing.
On the basis of the technical solution, the optional additional instruction is associated with an operation instruction parameter, including but not limited to: sorting instructions, number limiting instructions, conditional instructions.
On the basis of the above technical solution, the parameter analysis means:
the userbmanager class forwards the received parameters to the SQL parameter layer,
in the SQL parameter layer, the SQL parameters are,
the table name parameters are parsed into standard table name assignment statements in SQL statements,
the operation command parameters are analyzed into standard operation and column name making statements in SQL statements,
the additional function is parsed into a standard additional function switch statement in an SQL statement,
after the SQL parameter layer is processed, the UserDBmanager class forwards the processing result to the SQL assembly layer, assembles the processing result into a standard SQL statement,
finally, the SQL assembly layer takes the assembled standard SQL statement as a character string and returns the character string to the UserDBmanager class.
On the basis of the technical scheme, the character string is packaged through a commit instruction and then transmitted to the SQL execution layer for processing.
On the basis of the technical scheme, the character string is packaged through the commit instruction and then is transmitted to the SQL execution layer for processing as the value of the params parameter.
On the basis of the technical scheme, the SQL execution layer analyzes the SQL statement carried by the params parameter in the commit instruction and stores the SQL statement into the DBqueue of the FM execution layer,
in the FM execution layer, a select instruction is issued by an execute query () method to query the database to obtain a query result resultSet,
and finally, returning the query result resultSet to the FM interface layer through the KWSqlResult parameter.
On the basis of the technical scheme, the KWSqlResult parameter at least comprises the following data:
success flag bit success, used to flag the result of SQL execution,
multiple data bits rows for storing query results comprising multiple data,
a single data bit id for storing a query result including one data,
and counting the bits num, and storing the query result comprising the statistical data.
The SQL sentence packaging method based on the FMDB is clear in structure and easy to realize based on the FMDB, simplifies the code writing amount of the SQL sentence, is beneficial to improving the development efficiency, and reduces errors caused by repeated labor in programming.
Drawings
The invention has the following drawings:
FIG. 1 is a flow chart of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings.
As shown in fig. 1, the SQL statement encapsulation method based on FMDB of the present invention includes the following steps:
at the FM interface layer, a UserDBmanager class is created for managing the user database,
the UserDBmanager class generates an object and invokes a method: AllModel (), the method internally calls the FMDB encapsulation function:
a table function for specifying a table in the user database, a user table in the embodiment shown in fig. 1, i.e. a user table,
a select array function, which specifies the operation to be performed, specifies the select array instruction, i.e., select array, and specifies select nil object in the embodiment of FIG. 1,
additional functions for specifying optional additional instructions, in the embodiment shown in fig. 1, a sortStr instruction, i.e. a sort instruction, and specifically defined as ORDER BY round DESC, may also be a number limit instruction, a conditional instruction, etc.,
and after the parameters are received and analyzed, the UserDBmanager class packages the analysis result through the commit instruction and transmits the analysis result to the SQL execution layer for processing.
On the basis of the above technical solution, the parameter analysis means:
the userbmanager class forwards the received parameters to the SQL parameter layer,
in the SQL parameter layer, the SQL parameters are,
the table name parameters are resolved into standard table name assignment statements in SQL statements, namely: table = statement, which in the embodiment shown in fig. 1 should be parsed as table = user,
analyzing the operation instruction parameters into standard operation in SQL sentences and specified column name sentences, namely: the column name of the specified column is obtained and operated accordingly, in the embodiment shown in fig. 1, it should be resolved into the column name in the user table of uid, uname, etc., and a select statement is executed thereon, since the selection of the nil object is specified in the embodiment shown in fig. 1, it is resolved into the column names of all columns accordingly, which is not detailed here,
the additional function is parsed into a standard additional function switch statement in the SQL statement, which in the embodiment shown in fig. 1 should be parsed into an ORDER BY rowed DESC,
after the SQL parameter layer finishes processing, the userbmanager class forwards the processing result to the SQL assembly layer, and assembles the processing result into a standard SQL statement, which should be resolved as select (uid, diameter, …) from user ORDER BY round DESC in the embodiment shown in fig. 1,
finally, the SQL assembly layer takes the assembled standard SQL statement as a character string and returns the character string to the UserDBmanager class.
On the basis of the technical scheme, the character string is packaged through a commit instruction and then transmitted to the SQL execution layer for processing.
On the basis of the technical scheme, the character string is packaged through the commit instruction and then is transmitted to the SQL execution layer for processing as the value of the params parameter.
On the basis of the technical scheme, the SQL execution layer analyzes the SQL statement carried by the params parameter in the commit instruction and stores the SQL statement into the DBqueue of the FM execution layer,
in the FM execution layer, a select instruction is issued by an execute query () method to query the database to obtain a query result resultSet,
and finally, returning the query result resultSet to the FM interface layer through the KWSqlResult parameter.
On the basis of the technical scheme, the KWSqlResult parameter at least comprises the following data:
success flag bit success, used to flag the result of SQL execution,
multiple data bits rows for storing query results comprising multiple data,
a single data bit id for storing a query result including one data,
and counting the bits num, and storing the query result comprising the statistical data.
Those not described in detail in this specification are within the skill of the art.
Claims (6)
1. An SQL statement packaging method based on FMDB is characterized by comprising the following steps:
at the FM interface layer, a UserDBmanager class is created for managing the user database,
the UserDBmanager class generates an object and invokes a method: AllModel (), the method internally calls the FMDB encapsulation function:
a table function for specifying a table in a user database,
a selectrarray function for specifying an operation to be performed,
an additional function for specifying optional additional instructions,
after the parameters in the functions are received and analyzed, the UserDBmanager class packages the analysis result through a commit instruction and then transmits the analysis result to the SQL execution layer for processing;
the parameter analysis means:
the userbmanager class forwards the received parameters to the SQL parameter layer,
in the SQL parameter layer, the SQL parameters are,
the table name parameters are parsed into standard table name assignment statements in SQL statements,
the operation command parameters are analyzed into standard operation and column name making statements in SQL statements,
the additional function is parsed into a standard additional function switch statement in an SQL statement,
after the SQL parameter layer is processed, the UserDBmanager class forwards the processing result to the SQL assembly layer, assembles the processing result into a standard SQL statement,
finally, the SQL assembly layer takes the assembled standard SQL statement as a character string and returns the character string to the UserDBmanager class.
2. An FMDB-based SQL statement encapsulation method according to claim 1, wherein: the optional additional instructions are associated with operational instruction parameters, including but not limited to: sorting instructions, number limiting instructions, conditional instructions.
3. An FMDB-based SQL statement encapsulation method according to claim 1, wherein: and the character string is packaged by the commit instruction and then transmitted to the SQL execution layer for processing.
4. A FMDB based SQL statement encapsulation method according to claim 3, wherein: and the character string is packaged by the commit instruction and then is transmitted to the SQL execution layer for processing as the value of the params parameter.
5. An FMDB-based SQL statement encapsulation method according to claim 4, characterized in that: after the SQL execution layer analyzes the SQL statement carried by the params parameter in the commit instruction, the SQL statement is stored in the DBQueue queue of the FM execution layer,
in the FM execution layer, a select instruction is issued by an execute query () method to query the database to obtain a query result resultSet,
and finally, returning the query result resultSet to the FM interface layer through the KWSqlResult parameter.
6. An FMDB-based SQL statement encapsulation method according to claim 5, characterized in that: the KWSqlResult parameter at least comprises the following data:
success flag bit success, used to flag the result of SQL execution,
multiple data bits rows for storing query results comprising multiple data,
a single data bit id for storing a query result including one data,
and counting the bits num, and storing the query result comprising the statistical data.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711042735.0A CN107818157B (en) | 2017-10-31 | 2017-10-31 | SQL statement packaging method based on FMDB |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711042735.0A CN107818157B (en) | 2017-10-31 | 2017-10-31 | SQL statement packaging method based on FMDB |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107818157A CN107818157A (en) | 2018-03-20 |
CN107818157B true CN107818157B (en) | 2021-06-29 |
Family
ID=61604438
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201711042735.0A Active CN107818157B (en) | 2017-10-31 | 2017-10-31 | SQL statement packaging method based on FMDB |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107818157B (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP1294126A1 (en) * | 2001-09-14 | 2003-03-19 | Siemens Aktiengesellschaft | Method to control the access to a fault management system of a communications network, fault management system and computer program |
CN104142944A (en) * | 2013-05-07 | 2014-11-12 | 杭州勒卡斯广告策划有限公司 | Method and system for encapsulating SQL statements |
CN105630508A (en) * | 2015-12-31 | 2016-06-01 | 广州亦云信息技术有限公司 | Processing method and processing system for encapsulating SQL (Structured Query Language) in Java system |
CN106095792A (en) * | 2016-05-27 | 2016-11-09 | 中国银联股份有限公司 | The method and apparatus generating database manipulation code |
CN106294776A (en) * | 2016-08-12 | 2017-01-04 | 北京东方车云信息技术有限公司 | A kind of data processing method and device |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7860904B2 (en) * | 2007-04-24 | 2010-12-28 | Microsoft Corporation | Standalone execution of incomplete data flows |
CN101847142A (en) * | 2009-03-25 | 2010-09-29 | 上海斯年信息技术有限公司 | Web page development method based on data sheet mould encapsulation |
CN102651010A (en) * | 2011-02-28 | 2012-08-29 | 国际商业机器公司 | Method, equipment and system for unloading database |
CN106599139B (en) * | 2016-12-05 | 2021-02-26 | 金蝶软件(中国)有限公司 | SQL processing method and device based on MyBatis framework |
-
2017
- 2017-10-31 CN CN201711042735.0A patent/CN107818157B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP1294126A1 (en) * | 2001-09-14 | 2003-03-19 | Siemens Aktiengesellschaft | Method to control the access to a fault management system of a communications network, fault management system and computer program |
CN104142944A (en) * | 2013-05-07 | 2014-11-12 | 杭州勒卡斯广告策划有限公司 | Method and system for encapsulating SQL statements |
CN105630508A (en) * | 2015-12-31 | 2016-06-01 | 广州亦云信息技术有限公司 | Processing method and processing system for encapsulating SQL (Structured Query Language) in Java system |
CN106095792A (en) * | 2016-05-27 | 2016-11-09 | 中国银联股份有限公司 | The method and apparatus generating database manipulation code |
CN106294776A (en) * | 2016-08-12 | 2017-01-04 | 北京东方车云信息技术有限公司 | A kind of data processing method and device |
Non-Patent Citations (1)
Title |
---|
"iOS平台移动学习资源构建及终端实现研究";牛丽 等;《中国教育信息化》;20150610;第(2015)卷(第12期);第18-21页 * |
Also Published As
Publication number | Publication date |
---|---|
CN107818157A (en) | 2018-03-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101021874B (en) | Method and apparatus for optimizing request to poll SQL | |
CN106777101B (en) | Data processing engine | |
GB2555544A9 (en) | International multi-language implementation method of configuration software | |
CN106933869B (en) | Method and device for operating database | |
CN108121542B (en) | MyBatis-based SQL statement configuration method and system | |
CN104133772A (en) | Automatic test data generation method | |
CN103714058A (en) | Database query optimization | |
CN104036007B (en) | A kind of distributed networks database query method and device | |
CN111104423B (en) | SQL statement generation method and device, electronic equipment and storage medium | |
RU2012157753A (en) | METHOD CARRIED OUT BY THE COMPUTER, CARRIER AND SYSTEM FOR INTEGRATING TRANSACTIONS WITH SEQUENCES OF PERFORMANCE ACTIONS AND DATABASES | |
CN111143403B (en) | SQL conversion method and device and storage medium | |
CN105653647B (en) | The information collecting method and system of SQL statement | |
CN102426612A (en) | Condition object query method and system | |
CN109656950B (en) | Recursive query method, device, server and storage medium | |
CN105630508A (en) | Processing method and processing system for encapsulating SQL (Structured Query Language) in Java system | |
WO2023045295A1 (en) | Data skew processing method, device, storage medium, and program product | |
CN107145538B (en) | Table data query method, device and system | |
CN107818157B (en) | SQL statement packaging method based on FMDB | |
CN111198898A (en) | Big data query method and big data query device | |
CN107729428A (en) | A kind of SQL query method based on Presto and Elasticsearch | |
CN108345603B (en) | SQL statement parsing method and device | |
CN107832387B (en) | SQL statement analysis method based on FMDB | |
CN111913704A (en) | VScode-based method for rapidly developing GSP7 script and plug-in tool | |
CN102354318B (en) | Device and method for reducing ad hoc query languages in database system | |
CN105607892A (en) | Concurrent execution method and system of multiple programs |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |