public function asArray($key = null, $value = null)
    {
        if (!is_null($key))
        {
            Helpers\Validate::table($this->name)->field($key);
        }
        if (!is_null($value))
        {
            Helpers\Validate::table($this->name)->field($value);
        }

        $datas = array();
        if (!$this->resetKeys)
        {
            if (is_null($key) && is_null($value))
            {
                return $this->data;
            }
            else
            {
                foreach ($this->data as $rowKey => $data)
                {
                    $datas[$rowKey] = array();
                    foreach ($data as $row)
                    {
                        if (is_null($key))
                        {
                            $datas[$rowKey][] = $row->{$value};
                        }
                        elseif (is_null($value))
                        {
                            $datas[$rowKey][$row->{$key}] = $row;
                        }
                        else
                        {
                            $datas[$rowKey][$row->{$key}] = $row->{$value};
                        }
                    }
                }
            }
        }
        else
        {
            if (is_null($key) && is_null($value))
            {
                foreach ($this->data as $data)
                {
                    $datas[] = get_object_vars($data);
                }
            }
            else
            {
                foreach ($this->data as $data)
                {
                    if (is_null($key))
                    {
                        $datas[] = $data->{$value};
                    }
                    elseif (is_null($value))
                    {
                        $datas[$data->{$key}] = $data;
                    }
                    else
                    {
                        $datas[$data->{$key}] = $data->{$value};
                    }
                }
            }
        }

        return $datas;
    }
public function asArray($key = null, $value = null)
    {
        if (!is_null($key))
        {
            Helpers\Validate::table($this->name)->field($key);
        }
        if (!is_null($value))
        {
            Helpers\Validate::table($this->name)->field($value);
        }

        $datas = array();
        if (!$this->resetKeys)
        {
            if (is_null($key) && is_null($value))
            {
                return $this->data;
            }
            else
            {
                foreach ($this->data as $rowKey => $data)
                {
                    $datas[$rowKey] = array();
                    foreach ($data as $row)
                    {
                        if (is_null($key))
                        {
                            $datas[$rowKey][] = $row->{$value};
                        }
                        elseif (is_null($value))
                        {
                            $datas[$rowKey][$row->{$key}] = $row;
                        }
                        else
                        {
                            $datas[$rowKey][$row->{$key}] = $row->{$value};
                        }
                    }
                }
            }
        }
        else
        {
            if (is_null($key) && is_null($value))
            {
                foreach ($this->data as $data)
                {
                    $datas[] = get_object_vars($data);
                }
            }
            else
            {
                foreach ($this->data as $data)
                {
                    if (is_null($key))
                    {
                        $datas[] = $data->{$value};
                    }
                    elseif (is_null($value))
                    {
                        $datas[$data->{$key}] = $data;
                    }
                    else
                    {
                        $datas[$data->{$key}] = $data->{$value};
                    }
                }
            }
        }

        return $datas;
    }
public function asArray ( $ key = null , $ value = null ) { if ( ! is_null ( $ key ) ) { Helpers \ Validate :: table ( $ this -> name ) -> field ( $ key ) ; } if ( ! is_null ( $ value ) ) { Helpers \ Validate :: table ( $ this -> name ) -> field ( $ value ) ; } $ datas = array ( ) ; if ( ! $ this -> resetKeys ) { if ( is_null ( $ key ) && is_null ( $ value ) ) { return $ this -> data ; } else { foreach ( $ this -> data as $ rowKey => $ data ) { $ datas [ $ rowKey ] = array ( ) ; foreach ( $ data as $ row ) { if ( is_null ( $ key ) ) { $ datas [ $ rowKey ] [ ] = $ row -> { $ value } ; } elseif ( is_null ( $ value ) ) { $ datas [ $ rowKey ] [ $ row -> { $ key } ] = $ row ; } else { $ datas [ $ rowKey ] [ $ row -> { $ key } ] = $ row -> { $ value } ; } } } } } else { if ( is_null ( $ key ) && is_null ( $ value ) ) { foreach ( $ this -> data as $ data ) { $ datas [ ] = get_object_vars ( $ data ) ; } } else { foreach ( $ this -> data as $ data ) { if ( is_null ( $ key ) ) { $ datas [ ] = $ data -> { $ value } ; } elseif ( is_null ( $ value ) ) { $ datas [ $ data -> { $ key } ] = $ data ; } else { $ datas [ $ data -> { $ key } ] = $ data -> { $ value } ; } } } } return $ datas ; }
Returning data as indexed or assoc array.
@param string $key Field that will be the key, NULL for Indexed
@param string $value Field that will be the value
@return array
Returning data as indexed or assoc array .