1. Go to this page and download the library: Download scpzc/hyperf-db 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/ */
regexp
$where = "user_id = :user_id and age > :age";
$params = ['user_id'=>1,'age'=>10];
regexp
$sql = "SELECT username FROM user WHERE user_id = :user_id";
$params = ['user_id'=>1];
regexp
declare(strict_types=1);
namespace App\Listener;
use Hyperf\Event\Annotation\Listener;
use Hyperf\Event\Contract\ListenerInterface;
use Scpzc\HyperfDb\Event\FailToExecute;
#[Listener]
class FailToExecuteDbListener implements ListenerInterface
{
public function listen(): array
{
return [
FailToExecute::class,
];
}
/**
* @param FailToExecute $event
*/
public function process(object $event)
{
var_dump($event->throwable->getMessage());
}
}