phpdevshell team mailing list archive
-
phpdevshell team
-
Mailing list archive
-
Message #00376
[Bug 689717] Re: Database query returns unexpected keys
I just needed to understand what it was doing and why is was doing it!
Your example above makes perfect sense! Thanks
--
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