PHP code example of rougin / describe

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

    

rougin / describe example snippets

 php
// index.php

use Rougin\Describe\Driver\MysqlDriver;

$dsn = 'mysql:host=localhost;dbname=test';

$pdo = new PDO($dsn, 'root', '');

$driver = new MysqlDriver($pdo, 'test');
 php
use Rougin\Describe\Driver\DatabaseDriver;

$creds = array('password' => '');

$creds['hostname'] = 'localhost';
$creds['database'] = 'test';
$creds['username'] = 'root';

$driver = new DatabaseDriver('mysql', $creds);
 php
// index.php

/** @var \Rougin\Describe\Column[] */
$columns = $driver->columns('users');
 php
namespace Rougin\Describe\Driver;

interface DriverInterface
{
    /**
     * Returns a list of columns from a table.
     *
     * @param  string $table
     * @return \Rougin\Describe\Column[]
     */
    public function columns($table);

    /**
     * Returns a list of tables.
     *
     * @return \Rougin\Describe\Table[]
     */
    public function tables();
}
 php
use Rougin\Describe\Table;

$table = new Table('users', $driver);

/** @var \Rougin\Describe\Column[] */
$columns = $driver->columns();

/** @var \Rougin\Describe\Column */
$primary = $driver->primary();