dbObject::getOne PHP Méthode

getOne() protected méthode

Convinient function to fetch one object. Mostly will be togeather with where()
protected getOne ( array | string $fields = null ) : dbObject
$fields array | string Array or coma separated list of fields to fetch
Résultat dbObject
    protected function getOne($fields = null)
    {
        $this->processHasOneWith();
        $results = $this->db->ArrayBuilder()->getOne($this->dbTable, $fields);
        if ($this->db->count == 0) {
            return null;
        }
        $this->processArrays($results);
        $this->data = $results;
        $this->processAllWith($results);
        if ($this->returnType == 'Json') {
            return json_encode($results);
        }
        if ($this->returnType == 'Array') {
            return $results;
        }
        $item = new static($results);
        $item->isNew = false;
        return $item;
    }