summaryrefslogtreecommitdiff
path: root/ext/sqlite/tests
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2003-04-20 13:31:36 +0000
committerWez Furlong <wez@php.net>2003-04-20 13:31:36 +0000
commitd40a615a8e2d09b66369fabb36f75022904172be (patch)
treeb602f9f927e80fb924bf736210c19145b173606b /ext/sqlite/tests
parentb0d26a11ac6ffe0222206a5635c64704ed8770f2 (diff)
downloadphp-git-d40a615a8e2d09b66369fabb36f75022904172be.tar.gz
Implement sqlite_create_function(), which allows binding of php functions by
name; this is a higher performance alternative to the generic php() SQL function. (saves parsing the additional function call in the SQL and a call to zend_is_callable on each function invocation). Add test for sqlite_create_function(). Fixup proto for sqlite_create_aggregate(). Tweak package file and speling in header file.
Diffstat (limited to 'ext/sqlite/tests')
-rw-r--r--ext/sqlite/tests/sqlite_006.phpt50
1 files changed, 50 insertions, 0 deletions
diff --git a/ext/sqlite/tests/sqlite_006.phpt b/ext/sqlite/tests/sqlite_006.phpt
new file mode 100644
index 0000000000..e946f2d30b
--- /dev/null
+++ b/ext/sqlite/tests/sqlite_006.phpt
@@ -0,0 +1,50 @@
+--TEST--
+sqlite: regular functions
+--SKIPIF--
+<?php # vim:ft=php
+if (!extension_loaded("sqlite")) print "skip"; ?>
+--FILE--
+<?php
+include "blankdb.inc";
+
+$data = array(
+ array("one", "uno"),
+ array("two", "dos"),
+ array("three", "tres"),
+ );
+
+sqlite_query("CREATE TABLE strings(a,b)", $db);
+
+function implode_args()
+{
+ $args = func_get_args();
+ $sep = array_shift($args);
+ return implode($sep, $args);
+}
+
+foreach ($data as $row) {
+ sqlite_query("INSERT INTO strings VALUES('" . sqlite_escape_string($row[0]) . "','" . sqlite_escape_string($row[1]) . "')", $db);
+}
+
+sqlite_create_function($db, "implode", "implode_args");
+
+$r = sqlite_query("SELECT implode('-', a, b) from strings", $db);
+while ($row = sqlite_fetch_array($r, SQLITE_NUM)) {
+ var_dump($row);
+}
+echo "DONE!\n";
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ string(7) "one-uno"
+}
+array(1) {
+ [0]=>
+ string(7) "two-dos"
+}
+array(1) {
+ [0]=>
+ string(10) "three-tres"
+}
+DONE!