DB\SQL\Mapper::cast PHP Method

cast() public method

Return fields of mapper object as an associative array
public cast ( $obj = NULL ) : array
$obj object
return array
    function cast($obj = NULL)
    {
        if (!$obj) {
            $obj = $this;
        }
        return array_map(function ($row) {
            return $row['value'];
        }, $obj->fields + $obj->adhoc);
    }

Usage Example

Beispiel #1
0
 function cast($obj = NULL)
 {
     $ox = parent::cast($obj);
     $user = new \Model\User($ox['uid']);
     return array_merge($ox, array("user" => $user->cast()));
 }