Function | Description |
support | Check SQLite support using phpinfo() |
Connection | Connection to DB and creating table |
Display | Display multiple rows using Parameter query |
Display | Display single row using Parameter query |
Update | Update and get number of records updated |
insert | Add records to table and display the record ID |
delete | delete records and get number of affected by query |
drop | delete table if exists |
ACID | Atomicity, Consistency, Isolation, Durability |
Blob | Binary Large Object to store images audio files, videos etc. |
Form | Collect user inputs and store in SQLite database table. |
Login | Simple Login system using SQLite & PHP PDO . |
Function | Description |
LIKE | String Pattern matching using wildcards |
LIMIT | Strting position and number of records to return |
DISTINCT | Unique data from the Column |
MAX | Highest value of the column and record details |
MIN | Lowest value of the column and record details |
$sql="CREATE TABLE student1(
a TEXT,
b NUMERIC,
c INTEGER,
d REAL,
e BLOB
)";
$count=$my_conn->prepare($sql);
<?php
// Create (connect to) SQLite database in file
//$my_conn = new PDO('sqlite:D:\\sqlite-data\\my_student.db');// different path
$my_conn = new PDO('sqlite:'.dirname(__FILE__).'/my_student.db'); // same location
// Set errormode to exceptions
$my_conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$sql="SELECT * FROM student LIMIT 0,5";
echo "<table>";
foreach ($my_conn->query($sql) as $row) {
echo "<tr ><td>$row[id]</td><td>$row[name]</td></tr>";
}
echo "</table>";
?>
PHP PDO offers a standard way to connect to SQLite databases. This connection ensures flexibility across different database systems without changing much code. Example:
$pdo = new PDO('sqlite:database.db');
Prepared statements help protect your application from SQL injection by separating SQL code from user input.
PDO provides methods like fetch() and fetchAll() for retrieving query results.
PDO offers built-in error handling methods to capture exceptions when a query or connection fails.
Use PDO transactions for safely executing multiple related queries, ensuring database integrity.
With PDO, queries can be parameterized to dynamically bind values during execution, ensuring security and efficiency.
PDO simplifies performing Create, Read, Update, and Delete (CRUD) operations securely and efficiently.
SQLite supports dynamic typing, allowing flexibility in handling various data types.
PDO’s lastInsertId() method retrieves the ID of the last inserted row, helpful for tracking new records.
SQLite supports in-memory databases, enabling faster, temporary database operations ideal for testing.
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.