PHP code example of ice-cream / database

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

    

ice-cream / database example snippets


use IceCreamDatabase\Connect;

// Similar to that of Laravel if you are familiar.
$connections = [
  'mysql' => [
    'host' => '127.0.0.1',
    'port' => 3306,
    'database' => '',
    'username' => 'root',
    'password' => 'root',
    'charset' => 'utf8',
  ],
  'pgsql' => [
    'host' => '127.0.0.1',
    'port' => 5432,
    'dbname' => 'scotchbox',
    'username' => 'root',
    'password' => 'root',
    'charset' => 'utf8',
  ],
  'sqlite' => [
    'temp_file' => ':memory'
  ]
]

// At this time I have made the choice to only support mysql and pgsql as well as sqlite connections.
// More can be added in the future, simplicity was the game here.

$con = new Connect($connections);

$con->db()->exec( ... );

// Should you have multiple databases configured you can do:

$con->db('mysql')->exec( ... );
$con->db('pgsql')->exec( ... );
$con->db('sqlite')->exec( ... );

// Get the current connection name:
$con->manager()->getCurrentConnectionName(); // mysql, sqlite or pgsql