phpdevshell team mailing list archive
-
phpdevshell team
-
Mailing list archive
-
Message #00375
[Bug 689717] Re: Database query returns unexpected keys
The whole idea of this system is to be intuitive and easy to use. And
believe me, having a table already hashed by key field is really handy.
You can still iterate by index using array_keys(). And in the rare case
you need linear indexing, just add the flag to the query, as you did.
Example:
SELECT name, phone FROM phonebook => $numbers
echo $numbers['jason'];
--
You received this bug notification because you are a member of
PHPDevShell, which is subscribed to PHPDevShell.
https://bugs.launchpad.net/bugs/689717
Title:
Database query returns unexpected keys
Status in Open Source PHP RAD Framework with UI.:
New
Bug description:
Ok, try the following:
Given this database table:
CREATE TABLE pds_test (
id int(11) NOT NULL AUTO_INCREMENT,
`name` text COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO pds_test (id, `name`) VALUES
(2, 'Bob'),
(4, 'Jeff');
And this controller test.php:
<?php
class test extends PHPDS_controller
{
public function execute()
{
$test = $this->db->invokeQuery('myPlugin_test');
echo '<pre>';
print_r($test);
echo '</pre>';
}
}
return 'test';
And this model:
<?php
class myPlugin_test extends PHPDS_query
{
protected $sql = "
SELECT *
FROM _db_test
";
}
This returns the following results:
Array
(
[2] => Array
(
[id] => 2
[name] => Bob
)
[4] => Array
(
[id] => 4
[name] => Jeff
)
)
I would have expected the results of the main key to start with an index of 0 (see below) and not with the [id] field:
Array
(
[0] => Array
(
[id] => 2
[name] => Bob
)
[1] => Array
(
[id] => 4
[name] => Jeff
)
)
References