PHP code example of mvc-package / mysql-db

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

    

mvc-package / mysql-db example snippets



use Php\Db\db;
$db = new DB();

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

/* insert/update/delete */
$db->table('tablename')->insert(['id' => $id])->execute();
$db->table("tablename")->update(['username' => "donia2000" ])->where("username", "=", 'donia')->execute();
$db->delete('tablename')->where(['id' => $id])->excute();

/* select */
$db->table("tablename")->select('columns')->all();
$db->table("tablename")->select('columns')->first();
$db->table("tablename")->select('columns')->where(['id' => $id])->first();

$db->table("tablename")->select('columns')->where(['id' => $id])->andWhere(['id' => $id])->first();

$db->table("tablename")->select('columns')->where(['id' => $id])->orWhere(['id' => $id])->first();