PHP code example of seniorclass / db

1. Go to this page and download the library: Download seniorclass/db library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

seniorclass / db example snippets



use Senior\Db\db;
$db = new db($server,$user,$pass,$db);

/* connect to database */
$db = new db('127.0.0.1', 'username', 'password', 'database', 3306);

/* insert/update/delete */
$id = $db->insert('tablename', ['col1' => 'foo'])->excu();
$db->update('tablename', ['col1' => 'bar'])->where(['id' => $id])->excu();
$db->delete('tablename')->where(['id' => $id])->excu();

/* select */
$db->select('tablename','columns')->getAll();
$db->select('tablename','columns')->getRow();
$db->select('tablename','columns')->where(['id' => $id])->getRow();

$db->select('tablename','columns')->where(['id' => $id])->andWhere(['id' => $id])->getRow();

$db->select('tablename','columns')->where(['id' => $id])->orWhere(['id' => $id])->getRow();