-
Notifications
You must be signed in to change notification settings - Fork 0
insertRecord
Ayoob edited this page Apr 11, 2020
·
2 revisions
[easySQLite3 >= v0.1.0 (Beta)]
Insert data to a database using prepared statement.
insertRecord( [ string $table_name [, array $data_array ]] ) : object
This function is used to insert data to a database using prepared statement.
The prepared statement will be applied automatically.
Parameter | Description |
---|---|
table_name |
The table name to insert data to. |
data_array |
Array containing the data to insert. Can be taken from the functions setData() and getData() . |
Returns an SQLite3Result object on successful inserting of data, false
on failure
Example #1 : Insert data.
include "easySQLite3.class.php";
$db = new easySQLite3("database.sqlite");
$db->setTable( "TableName" );
$db->clearData();
$db->setData("id", null); // Will set null value for the column 'id' as it's auto-incremented.
$db->setData("mail", "[email protected]"); // Will set '[email protected]' for the column 'mail'.
$db->setData("url", "https://example.com"); // Will set 'https://example.com' for the column 'url'.
$db->setData("timestamp", date("Y-m-d H:i:s")); // Will set the current date for the column 'timestamp' in the format of 'YYYY-MM-DD HH:MM:SS'.
$db->setData("status", 0); // Will set '0' for the column 'status'.
if ( $db->insertRecord() ) {
echo "Data has been added.";
}
- setData - Set data to insert into a table, or update a record in a table.
-
getData - Get the temporary data that was created using
setData()
function. -
clearData - Clears temporary data that was created using
setData()
function. - isTable - Check if table exits in a database.
- setTable - Set the default Table name to work with.