Does the execute()
statement perform an implicit fetch()
? PHP does not show the first row of the returned result in the following simple code:
$query = 'CALL `MySP`()';
$stmt = $db->prepare($query);
$stmt->execute();
$rows = $stmt->fetchAll();
return $rows;
$rows
contains only 3 rows instead of actual 4; the first one is missing. The same SP returns 4 rows when run directly.
Edit
No luck yet after I tried everything suggested in the comments. Additionally I found that PDO can fail for very simple SPs too. Here is an example:
CREATE PROCEDURE `Test`()
BEGIN
SELECT 123 as Col1
UNION ALL
SELECT 456 as Col1;
END
Try calling this proc from PHP. PDO throws a "no clue" exception when you try to fetch:
PDO error: “ SQLSTATE[HY000]: General error ” ...