PHP code example of mocodo / sql

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

    

mocodo / sql example snippets




use Mocodo\Driver\MySQLConnection

$pdo = new MySQLConnection('mysql:127.0.0.1;dbname=test', 'root', 'root', [...]);

$query = 'SELECT foo, bar FROM my_table WHERE 1';

$stmt = $pdo->find($query, [
    'conditions' => [
        'foo' => 'foobar',
        'bar LIKE' => '%.com',
    ]
]);

// SELECT foo, bar FROM my_table WHERE 1 AND foo = 'foobar' AND bar LIKE '%.com'