Ticket #572 (closed Patch: fixed)

Opened 2 months ago

Last modified 1 month ago

Database Result Object Not Autoloaded

Reported by: charlie Assigned to: zombor
Priority: minor Milestone: 2.1.2
Component: Libraries:Database Version: 2.1 Release
Keywords: Cc:
SVN Revision (if applicable):

Description

When using object results, the specified class will only be used if it has been loaded already. If the class is not already in the namespace, stdClass is used. This may be fixed by replacing the code at line 399 (system/libraries/drivers/database/Mysql.php):

$this->return_type = class_exists($type, FALSE) ? $type : 'stdClass';

with:

$this->return_type = $type;

This same change must be made inside the result_array function, and in the other database drivers.

This solution isn't perfect, because there is no check for a loader failure. It may make sense to search for the specified class, load it if found, and change the result type to stdClass if it is not.

This same problem still exists in the development trunk, but line numbers are from the 2.1.1 release.

Attachments

database.patch (4.4 kB) - added by charlie on 05/23/08 12:33:55.
Patch to update all other database drivers to autoload result objects

Change History

04/25/08 15:24:56 changed by zombor

  • status changed from new to closed.
  • resolution set to fixed.

This was the desired behavior. I have made some modifications so it autoloads the class though in r2575 and r2576.

04/25/08 15:32:45 changed by charlie

  • priority changed from major to minor.
  • status changed from closed to reopened.
  • resolution deleted.

That works for me, although the same changes will need to made in the other database drivers if you want the same functionality across database platforms...

04/25/08 15:56:39 changed by charlie

Is there any reason to not do this for result_array() as well? There's a comment that says this was done to avoid overhead, but the behavior is incorrect.

05/23/08 12:33:55 changed by charlie

  • attachment database.patch added.

Patch to update all other database drivers to autoload result objects

05/23/08 12:34:23 changed by charlie

  • type changed from Bug to Patch.

The same code in Mysql_Result::result_array() has already been changed.

I attached a patch to use this same method for all the other drivers.

05/28/08 18:37:58 changed by zombor

  • status changed from reopened to closed.
  • resolution set to fixed.

Fixed in r2708 and r2710.