public function getByID($id)
    {
        $pkey = $this->getPrimaryKey();
        if ($pkey === null)
            throw new DAOException("A primary key is required to select a record by ID");

        // If there's a unary primary key, the value can be specified as a
        // single scalar, rather than an array
        if (count($pkey) === 1 && is_scalar($id))
            foreach ($pkey as $colname => $def)
                $id = [$colname => $id];


        $condition = $this->getSelector($pkey, $id);
        $rec = $this->fetchSingle(QB::where($condition));
        if (empty($rec))
            throw new DAOEXception("Object not found with " . WF::str($id));

        $model = new $this->model_class;
        $model->assignRecord($rec, $this->db);
        return $model;
    }
public function getByID($id)
    {
        $pkey = $this->getPrimaryKey();
        if ($pkey === null)
            throw new DAOException("A primary key is required to select a record by ID");

        // If there's a unary primary key, the value can be specified as a
        // single scalar, rather than an array
        if (count($pkey) === 1 && is_scalar($id))
            foreach ($pkey as $colname => $def)
                $id = [$colname => $id];


        $condition = $this->getSelector($pkey, $id);
        $rec = $this->fetchSingle(QB::where($condition));
        if (empty($rec))
            throw new DAOEXception("Object not found with " . WF::str($id));

        $model = new $this->model_class;
        $model->assignRecord($rec, $this->db);
        return $model;
    }
public function getByID ( $ id ) { $ pkey = $ this -> getPrimaryKey ( ) ; if ( $ pkey === null ) throw new DAOException ( "A primary key is required to select a record by ID" ) ; // If there's a unary primary key, the value can be specified as a // single scalar, rather than an array if ( count ( $ pkey ) === 1 && is_scalar ( $ id ) ) foreach ( $ pkey as $ colname => $ def ) $ id = [ $ colname => $ id ] ; $ condition = $ this -> getSelector ( $ pkey , $ id ) ; $ rec = $ this -> fetchSingle ( QB :: where ( $ condition ) ) ; if ( empty ( $ rec ) ) throw new DAOEXception ( "Object not found with " . WF :: str ( $ id ) ) ; $ model = new $ this -> model_class ; $ model -> assignRecord ( $ rec , $ this -> db ) ; return $ model ; }
Load the record from the database
@param mixed $id The record to load, indicating the primary key. The
type should match the primary key: scalar for unary
primary keys, associative array for combined primary
keys.
Load the record from the database