1--TEST-- 2Test Pdo\Sqlite::createFunction() trampoline callback 3--EXTENSIONS-- 4pdo_sqlite 5--FILE-- 6<?php 7 8$db = new Pdo\Sqlite('sqlite::memory:'); 9 10$db->query('CREATE TABLE test_pdo_sqlite_createaggregate_trampoline (a INTEGER, b INTEGER)'); 11 12$stmt = $db->query('INSERT INTO test_pdo_sqlite_createaggregate_trampoline VALUES (1, -1), (2, -2), (3, -3), (4, -4), (4, -4)'); 13 14class TrampolineTest { 15 public function __call(string $name, array $arguments) { 16 echo 'Trampoline for ', $name, PHP_EOL; 17 return strtoupper($arguments[0]); 18 } 19} 20 21var_dump($db->createFunction('strtoupper', [new TrampolineTest(), 'strtoupper'])); 22 23foreach ($db->query('SELECT strtoupper("test")') as $row) { 24 var_dump($row); 25} 26 27foreach ($db->query('SELECT strtoupper("test")') as $row) { 28 var_dump($row); 29} 30 31?> 32--EXPECT-- 33bool(true) 34Trampoline for strtoupper 35array(2) { 36 ["strtoupper("test")"]=> 37 string(4) "TEST" 38 [0]=> 39 string(4) "TEST" 40} 41Trampoline for strtoupper 42array(2) { 43 ["strtoupper("test")"]=> 44 string(4) "TEST" 45 [0]=> 46 string(4) "TEST" 47} 48