mirror of
https://github.com/SOCI/soci.git
synced 2026-05-09 05:09:51 -05:00
Demonstrate use() in the examples on the landing page
While using ints is safe from the point of view of SQL injection, it's still not a great example, so use parameters instead of building the SQL query by simple string concatenation.
This commit is contained in:
+3
-3
@@ -15,8 +15,8 @@ int id = ...;
|
||||
std::string name;
|
||||
int salary;
|
||||
|
||||
sql << "select name, salary from persons where id = " << id,
|
||||
into(name), into(salary);
|
||||
sql << "select name, salary from persons where id = :id",
|
||||
use(id), into(name), into(salary);
|
||||
```
|
||||
|
||||
## Basic ORM
|
||||
@@ -28,7 +28,7 @@ int id = ...;
|
||||
Person p;
|
||||
|
||||
sql << "select first_name, last_name, date_of_birth "
|
||||
"from persons where id = " << id, into(p);
|
||||
"from persons where id = :id", use(id), into(p);
|
||||
```
|
||||
|
||||
## Integrations
|
||||
|
||||
Reference in New Issue
Block a user