/** * {@inheritdoc} */ protected static function createCollectionFromDbResult(\Database\Result $objResult, $strTable) { return ProductPriceCollection::createFromDbResult($objResult, $strTable); }
/** * Find records and return the model or model collection * * Supported options: * * * column: the field name * * value: the field value * * limit: the maximum number of rows * * offset: the number of rows to skip * * order: the sorting order * * eager: load all related records eagerly * * @param array $arrOptions The options array * * @return \Model|\Model\Collection|null A model, model collection or null if the result is empty */ protected static function find(array $arrOptions) { if (static::$strTable == '') { return null; } $arrOptions['table'] = static::$strTable; $strQuery = \Model\QueryBuilder::find($arrOptions); $objStatement = \Database::getInstance()->prepare($strQuery); // Defaults for limit and offset if (!isset($arrOptions['limit'])) { $arrOptions['limit'] = 0; } if (!isset($arrOptions['offset'])) { $arrOptions['offset'] = 0; } // Limit if ($arrOptions['limit'] > 0 || $arrOptions['offset'] > 0) { $objStatement->limit($arrOptions['limit'], $arrOptions['offset']); } $objStatement = static::preFind($objStatement); $objResult = $objStatement->execute($arrOptions['value']); if ($objResult->numRows < 1) { return null; } $objResult = static::postFind($objResult); if ($arrOptions['return'] == 'Model') { $strPk = static::$strPk; $intPk = $objResult->{$strPk}; // Try to load from the registry $objModel = \Model\Registry::getInstance()->fetch(static::$strTable, $intPk); if ($objModel !== null) { return $objModel->mergeRow($objResult->row()); } return new static($objResult); } else { return \Isotope\Collection\ProductPrice::createFromDbResult($objResult, static::$strTable); } }