From d8bb994629a017b9ab74bb647dae3ccc21164a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Tue, 29 Sep 2015 10:40:15 +0200 Subject: [PATCH] README.md --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e2fbaacbe..6c261318b 100644 --- a/README.md +++ b/README.md @@ -243,6 +243,8 @@ The last two methods are the only ones that don't take a custom SQL query as an - [RowConvertible Protocol](#rowconvertible-protocol) +#### Fetching Rows + Fetch **sequences** of rows, **arrays**, or a **single** row: ```swift @@ -263,7 +265,13 @@ Row.fetch(db, "SELECT * FROM persons WHERE name = :name", arguments: ["name": "A Do use those arguments: they prevent nasty users from injecting [nasty SQL snippets](https://en.wikipedia.org/wiki/SQL_injection) into your SQL queries. -**Row sequences grant the fastest and the most memory-efficient access to SQLite**, much more than row arrays that hold copies of the database rows. +**Row sequences grant the fastest and the most memory-efficient access to SQLite**, much more than row arrays that hold copies of the database rows: + +```swift +for row in Row.fetch(db, "SELECT ...") { + // Can't be closer to SQLite +} +``` > **Note**: this performance advantage comes with extra precautions when using row sequences: > @@ -307,6 +315,8 @@ let dateString: String = row.value(named: "date") // "2015-09-11 18:14:15. let date: NSDate = row.value(named: "date") // NSDate ``` +Don't miss the [NSData](#nsdata-and-memory-savings) paragraph if you target memory efficiency. + You can also use the `as` type casting operator: ```swift