PHP code example of migliori / power-lite-pdo

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

    

migliori / power-lite-pdo example snippets


    use Migliori\PowerLitePdo\Db;

    // Build the container and connect to the database
    $container = 

    $from = 'users'; // The table name
    $fields = ['id', 'username', 'email']; // The columns you want to select
    $where = ['status' => 'active']; // The conditions for the WHERE clause

    $db->select($from, $fields, $where);
    

    while ($record = $db->fetch()) {
        echo $record->id . ', ' . $record->username . ', ' . $record->email . "\n";
    }
    

    use Migliori\PowerLitePdo\Query\QueryBuilder;

    // Build the container and connect to the database
    $container = 

    $queryBuilder->select(['id', 'username', 'email'])->from('users')->where(['status' => 'active'])->execute();
    

    while ($record = $queryBuilder->fetch()) {
        echo $record->id . ', ' . $record->username . ', ' . $record->email . "\n";
    }
    

    use Migliori\PowerLitePdo\Pagination;

    // Build the container and connect to the database
    $container = 

    $from = 'users'; // The table name
    $fields = ['id', 'username', 'email']; // The columns you want to select
    $where = ['status' => 'active']; // The conditions for the WHERE clause

    $pagination->select($from, $fields, $where);
    

    while ($record = $pagination->fetch()) {
        echo $record->id . ', ' . $record->username . ', ' . $record->email . "\n";
    }
    

    $url = '/users'; // The URL for the pagination links
    echo $pagination->pagine($url);
    
bash
php ./vendor/bin/phpunit test