public function tryLoadAny(Model $m)
    {
        $load = $m->action('select');
        $load->limit(1);

        // execute action
        try {
            $data = $this->typecastLoadRow($m, $load->getRow());
        } catch (\PDOException $e) {
            throw new Exception([
                'Unable to load due to query error',
                'query'      => $load->getDebugQuery(false),
                'model'      => $m,
                'conditions' => $m->conditions,
            ], null, $e);
        }

        if (!$data) {
            return;
        }

        if ($m->id_field) {

            // If id_field is not set, model will be read-only
            if (isset($data[$m->id_field])) {
                $m->id = $data[$m->id_field];
            } else {
                throw new Exception([
                    'Model uses "id_field" but it was not available in the database',
                    'model'       => $m,
                    'id_field'    => $m->id_field,
                    'data'        => $data,
                ]);
            }
        }

        return $data;
    }
public function tryLoadAny(Model $m)
    {
        $load = $m->action('select');
        $load->limit(1);

        // execute action
        try {
            $data = $this->typecastLoadRow($m, $load->getRow());
        } catch (\PDOException $e) {
            throw new Exception([
                'Unable to load due to query error',
                'query'      => $load->getDebugQuery(false),
                'model'      => $m,
                'conditions' => $m->conditions,
            ], null, $e);
        }

        if (!$data) {
            return;
        }

        if ($m->id_field) {

            // If id_field is not set, model will be read-only
            if (isset($data[$m->id_field])) {
                $m->id = $data[$m->id_field];
            } else {
                throw new Exception([
                    'Model uses "id_field" but it was not available in the database',
                    'model'       => $m,
                    'id_field'    => $m->id_field,
                    'data'        => $data,
                ]);
            }
        }

        return $data;
    }
public function tryLoadAny ( Model $ m ) { $ load = $ m -> action ( 'select' ) ; $ load -> limit ( 1 ) ; // execute action try { $ data = $ this -> typecastLoadRow ( $ m , $ load -> getRow ( ) ) ; } catch ( \ PDOException $ e ) { throw new Exception ( [ 'Unable to load due to query error' , 'query' => $ load -> getDebugQuery ( false ) , 'model' => $ m , 'conditions' => $ m -> conditions , ] , null , $ e ) ; } if ( ! $ data ) { return ; } if ( $ m -> id_field ) { // If id_field is not set, model will be read-only if ( isset ( $ data [ $ m -> id_field ] ) ) { $ m -> id = $ data [ $ m -> id_field ] ; } else { throw new Exception ( [ 'Model uses "id_field" but it was not available in the database' , 'model' => $ m , 'id_field' => $ m -> id_field , 'data' => $ data , ] ) ; } } return $ data ; }
Tries to load any one record.

@param Model $m

@return array
Tries to load any one record .