Permalink
Browse files

git-svn-id: svn://dklab.ru/lib/DbSimple/trunk@95 78bb956b-1e24-0410-b…

…8d0-c528fdc9eae3
  • Loading branch information...
1 parent 98474e1 commit 4ff11e2225e73dd381c57eb067d9945181be3ea4 dk committed Jan 8, 2007
View
@@ -0,0 +1,2 @@
+AddHandler application/x-httpd-php phpt
+php_flag output_buffering On
@@ -0,0 +1,98 @@
+--TEST--
+Generic: ARRAY_KEY* usage
+--FILE--
+<?php
+require_once dirname(__FILE__) . '/../init.php';
+
+function main(&$DB)
+{
+ @$DB->query("DROP TABLE test");
+ $DB->query("CREATE TABLE test(id INTEGER, pid INTEGER, str VARCHAR(1))");
+ $DB->query("INSERT INTO test(id, pid, str) VALUES(100, 10, 'a')");
+ $DB->query("INSERT INTO test(id, pid, str) VALUES(101, 10, 'b')");
+ $DB->query("INSERT INTO test(id, pid, str) VALUES(200, 20, 'x')");
+ $DB->query("INSERT INTO test(id, pid, str) VALUES(201, 20, 'y')");
+ printr($DB->select("SELECT id AS ARRAY_KEY, str FROM test ORDER BY id"));
+ printr($DB->select("SELECT id AS ARRAY_KEY_2, pid AS ARRAY_KEY_1, str FROM test ORDER BY id"));
+ printr($DB->select("SELECT NULL AS ARRAY_KEY_2, pid AS ARRAY_KEY_1, str FROM test ORDER BY id"));
+}
+
+?>
+
+
+--EXPECT--
+Query: 'DROP TABLE test'
+Query: 'CREATE TABLE test(id INTEGER, pid INTEGER, str VARCHAR(1))'
+Query: 'INSERT INTO test(id, pid, str) VALUES(100, 10, \'a\')'
+Query: 'INSERT INTO test(id, pid, str) VALUES(101, 10, \'b\')'
+Query: 'INSERT INTO test(id, pid, str) VALUES(200, 20, \'x\')'
+Query: 'INSERT INTO test(id, pid, str) VALUES(201, 20, \'y\')'
+Query: 'SELECT id AS ARRAY_KEY, str FROM test ORDER BY id'
+array (
+ 100 =>
+ array (
+ 'str' => 'a',
+ ),
+ 101 =>
+ array (
+ 'str' => 'b',
+ ),
+ 200 =>
+ array (
+ 'str' => 'x',
+ ),
+ 201 =>
+ array (
+ 'str' => 'y',
+ ),
+)
+Query: 'SELECT id AS ARRAY_KEY_2, pid AS ARRAY_KEY_1, str FROM test ORDER BY id'
+array (
+ 10 =>
+ array (
+ 100 =>
+ array (
+ 'str' => 'a',
+ ),
+ 101 =>
+ array (
+ 'str' => 'b',
+ ),
+ ),
+ 20 =>
+ array (
+ 200 =>
+ array (
+ 'str' => 'x',
+ ),
+ 201 =>
+ array (
+ 'str' => 'y',
+ ),
+ ),
+)
+Query: 'SELECT NULL AS ARRAY_KEY_2, pid AS ARRAY_KEY_1, str FROM test ORDER BY id'
+array (
+ 10 =>
+ array (
+ 0 =>
+ array (
+ 'str' => 'a',
+ ),
+ 1 =>
+ array (
+ 'str' => 'b',
+ ),
+ ),
+ 20 =>
+ array (
+ 0 =>
+ array (
+ 'str' => 'x',
+ ),
+ 1 =>
+ array (
+ 'str' => 'y',
+ ),
+ ),
+)
@@ -0,0 +1,164 @@
+--TEST--
+Generic: ARRAY_KEY/PARENT_KEY usage
+--FILE--
+<?php
+require_once dirname(__FILE__) . '/../init.php';
+
+function main(&$DB)
+{
+ @$DB->query("DROP TABLE test");
+ $DB->query("CREATE TABLE test(id INTEGER, pid INTEGER, str VARCHAR(1))");
+ $DB->query("INSERT INTO test(id, pid, str) VALUES( 1, NULL, 'a')");
+ $DB->query("INSERT INTO test(id, pid, str) VALUES( 2, 1, 'b')");
+ $DB->query("INSERT INTO test(id, pid, str) VALUES( 3, 1, 'c')");
+ $DB->query("INSERT INTO test(id, pid, str) VALUES( 4, 1, 'd')");
+ $DB->query("INSERT INTO test(id, pid, str) VALUES( 5, 2, 'e')");
+ $DB->query("INSERT INTO test(id, pid, str) VALUES( 6, 2, 'f')");
+ $DB->query("INSERT INTO test(id, pid, str) VALUES( 7, 2, 'g')");
+ $DB->query("INSERT INTO test(id, pid, str) VALUES( 8, 3, 'h')");
+ $DB->query("INSERT INTO test(id, pid, str) VALUES( 9, 3, 'i')");
+ $DB->query("INSERT INTO test(id, pid, str) VALUES(10, 3, 'j')");
+ $DB->query("INSERT INTO test(id, pid, str) VALUES(11, 4, 'k')");
+ $DB->query("INSERT INTO test(id, pid, str) VALUES(12, 4, 'l')");
+ $DB->query("INSERT INTO test(id, pid, str) VALUES(13, 4, 'm')");
+ $DB->query("INSERT INTO test(id, pid, str) VALUES(14, 5, 'n')");
+ $DB->query("INSERT INTO test(id, pid, str) VALUES(15, 5, 'o')");
+ $DB->query("INSERT INTO test(id, pid, str) VALUES(16, 5, 'p')");
+ printr($DB->select("SELECT id AS ARRAY_KEY, pid AS PARENT_KEY, str FROM test"));
+}
+
+?>
+--EXPECT--
+Query: 'DROP TABLE test'
+Query: 'CREATE TABLE test(id INTEGER, pid INTEGER, str VARCHAR(1))'
+Query: 'INSERT INTO test(id, pid, str) VALUES( 1, NULL, \'a\')'
+Query: 'INSERT INTO test(id, pid, str) VALUES( 2, 1, \'b\')'
+Query: 'INSERT INTO test(id, pid, str) VALUES( 3, 1, \'c\')'
+Query: 'INSERT INTO test(id, pid, str) VALUES( 4, 1, \'d\')'
+Query: 'INSERT INTO test(id, pid, str) VALUES( 5, 2, \'e\')'
+Query: 'INSERT INTO test(id, pid, str) VALUES( 6, 2, \'f\')'
+Query: 'INSERT INTO test(id, pid, str) VALUES( 7, 2, \'g\')'
+Query: 'INSERT INTO test(id, pid, str) VALUES( 8, 3, \'h\')'
+Query: 'INSERT INTO test(id, pid, str) VALUES( 9, 3, \'i\')'
+Query: 'INSERT INTO test(id, pid, str) VALUES(10, 3, \'j\')'
+Query: 'INSERT INTO test(id, pid, str) VALUES(11, 4, \'k\')'
+Query: 'INSERT INTO test(id, pid, str) VALUES(12, 4, \'l\')'
+Query: 'INSERT INTO test(id, pid, str) VALUES(13, 4, \'m\')'
+Query: 'INSERT INTO test(id, pid, str) VALUES(14, 5, \'n\')'
+Query: 'INSERT INTO test(id, pid, str) VALUES(15, 5, \'o\')'
+Query: 'INSERT INTO test(id, pid, str) VALUES(16, 5, \'p\')'
+Query: 'SELECT id AS ARRAY_KEY, pid AS PARENT_KEY, str FROM test'
+array (
+ 1 =>
+ array (
+ 'str' => 'a',
+ 'childNodes' =>
+ array (
+ 2 =>
+ array (
+ 'str' => 'b',
+ 'childNodes' =>
+ array (
+ 5 =>
+ array (
+ 'str' => 'e',
+ 'childNodes' =>
+ array (
+ 14 =>
+ array (
+ 'str' => 'n',
+ 'childNodes' =>
+ array (
+ ),
+ ),
+ 15 =>
+ array (
+ 'str' => 'o',
+ 'childNodes' =>
+ array (
+ ),
+ ),
+ 16 =>
+ array (
+ 'str' => 'p',
+ 'childNodes' =>
+ array (
+ ),
+ ),
+ ),
+ ),
+ 6 =>
+ array (
+ 'str' => 'f',
+ 'childNodes' =>
+ array (
+ ),
+ ),
+ 7 =>
+ array (
+ 'str' => 'g',
+ 'childNodes' =>
+ array (
+ ),
+ ),
+ ),
+ ),
+ 3 =>
+ array (
+ 'str' => 'c',
+ 'childNodes' =>
+ array (
+ 8 =>
+ array (
+ 'str' => 'h',
+ 'childNodes' =>
+ array (
+ ),
+ ),
+ 9 =>
+ array (
+ 'str' => 'i',
+ 'childNodes' =>
+ array (
+ ),
+ ),
+ 10 =>
+ array (
+ 'str' => 'j',
+ 'childNodes' =>
+ array (
+ ),
+ ),
+ ),
+ ),
+ 4 =>
+ array (
+ 'str' => 'd',
+ 'childNodes' =>
+ array (
+ 11 =>
+ array (
+ 'str' => 'k',
+ 'childNodes' =>
+ array (
+ ),
+ ),
+ 12 =>
+ array (
+ 'str' => 'l',
+ 'childNodes' =>
+ array (
+ ),
+ ),
+ 13 =>
+ array (
+ 'str' => 'm',
+ 'childNodes' =>
+ array (
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+)
Oops, something went wrong.

0 comments on commit 4ff11e2

Please sign in to comment.