PHP code example of joaomfrebelo / db

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

    

joaomfrebelo / db example snippets


    $config = [
            'driver'   => 'Pdo_Mysql',
            'username' => 'root',
            'password' => 'password',
            'charset'  => 'utf8',
            'hostname' => 'localhost',
            'database' => 'sakila'];
$adapter = new \Rebelo\Db\Adapter\Adapter($config);
$result  = $adapter->select()->from("actor")->fetch();

$result  = $adapter->select("actor")->fetchRow();

$result  = $adapter->select("actor")
            ->columns([
                new \Zend\Db\Sql\Expression("COUNT(*)")])
            ->fetchOne();

$result  = $adapter->select("actor")
            ->limit(5)->offset(1)
            ->fetch();

$adapter->insert("language")->values([
            "language_id" => "9",
            "name"        => "PT"
        ])->execute();

$adapter->update("language")->set([
                "name" => "Portuguese"])
            ->where([
                "language_id" => 9])
            ->execute();

$adapter->delete("language")->where([
                "language_id" => 9])
            ->execute();

$adapter->beginTransaction();
$result = $adapter->select("film")->fetchOne();
$result2 = $adapter->select()->from("city")
            ->where([
                "city_id" => 288])
            ->fetchRow();
$adapter->commit();