PHP code example of quellabs / canvas-database

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

    

quellabs / canvas-database example snippets


use Cake\Database\Connection;

class MyController {
    public function __construct(
        private Connection $db
    ) {}
    
    public function index() {
        $results = $this->db->execute('SELECT * FROM users')->fetchAll('assoc');
    }
}

return [
    'driver'   => 'mysql',
    'host'     => 'localhost',
    'database' => 'myapp',
    'username' => 'root',
    'password' => '',
    'port'     => 3306,
    'encoding' => 'utf8mb4',
];