PHP code example of ahmedmaher0 / maher

1. Go to this page and download the library: Download ahmedmaher0/maher 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/ */

    

ahmedmaher0 / maher example snippets



use Ahmed\Maher\db as class_db;
$db = new class_db();

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

/* insert/update/delete */
$db->insert('tablename', [ 'key' => 'value' ])->excute();                         // return = true OR false
$db->update('tablename', [ 'key' => 'value' ])->where(['id' => $id])->excute();   // return = true OR false
$db->delete('tablename')->where(['id' => $id])->excute();                         // return = true OR false

/* select */
$db->select('tablename', 'columns')->rows();    // return more than one row
$db->select('tablename', 'columns')->first();   // return 1 Row Data
$db->select('tablename', 'columns')->where(['id' => $id])->first();    // return 1 Row Data

$db->select('tablename', 'columns')->where(['id' => $id])->andWhere(['id' => $id])->first(); // return 1 Row Data

$db->select('tablename', 'columns')->where(['id' => $id])->orWhere(['id' => $id])->first(); // return 1 Row Data