/** * @param SqlCrudInterface $sqlCrudInterface * @param array $conds * @param null $sortBy * @param null $condsQuery * * @return bool|SqlCrudInterface[] */ public function readMany(SqlCrudInterface $sqlCrudInterface, array $conds = array(), $sortBy = null, $condsQuery = null) { // handle custom query $query = $sqlCrudInterface->crudGetQuery(); // fallback to standard query if ($query === null) { $query = "SELECT * FROM {$sqlCrudInterface::crudGetSource()}"; } // add conds if (empty($conds) === false) { $query .= " WHERE {$this->getCondsQuery($conds, $condsQuery)}"; } // add sorting if ($sortBy !== null) { $query .= " ORDER BY {$sortBy}"; } // fetch data $cursor = $this->getMysql()->fetchRowManyCursor($query, $conds); // build result $sqlCrudInterfaceMany = array(); if ($cursor !== false) { foreach ($cursor as $data) { $sqlCrudInterfaceMany[] = $this->setData(clone $sqlCrudInterface, $data); } return empty($sqlCrudInterfaceMany) ? false : $sqlCrudInterfaceMany; } return false; }
/** * @param SqlCrudInterface $sqlCrudInterface * @param array $conditions * @param null $conditionsQuery * @return bool|SqlCrudInterface[] */ public function readMany(SqlCrudInterface $sqlCrudInterface, array $conditions, $conditionsQuery = null) { // handle custom query $query = $sqlCrudInterface->crudGetQuery(); // fallback to standard query if ($query === '') { $query = "SELECT * FROM {$sqlCrudInterface::crudGetSource()} WHERE {$this->getConditionsQuery($conditions, $conditionsQuery)}"; } // fetch data $cursor = $this->getMysql()->fetchRowManyCursor($query, $conditions); // build result $sqlCrudInterfaceMany = []; if ($cursor !== false) { foreach ($cursor as $data) { $sqlCrudInterfaceMany[] = $this->setData($sqlCrudInterface, $data); } return $sqlCrudInterfaceMany; } return false; }