Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multi-dimensional array support in selectCol()
git-svn-id: svn://dklab.ru/lib/DbSimple/trunk@201 78bb956b-1e24-0410-b8d0-c528fdc9eae3
- Loading branch information
dk
committed
Jul 2, 2007
1 parent
1552685
commit 3631bcb
Showing
4 changed files
with
68 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--TEST-- | ||
Generic: selectCol() usage with multi-dimensional array | ||
--FILE-- | ||
<?php | ||
require_once dirname(__FILE__) . '/../init.php'; | ||
|
||
function main(&$DB) | ||
{ | ||
@$DB->query("DROP TABLE test"); | ||
$DB->query("CREATE TABLE test(id1 INTEGER, id2 INTEGER, str VARCHAR(1))"); | ||
$DB->query("INSERT INTO test VALUES( 1, 10, 'a')"); | ||
$DB->query("INSERT INTO test VALUES( 2, 20, 'b')"); | ||
$DB->query("INSERT INTO test VALUES( 2, 30, 'c')"); | ||
$DB->query("INSERT INTO test VALUES( 4, 40, 'd')"); | ||
printr($DB->selectCol("SELECT id1 AS ARRAY_KEY_1, str FROM test")); | ||
printr($DB->selectCol("SELECT id1 AS ARRAY_KEY_1, id2 AS ARRAY_KEY_2, str FROM test")); | ||
} | ||
|
||
?> | ||
--EXPECT-- | ||
Query: 'DROP TABLE test' | ||
Query: 'CREATE TABLE test(id1 INTEGER, id2 INTEGER, str VARCHAR(1))' | ||
Query: 'INSERT INTO test VALUES( 1, 10, \'a\')' | ||
Query: 'INSERT INTO test VALUES( 2, 20, \'b\')' | ||
Query: 'INSERT INTO test VALUES( 2, 30, \'c\')' | ||
Query: 'INSERT INTO test VALUES( 4, 40, \'d\')' | ||
Query: 'SELECT id1 AS ARRAY_KEY_1, str FROM test' | ||
array ( | ||
1 => 'a', | ||
2 => 'c', | ||
4 => 'd', | ||
) | ||
Query: 'SELECT id1 AS ARRAY_KEY_1, id2 AS ARRAY_KEY_2, str FROM test' | ||
array ( | ||
1 => | ||
array ( | ||
10 => 'a', | ||
), | ||
2 => | ||
array ( | ||
20 => 'b', | ||
30 => 'c', | ||
), | ||
4 => | ||
array ( | ||
40 => 'd', | ||
), | ||
) |