- var_dump: documentation ( source)
- sqrt: documentation ( source)
<?php
class SqlitePlatform
{
public static function udfSqrt($value)
{
return sqrt($value);
}
}
$userDefinedFunctions = [
'sqrt' => ['callback' => [SqlitePlatform::class, 'udfSqrt'], 'numArgs' => 1],
];
$dsn = "sqlite::memory:";
try {
$pdo = new PDO($dsn);
foreach ($userDefinedFunctions as $fn => $data) {
$pdo->sqliteCreateFunction($fn, $data['callback'], $data['numArgs']);
}
\var_dump($pdo);
} catch (PDOException $e) {
\var_dump($e);
}