1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402
|
sqlite_new
SYNOPSIS
Create a new SQLite instance
USAGE
Struct_Type sqlite_new(String_Type filename)
DESCRIPTION
Create a new SQLite database object. This returns a structure with the
field `db' holding the actual SQLite handle, and the methods
get_table
get_row
get_array
exec
changes
prepare
SEE ALSO
sqlite_open, sqlite_get_table, sqlite_get_row, sqlite_get_array, sqlite_exec,
sqlite_changes, sqlite_prepare
--------------------------------------------------------------
sqlite_open
SYNOPSIS
Open a SQLite database
USAGE
Sqlite_Type sqlite_open(String_Type filename)
DESCRIPTION
Open the sqlite database file `filename'. If the database file does
not exist, then a new database will be created as needed. On failure a
`SqliteError' exception is thrown.
SEE ALSO
sqlite_new, sqlite_get_table, sqlite_get_array, sqlite_get_row, sqlite_exec, sqlite_changes
--------------------------------------------------------------
sqlite_get_table
SYNOPSIS
Get a table of results from a SQLite query
USAGE
String_Type[] sqlite_get_table(Sqlite_Type db, String_Type query)
DESCRIPTION
This executes a query and returns the result as a 2d array of strings.
The first row of the array contains the column headers. This function does
not support placeholders.
NOTES
You should only use this function if you need the column headers.
Otherwise, use `sqlite_get_array'
SEE ALSO
sqlite_open, sqlite_get_array, sqlite_get_row, sqlite_exec, sqlite_changes
--------------------------------------------------------------
sqlite_get_row
SYNOPSIS
Get a row of results from a SQLite query
USAGE
sqlite_get_row(Sqlite_Type db, String_Type query, ...)
DESCRIPTION
This executes a query and pushes the elements of the first row of the
result on the stack. This supports string, integer, float and blob
datatatypes. Blobs are returned as bstrings. If there are no rows, a
`SqliteError' exception is thrown even if the query executed flawlessly.
Question marks in the query are placeholders. Extra arguments to the
function are bound to these placeholders from left to right.
EXAMPLE
(foo, bar) = sqlite_get_row("SELECT foo, bar FROM table WHERE baz = ?", "quux");
NOTES
To get integers greater than INT_MAX, use `sqlite_get_array' with a
`LLONG_TYPE' type.
To get the result of a query that returns multiple rows, use
`sqlite_get_array' or use
foreach foo, bar (db) using ("SELECT foo, bar FROM table WHERE baz = ?", "quux")
{
....
}
Or in the object-oriented interface:
foreach foo, bar (db.db) using ("SELECT foo, bar FROM table WHERE baz = ?", "quux")
{
....
}
SEE ALSO
sqlite_open, sqlite_get_table, sqlite_get_array, sqlite_exec, sqlite_changes
--------------------------------------------------------------
sqlite_get_array
SYNOPSIS
Get a 2-D array from a SQLite query
USAGE
Array_Type sqlite_get_array(Sqlite_Type db, DataType_type type, String_Type query, ...)
DESCRIPTION
Executes a query and returns the result as a 2d array of type `type'.
This supports string, integer, long long, float and blob datatatypes.
Question marks in the query are placeholders. Extra arguments to the
function are bound to these placeholders from left to right.
SEE ALSO
sqlite_open, sqlite_get_table, sqlite_get_row, sqlite_exec, sqlite_changes
--------------------------------------------------------------
sqlite_exec
SYNOPSIS
Execute a SQLite query
USAGE
sqlite_exec(Sqlite_Type db, String_Type query, ...)
DESCRIPTION
Execute a SQL query on a sqlite database, without returning a result.
Question marks in the query are placeholders. Extra arguments to the
function are bound to these placeholders from left to right.
EXAMPLE
sqlite_exec(db, "INSERT INTO table(foo,bar,baz) VALUES (?,?,?)", 1, 2, 3);
Or in the object-oriented interface:
db.exec("INSERT INTO table(foo,bar,baz) VALUES (?,?,?)", 1, 2, 3);
SEE ALSO
sqlite_open, sqlite_get_table, sqlite_get_array, sqlite_get_row, sqlite_changes
--------------------------------------------------------------
sqlite_changes
SYNOPSIS
Get the number of rows affected by a SQLite query
USAGE
Int_Type sqlite_changes(Sqlite_Type db)
DESCRIPTION
This function returns the number of database rows that were changed (or
inserted or deleted) by the most recently completed INSERT, UPDATE, or
DELETE statement. The change count for "DELETE FROM table" will be zero
regardless of the number of elements that were originally in the table.
SEE ALSO
sqlite_open, sqlite_get_table, sqlite_get_array, sqlite_get_row, sqlite_exec
--------------------------------------------------------------
sqlite_prepare
SYNOPSIS
create a SQLite prepared statement
USAGE
Sqlite_Statement_Type sqlite_prepare(Sqlite_Type db, String query)
DESCRIPTION
Prepare a SQL query.
EXAMPLE
stmt = sqlite_prepare(db, "INSERT INTO table(foo,bar,baz) VALUES (?,?,?)");
`stmt' will now hold a Sqlite_Statement_Type.
Or using the object-oriented interface:
stmt = db.prepare("INSERT INTO table(foo,bar,baz) VALUES (?,?,?)");
`stmt' will now hold a struct with, a field `stmt' holding the
Sqlite_Statement_Type, a field `db' holding the Database object, and the
methods
bind_params
step
fetch
reset
NOTES
In the procedural interface, you should destroy all prepared statements before
the database goes out of scope. Otherwise the database will not be
closed. In the object-oriented interface, this is ensured by the Statement
object holding a reference to the Database object.
SEE ALSO
sqlite_bind_params, sqlite_step, sqlite_fetch, sqlite_reset
--------------------------------------------------------------
sqlite_bind_params
SYNOPSIS
bind values to a prepared statement
USAGE
int sqlite_bind_params(Sqlite_Statement_Type, ..)
DESCRIPTION
Bind values to a prepared statement. Arguments are bound to placeholders
in the statement from left to right. If called with fewer arguments than
the prepared statement has placeholders, the remaining bindings are not modified.
Parameter bindings are not affected by `sqlite_reset'.
EXAMPLE
stmt = sqlite_prepare(db, "insert into table(foo, bar) values (?,?)");
sqlite_bind_params(stmt, "foo", "bar");
slite_bind_params(stmt, "baz");
The first parameter will now be set to ``baz'', the second to ``bar''.
The object-oriented method `bind_params' also supports named
parameters as qualifiers.
stmt = db.prepare("insert into table(foo, bar) values (:foo,:bar)");
stmt.bind_params(stmt, "foo", "bar");
stmt.bind_params(; bar = "baz");
Now the first parameter will be ``foo'', the second will be ``baz''.
NOTES
This function must be called after `sqlite_prepare' or
`sqlite_reset' and before `sqlite_step'. Bindings are not
cleared by the `sqlite_reset' routine. Unbound parameters are
interpreted as NULL.
SEE ALSO
sqlite_prepare, sqlite_bind_param, sqlite_step, sqlite_fetch, sqlite_reset
--------------------------------------------------------------
sqlite_bind_param
SYNOPSIS
bind a value to a prepared statement
USAGE
int sqlite_bind_params(Sqlite_Statement_Type, Int_Type n, value)
DESCRIPTION
In the SQL strings input to `sqlite_prepare', literals may be
replaced by a parameter in one of these forms:
?
?NNN
:VVV
@VVV
$VVV
In the parameter forms shown above NNN is an integer literal, VVV is an
alpha-numeric parameter name. The values of these parameters can be set
using the `sqlite_bind_param' function.
The first argument to `sqlite_bind_param' is a prepared statement
returned by `sqlite_prepare'. The second argument is the index of
the parameter, counting from 1. When the same named parameter is used
more than once, second and subsequent occurrences have the same index as
the first occurrence. The index for named parameters can be looked up
using the function `sqlite_bind_parameter_index' if desired. The
index for ``?NNN'' parameters is the value of NNN.
NOTES
You can set all parameters at once with `sqlite_bind_params'. To set
a specific parameter, you can use named parameters of the ``:VVV'' form
with the object method `bind_params'.
SEE ALSO
sqlite_prepare, sqlite_bind_params, sqlite_bind_parameter_index, sqlite_step, sqlite_fetch, sqlite_reset
--------------------------------------------------------------
sqlite_bind_parameter_index
SYNOPSIS
Return the index of an SQL parameter given its name
USAGE
int sqlite_bind_parameter_index(Sqlite_Statement_Type S, String_Type N)
DESCRIPTION
The `sqlite_bind_parameter_index' function returns the index of the
SQL parameter in prepared statement `S' whose name matches the string `N',
or 0 if there is no match.
SEE ALSO
sqlite_bind_param
--------------------------------------------------------------
sqlite_step
SYNOPSIS
evaluate a prepared statement
USAGE
int sqlite_step(Sqlite_Statement_Type, ..)
DESCRIPTION
This function evaluates a prepared statement.
This function returns a SQLite return code. If the query has completed, it
returns SQLITE_DONE (101). If the query has a result row ready, it returns
SQLITE_ROW (100). If SQLite returns an error code, this function throws a
SqliteError.
NOTES
If you want to execute a query and iterate over the results, use
stmt = db.prepare("sql");
stmt.bind_params("foo", "bar")
while (SQLITE_ROW == stmt.step())
{
result = stmt.fetch();
}
Or
foreach result (db.db) using ("sql", "foo", "bar")
{
...
}
If you want to execute a query multiple times with different parameters,
you would use
stmt = db.prepare("sql");
foreach param (array)
{
stmt.bind_params(param);
()=stmt.step());
stmt.reset();
}
SEE ALSO
sqlite_prepare, sqlite_bind_params, sqlite_fetch, sqlite_reset
--------------------------------------------------------------
sqlite_fetch
SYNOPSIS
Get a row of results from a prepared statement
USAGE
sqlite_fetch(Sqlite_Statement_Type)
DESCRIPTION
This pushes the elements of the current result row of a prepared statement
on the stack.
SEE ALSO
sqlite_prepare, sqlite_step, sqlite_reset, sqlite_get_row
--------------------------------------------------------------
sqlite_reset
SYNOPSIS
reset a prepared statement
USAGE
sqlite_reset(Sqlite_Statement_Type S)
DESCRIPTION
The `sqlite_reset' function resets the prepared statement `S' back to the
beginning of its program.
SEE ALSO
sqlite_prepare, sqlite_bind_params, sqlite_step, sqlite_fetch
--------------------------------------------------------------
|