PHP value of stored function SQL

169 Views Asked by At

we can fetch result of PDO with a stored procedure like that

$pdo = <PDO class>

//Request
$request = $pdo->prepare("CALL `procedure1`(:arg1, :arg2)");
$request->execute(
    [
        'arg1' => $arg1,
        'arg2' => $arg2
    ]
);
$values = $request->fetchAll(PDO::FETCH_ASSOC);

but i don't know how to fetch or get the result of stored function that returns true/false or BIGINT/VARCHAR

$pdo = <PDO class>

//Request
$request = $pdo->prepare("CALL `function1`(:arg1)");
$request->execute(
    [
        'arg1' => $arg1
    ]
);

$result = $request->fetchAll(PDO::FETCH_ASSOC); // ERROR
$result = $request->fetch(PDO::FETCH_ASSOC)["function1"]; // ERROR

I get an empty value

0

There are 0 best solutions below