Flake\Core\Model\Db::initByPrimary PHP Méthode

initByPrimary() protected méthode

protected initByPrimary ( $sPrimary )
    protected function initByPrimary($sPrimary)
    {
        $rSql = $GLOBALS["DB"]->exec_SELECTquery("*", self::getDataTable(), self::getPrimaryKey() . "='" . $GLOBALS["DB"]->quote($sPrimary) . "'");
        if (($aRs = $rSql->fetch()) === false) {
            throw new \Exception("\\Flake\\Core\\Model '" . htmlspecialchars($sPrimary) . "' not found for model " . get_class($this));
        }
        reset($aRs);
        $this->aData = $aRs;
    }

Usage Example

Exemple #1
0
 public function initByPrimary($sPrimary)
 {
     parent::initByPrimary($sPrimary);
     # Initializing principals
     $this->oIdentityPrincipal = \Baikal\Model\Principal::getBaseRequester()->addClauseEquals("uri", "principals/" . $this->get("username"))->execute()->first();
 }