renamed page files

This commit is contained in:
Guenter Obiltschnig 2012-10-13 09:07:34 +00:00
parent 0b6c8aa1e0
commit 045c23a9f6
4 changed files with 22 additions and 25 deletions

View File

@ -38,8 +38,8 @@ The following complete example shows how to use it:
}
----
The above example is pretty much self explanatory. The <[Poco/Data/Common.h]> file pulls in some common includes,
the SQLite::Connector is used to register the SQLite connector so that we can later create an SQLite session
The above example is pretty much self explanatory. First we pull in some necessary header files.
The SQLite::Connector is used to register the SQLite connector so that we can later create an SQLite session
via the SessionFactory. The two-argument constructor
Sesssion ses("SQLite", "sample.db");
@ -51,8 +51,8 @@ is actually equivalent to:
The << operator is used to send SQL statements to the Session, the <*into(count)*> simply informs the session where to store the result of the query.
Take note of the <!now!> at the end of the SQL statement. It is required, otherwise the statement would not be executed.
The <* <[ using namespace Poco::Data ]> *> is for convenience only but highly recommended for good readable code
(while <* <[ ses << "SELECT COUNT(*) FROM PERSON", Poco::Data::into(count), Poco::Data::now; ]> *> is valid, it simply looks... strange).
The <* <[ using namespace Poco::Data::Keywords ]> *> is for convenience only but highly recommended for good readable code
(while <* <[ ses << "SELECT COUNT(*) FROM PERSON", Poco::Data::Keywords::into(count), Poco::Data::Keywords::now; ]> *> is valid, it simply looks... strange).
The remainder of this tutorial is split up into the following parts:
* Creating Sessions
@ -81,7 +81,7 @@ Inserting data works by <* using *> the content of other variables. Assume we ha
If we want to insert one single forename we could write:
std::string aName("Peter");
ses << "INSERT INTO FORENAME VALUES(" << aName << ")", now;
ses << "INSERT INTO FORENAME VALUES('" << aName << "')", now;
----
Another way is to use <!placeholders!> and connect each placeholder via a <!use!>
@ -93,9 +93,9 @@ Universal placeholders are question marks <!?!> . Rewriting the above code now s
----
In this example the <!use!> expression matches the <* ? *> with the <*Peter*> value.
Note that apart from the nicer syntax, the real benefit of placeholders - which is performance - doesn't show here.
Some database systems (e.g. SQLite) support descriptive placeholders (e.g. !:name!) but, for universal appliciablity,
it is recommended to use the questin mark.
Note that apart from the nicer syntax, the real benefits of placeholders - which are performance and security against SQL injection attacks - don't show here.
Some database systems (e.g. SQLite) support descriptive placeholders (e.g. <[:name]>) but, for universal applicability,
it is recommended to use the question mark.
Check the <*Working with Statements*> section to find out more.
@ -111,7 +111,7 @@ It is also possible to combine into and use expressions:
std::string aName;
std::string match("Peter")
ses << "SELECT NAME FROM FORENAME WHERE NAME=:name", into(aName), use(match), now;
ses << "SELECT NAME FROM FORENAME WHERE NAME = ?", into(aName), use(match), now;
poco_assert (aName == match);
----
@ -131,16 +131,16 @@ The same is true for the <*into*> statement. We select <*firstname*> as the firs
thus <*into(firstName)*> must be the first into clause.
!! Handling NULL entries
A common case with databases are optional data fields that can contain NULL. To accomodate for NULL, use Nullable template:
A common case with databases are optional data fields that can contain NULL. To accomodate for NULL, use the Poco::Nullable template:
std::string firstName("Peter";
std::string lastName("Junior");
Nullable<int> age = 0;
Poco::Nullable<int> age = 0;
ses << INSERT INTO PERSON VALUES (?, ?, ?)", use(firstName), use(lastName), use(age), now;
ses << "SELECT (firstname, lastname, age) FROM Person", into(firstName), into(lastName), into(age), now;
----
Nullable is a template wrapping any type with purpose of allowing it to have null value.
Poco::Nullable is a template wrapping any type with purpose of allowing it to have null value.
!!!Working with Statements
We mentioned the term <*Statement*> in the previous section, yet we only worked with database session objects so far.
@ -180,7 +180,7 @@ simply guarantees that the statement was fully completed.
!!Prepared Statements
A prepared statement is created by omitting the <*now*> clause.
Statement stmt = ( ses << "INSERT INTO FORENAME VALUES(:name)", use(aName) );
Statement stmt = ( ses << "INSERT INTO FORENAME VALUES(?)", use(aName) );
----
The advantage of a prepared statement is performance. Assume the following loop:

View File

@ -8,13 +8,13 @@ to existing code.
!!Summary of Changes
- RowFormatter class for convenient output formatting.
- Stored procedures support (for databases that support it).
- Transaction support (for databases that support it).
- Poco::Data::RowFormatter class for convenient output formatting.
- Stored procedures support (for databases and ODBC drivers that support it).
- Improved transaction support (for databases that support it).
- Bulk execution (for ODBC drivers that support it).
- Batch queries and multiple results (for databases and ODBC drivers that support it).
- Stored procedures/functions support (for databases that support it)
- Session pool containers.
- New Poco::Data::SessionPoolContainer class.
!!Incompatible Changes and Possible Transition Issues

View File

@ -1,3 +0,0 @@
For the latest version of the documentation go to
http://appinf.com/poco/wiki/tiki-index.php?page=Data