PHP Classes

Connection MSi: Access MySQL database using MySQLi functions

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2023-06-02 (3 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 287 All time: 7,507 This week: 257Up
Version License PHP version Categories
connection-msi 1.0.11GNU General Publi...5PHP 5, Databases
Description 

Author

This class can access MySQL database using MySQLi functions.

It can connect to a given MySQL database server and perform several type of common operations using given parameters like executing SELECT, INSERT, UPDATE and DELETE queries, creating and dropping tables, and managing transactions.

In Portuguese:

Classe de conexão com MySQLi de uma forma mais prática, com métodos de

- CREATE
- DROP
- INSERT
- UPDATE
- DELETE
- SELECT
- ExecuteSQL (execução SQL genérico)
- TRANSACTION

Picture of Carlos Eduardo Barcelos Amaral
  Performance   Level  
Name: Carlos Eduardo Barcelos ... <contact>
Classes: 3 packages by
Country: Brazil Brazil
Age: 32
All time rank: 2177145 in Brazil Brazil
Week rank: 333 Up22 in Brazil Brazil Up

Details

ConnectionMSi

ConnectionMSi is a PHP class to carry out the management of the database in a more practical way.

ConnectionMSi é uma classe PHP para realizar a gestão do banco de dados de uma forma mais prática.

Methods

- Drop - Create - Insert - Update - Delete - Select - ExecuteSQL (generic query) - Transaction (Begin, Rollback, Commit)

Connection

$host = 'localhost';
$user = 'root';
$pass = '';
$base = 'test';

$con = new ConnectionMSi($host,$user,$pass,$base);

DROP

$con->Drop('tab_teste');

CREATE

$fields = Array(
      'id' => Array(
         'type' => 'int',
         'size' => '4',
         'comment' => 'first key'
      ),
      'name' => Array(
         'type' => 'varchar',
         'size' => '60',
         'comment' => 'test name'
      ),
      'col3' => Array(
         'type' => 'varchar',
         'size' => '60',
         'default' => NULL,
         'comment' => 'test name'
      )
   );
   $con->Create('tab_teste',$fields,'id','InnoDB',false);

The fifth parameter is to drop the table if it exists.

O quinto parâmetro é para eliminar a tabela, se existir.

INSERT

$con->Begin();
$data = Array('id'=>1,'name' => 'First Record', 'col3' => 'test ');
$con->Insert('tab_teste',$data);
$data = Array('id'=>2,'name' => 'Second Record', 'col3' => 'test ');
$con->Insert('tab_teste',$data);
$data = Array('id'=>3,'name' => 'Third Record', 'col3' => 'test ');
$con->Insert('tab_teste',$data);
$con->Commit();

DELETE

$where = Array('id'=>1);
$con->Delete('tab_teste', $where);

UPDATE

$data = Array(
   'name' => 'Now this is the first record', 
   'col3' => 'First record'
);
$where = Array('id'=>2);
$con->Update('tab_teste',$data, $where);

SELECT

$where = Array('id' => Array('BETWEEN'=>Array(2,3)));
$res = $con->Select('tab_teste',$where);
$tab = $res->fetch_all(MYSQLI_ASSOC);

Select Result for $tab

------------------------------------------------------
| id | name                           | col3         |
------------------------------------------------------
| 2  | Now this is the first record   | First record |
------------------------------------------------------
| 3  | Third Record                   | test         |
------------------------------------------------------

WHERE

$where = 'id = 1'; 
// Result: id = 1

$where = Array('id' => 1); 
// Result: id = 1

$where = Array('id' => 1,'OR','col3' => 'test'); 
// Result: id = 1 OR col3 = 'test'

$where - Array('col3' => array('LIKE' => 'recor'))
// Result: col3 LIKE '%recor%'

$where = Array('id' => Array(1,'>>>',10, Array(3,6,8))); 
// Result: id IN (1,2,4,5,7,9,10)

$where = Array('id' => Array('BETWEEN' => Array(1,10)));
// Result:  id BETWEEN 1 AND 10

$where = Array('id' => Array('NOT' => Array(1,2,3,12,45)));
// Result: id NOT IN (1,2,3,12,45)

$where = Array('id' => Array('NOT' => Array(1,'>>>',10, Array(3,6,8)))); 
// Result: id NOT IN (1,2,4,5,7,9,10)


$where = Array(
  'id' => array('NOT' => array(1,'>>>',6,array(3,5))),
  'OR',
  'col3' => array('LIKE' => 'recor')
);
// Result: id NOT IN (1, 2, 4, 6) OR col3 LIKE '%recor%'

Version

1.0.0

License

GPL v2

Project

Author: Kaduamaral

Devcia: ConnectionMSi Docs

GitHub: Project

Screenshots  
  • ss3.png
  • ss2.png
  • ss1.png
  Files folder image Files  
File Role Description
Accessible without login Plain text file README.md Doc. Readme
Accessible without login Plain text file example.php Example Exemplos
Plain text file ConnectionMSi.php Class ConnectionMSi Class
Accessible without login Plain text file LICENSE Data Create

 Version Control Unique User Downloads Download Rankings  
 57%
Total:287
This week:0
All time:7,507
This week:257Up