phpSniper is a PHP library that provides a collection of functions to simplify database operations such as CRUD (Create, Read, Update, and Delete) and other common tasks in PHP web development.
- PHP 5.4 or higher
- MySQL 5.0 or higher
- Clone the phpSniper repository or download it as a zip file and extract it in your project folder.
- Open the
functions/config.php
file and enter your MySQL database credentials. - Include the
sniper.php
file in your PHP script to start using the library.
Here's an example of how to use the select
function to retrieve all rows from a database table:
include 'path/to/sniper.php';
$rows = select('users');
foreach ($rows as $row) {
echo $row['name'];
}
include 'path/to/sniper.php';
$table = 'users';
$columns = 'name, email';
$values = "'John Doe', '[email protected]'";
$inserted = insert($table, $columns, $values);
if ($inserted) {
echo "Data inserted successfully!";
} else {
echo "Failed to insert data!";
}
connect()
- Establish a database connectioncloseConnection()
- Close the database connectioninsert($table, $cols, $values)
- Insert data into a database tableupdateRow($table, $colsAndValues, $conditions)
- Update multiple columns and values in a database tableupdateCol($table, $col, $value, $key, $id)
- Update a single column value in a database tabledelete($table, $condition)
- Delete row(s) from a database table based on a conditionsearch($data, $query)
- Search for a string in datagetInfo($table, $condition, $cols = null)
- Retrieve complete row information from a database table.
phpSniper is open source software released under the MIT license.