MetaModels\MetaModel::fetchRows PHP Method

fetchRows() protected method

Fetch the "native" database rows with the given ids.
protected fetchRows ( string[] $arrIds, string[] $arrAttrOnly = [] ) : array
$arrIds string[] The ids of the items to retrieve the order of ids is used for sorting of the return values.
$arrAttrOnly string[] Names of the attributes that shall be contained in the result, defaults to array() which means all attributes.
return array an array containing the database rows with each column "deserialized".
    protected function fetchRows($arrIds, $arrAttrOnly = array())
    {
        $parameters = array_merge($arrIds, $arrIds);
        $objRow = $this->getDatabase()->prepare(sprintf('SELECT * FROM %s WHERE id IN (%s) ORDER BY FIELD(id,%s)', $this->getTableName(), $this->buildDatabaseParameterList($arrIds), $this->buildDatabaseParameterList($arrIds)))->execute($parameters);
        /** @noinspection PhpUndefinedFieldInspection */
        if ($objRow->numRows == 0) {
            return array();
        }
        // If we have an attribute restriction, make sure we keep the system columns. See #196.
        if ($arrAttrOnly) {
            $arrAttrOnly = array_merge($GLOBALS['METAMODELS_SYSTEM_COLUMNS'], $arrAttrOnly);
        }
        return $this->convertRowsToResult($objRow, $arrAttrOnly);
    }