Ticket #406 (closed Patch: fixed)

Opened 10 months ago

Last modified 9 months ago

Propsed change to ORM::__call() for 'as_array' to support correct datatype translation

Reported by: sbeattie Owned by: Shadowhand
Priority: minor Milestone: 2.2
Component: Libraries:ORM Version: SVN HEAD
Keywords: as_array Cc:

Description

I ran into an issue where all values were returned as strings...

from line 214:

/**
 * Returns an array of all the
 */
if ($method === 'as_array')
{
	// Return all of the object data as an array
	$arr = array();
	foreach( self::$fields[$this->table] as $field => $data )
	{
		switch( $data['type'] )
		{
			case 'int':
				$arr["$field"] = (int) $this->object->$field;
				break;
				
			case 'float':
				$arr["$field"] = (float) $this->object->$field;
				break;	
			default:
				$arr["$field"] = $this->object->$field;
				break;
		}
	}
	return $arr;
}

Change History

Changed 10 months ago by Shadowhand

  • status changed from new to assigned

Changed 10 months ago by allain

I like it.

Changed 10 months ago by Shadowhand

  • milestone changed from 2.1.2 to 2.2

Changed 9 months ago by Shadowhand

  • status changed from assigned to closed
  • resolution set to fixed

Fixed in r2255.

Note: See TracTickets for help on using tickets.