PHP code example of crudly / connectly

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

    

crudly / connectly example snippets


$connectly = Connectly::create([
	'name' => 'My connection',
	'config' => [
		'driver' => 'mysql',
		'host' => '127.0.0.1',
		'port' => '3306',
		'database' => 'connectly_test_base',
		'username' => 'connectly_user',
		'password' => 'hunter2',
	],
]);

$myCon = Connectly::where('name', 'My connection')->first();

$connection = $myCon->connect();   // This is a Laravel DB connection

$connection->table('users')->get();



use Crudly\Connectly\Connectly;

// ...

$newConnection = new Connectly;

$newConnection->name = 'My other database';

$newConnection->config = [
	'driver' => 'mysql',
	'host' => '127.0.0.1',
	'port' => '3306',
	'database' => 'connectly_test_base',
	'username' => 'connectly_user',
	'password' => 'hunter2',
];

$newConnection->save();



use Crudly\Connectly\Connectly;

// ...

$storedConnectly = Connectly::latest()->first();

//or
$myConnection = Connectly::where('name', 'My other database')->first();

$connection = $myConnection->connect();

$data = $connection->table('posts')->get();