} $res = sqlite3_query($db, "insert into test (a,b,c, d) VALUES (?, ?, ?, ?)"); if (!$res) { die(sqlite3_error($db)); } if (!sqlite3_bind_int($res, 1, 10)) { die(sqlite3_error($db)); } if (!sqlite3_bind_text($res, 2, "bob")) { die(sqlite3_error($db)); } if (!sqlite3_bind_double($res, 3, 3.1415)) { die(sqlite3_error($db)); } if (!sqlite3_bind_blob($res, 4, file_get_contents("/bin/sh"))) { die(sqlite3_error($db)); } if (!sqlite3_query_exec($res, TRUE)) { /* TRUE: delete the resource after the execution */ die(sqlite3_error($db)); } $res = sqlite3_query($db, "SELECT * from test"); if (!$res) { die(sqlite3_error($db)); } $a_row = sqlite3_fetch_array($res); for ($n = 0; $n < sqlite3_column_count($res); $n++) { echo "column {$n}: type " . $col_types[sqlite3_column_type($res, $n)] . "\n"; } sqlite3_query_close($res); sqlite3_close($db);
/** * Get the the number of columns in a result set * * @return int the number of columns. A DB_Error object on failure. */ function numCols($result) { return sqlite3_column_count($result); }
public function numColumns() { return sqlite3_column_count($this->query); }