https://github.com/systemvll/database-php-class
A pre-builded php class for using mysql without caring about SQL and XSS attacks
https://github.com/systemvll/database-php-class
Last synced: 11 months ago
JSON representation
A pre-builded php class for using mysql without caring about SQL and XSS attacks
- Host: GitHub
- URL: https://github.com/systemvll/database-php-class
- Owner: SystemVll
- Created: 2022-05-25T18:05:54.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-26T22:06:21.000Z (about 4 years ago)
- Last Synced: 2025-06-28T04:13:08.590Z (11 months ago)
- Language: PHP
- Homepage:
- Size: 5.86 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Mysql Database Class
This php class is a simple oriented object mysql client base
on pdo, it **preventing** from ***SQL*** injection and ***XSS*** attacks.
#### Init the database object
```php
require 'class/database.class.php'
$GLOBALS['MYSQL'] = new Database(
"localhost",
"database",
"username",
"password"
);
```
#### Getting data from SQL tables
```php
// returning an array of all the table content
$GLOBALS['MYSQL']->getContent("table");
// returning an array of all the table content where exemple_colum is equal to 30
$GLOBALS['MYSQL']->getContent("table", ["exemple_colum" => 30]);
```
#### Inserting data into database
```php
// Inserting a new line to the table with exemple_colum equal to 30
$GLOBALS['MYSQL']->Insert("table", [
"exemple_colum" => 30
]);
// Inserting a new line to the table with exemple_colum equal to 30 without the XSS filter
$GLOBALS['MYSQL']->Insert("table", [
"exemple_colum" => 30
], false);
```
#### Updating data into database
```php
// Put 60 in the column exemple_colum whre exemple_colum equal to 30
$GLOBALS['MYSQL']->update("table", [
"exemple_colum" => 30
], [
"exemple_colum" => 60
]);
// Put 60 in the column exemple_colum whre exemple_colum equal to 30 without the XSS filter
$GLOBALS['MYSQL']->update("table", [
"exemple_colum" => 30
], [
"exemple_colum" => 60
], false);
```
#### Delete a line
```php
// Delete lines where exemple_colum equal to 60
$GLOBALS['MYSQL']->delete("table", [
"exemple_colum" => 60
]);
```