pdo_sqlite_createaggregate.phpt 711 B

12345678910111213141516171819202122232425262728293031
  1. --TEST--
  2. PDO_sqlite: Testing sqliteCreateAggregate()
  3. --SKIPIF--
  4. <?php if (!extension_loaded('pdo_sqlite')) print 'skip not loaded'; ?>
  5. --FILE--
  6. <?php
  7. $db = new pdo('sqlite::memory:');
  8. $db->query('CREATE TABLE IF NOT EXISTS foobar (id INT AUTO INCREMENT, name TEXT)');
  9. $db->query('INSERT INTO foobar VALUES (NULL, "PHP")');
  10. $db->query('INSERT INTO foobar VALUES (NULL, "PHP6")');
  11. $db->sqliteCreateAggregate('testing', function(&$a, $b) { $a .= $b; return $a; }, function(&$v) { return $v; });
  12. foreach ($db->query('SELECT testing(name) FROM foobar') as $row) {
  13. var_dump($row);
  14. }
  15. $db->query('DROP TABLE foobar');
  16. ?>
  17. --EXPECTF--
  18. array(2) {
  19. ["testing(name)"]=>
  20. string(2) "12"
  21. [0]=>
  22. string(2) "12"
  23. }