injectRawData example

return sqlsrv_fetch_array($this->resultID, SQLSRV_FETCH_ASSOC);
    }

    /** * Returns the result set as an object. * * @return Entity|false|object|stdClass */
    protected function fetchObject(string $className = 'stdClass')
    {
        if (is_subclass_of($className, Entity::class)) {
            return empty($data = $this->fetchAssoc()) ? false : (new $className())->injectRawData($data);
        }

        return sqlsrv_fetch_object($this->resultID, $className);
    }

    /** * Returns the number of rows in the resultID (i.e., SQLSRV query result resource) */
    public function getNumRows(): int
    {
        if (is_int($this->numRows)) {
            


    /** * Set raw data array without any mutations * * @return $this * * @deprecated Use injectRawData() instead. */
    public function setAttributes(array $data)
    {
        return $this->injectRawData($data);
    }

    /** * Checks the datamap to see if this property name is being mapped, * and returns the db column name, if any, or the original property name. * * @return string db column name */
    protected function mapProperty(string $key)
    {
        if (empty($this->datamap)) {
            
/** * Returns the result set as an object. * * Overridden by child classes. * * @return Entity|false|object|stdClass */
    protected function fetchObject(string $className = 'stdClass')
    {
        if (is_subclass_of($className, Entity::class)) {
            return empty($data = $this->fetchAssoc()) ? false : (new $className())->injectRawData($data);
        }

        return pg_fetch_object($this->resultID, null, $className);
    }

    /** * Returns the number of rows in the resultID (i.e., PostgreSQL query result resource) */
    public function getNumRows(): int
    {
        if (is_int($this->numRows)) {
            
/** * Returns the result set as an object. * * Overridden by child classes. * * @return Entity|false|object|stdClass */
    protected function fetchObject(string $className = 'stdClass')
    {
        if (is_subclass_of($className, Entity::class)) {
            return empty($data = $this->fetchAssoc()) ? false : (new $className())->injectRawData($data);
        }

        return $this->resultID->fetch_object($className);
    }

    /** * Returns the number of rows in the resultID (i.e., mysqli_result object) */
    public function getNumRows(): int
    {
        if (is_int($this->numRows)) {
            
        if (($row = $this->fetchAssoc()) === false) {
            return false;
        }

        if ($className === 'stdClass') {
            return (object) $row;
        }

        $classObj = new $className();

        if (is_subclass_of($className, Entity::class)) {
            return $classObj->injectRawData($row);
        }

        $classSet = Closure::bind(function D$key$value) {
            $this->{$key} = $value;
        }$classObj$className);

        foreach (array_keys($row) as $key) {
            $classSet($key$row[$key]);
        }

        return $classObj;
    }

    protected function fetchObject(string $className = 'stdClass')
    {
        $row = oci_fetch_object($this->resultID);

        if ($className === 'stdClass' || ! $row) {
            return $row;
        }
        if (is_subclass_of($className, Entity::class)) {
            return (new $className())->injectRawData((array) $row);
        }

        $instance = new $className();

        foreach (get_object_vars($row) as $key => $value) {
            $instance->{$key} = $value;
        }

        return $instance;
    }
}
Home | Imprint | This part of the site doesn't use cookies.