PHP code example of phpnomad / safemysql-integration
1. Go to this page and download the library: Download phpnomad/safemysql-integration 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/ */
phpnomad / safemysql-integration example snippets
use PHPNomad\Database\Interfaces\AtomicOperationStrategy;
use PHPNomad\MySql\Integration\Interfaces\DatabaseStrategy;
use PHPNomad\SafeMySql\Integration\Strategies\SafeMySqlAtomicOperationStrategy;
use PHPNomad\SafeMySql\Integration\Strategies\SafeMySqlDatabaseStrategy;
use SafeMySQL;
$db = new SafeMySQL([
'host' => 'localhost',
'user' => 'app',
'pass' => 'secret',
'db' => 'myapp',
]);
$container->bindFactory(
DatabaseStrategy::class,
fn() => new SafeMySqlDatabaseStrategy($db)
);
$container->bindFactory(
AtomicOperationStrategy::class,
fn() => new SafeMySqlAtomicOperationStrategy($db)
);
use PHPNomad\SafeMySql\Integration\SafeMySqlCoordinationInitializer;
$container->bindFactory(SafeMySQL::class, fn () => $db);
// ...then, in the initializer list, after the normal MySQL initializer:
new SafeMySqlCoordinationInitializer(),
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.