/** * Method query * * Cria uma interface para execução códigos SQL que não * estam implementados nesta classe * * @param string * @return array */ public function query($sql) { if (is_string($sql)) { throw new \InvalidArgumentException('Valores inválidos para [param] ou [data].'); return; } $rows = array(); foreach ($this->conn->query($sql, \PDO::FETCH_ASSOC) as $row) { $rows[] = $row; } return $rows; }
/** * Trouver le numero de page d'une pagination indirecte * lorsque debut_xxx=@123 * on cherche la page qui contient l'item dont la cle primaire vaut 123 * * @param string $primary * @param int|string $valeur * @param int $pas * @param objetc $iter * @return int */ function quete_debut_pagination($primary, $valeur, $pas, $iter) { // on ne devrait pas arriver ici si la cle primaire est inexistante // ou composee, mais verifions if (!$primary or preg_match('/[,\\s]/', $primary)) { return 0; } $pos = 0; while ($row = $iter->fetch() and $row[$primary] != $valeur) { $pos++; } // si on a pas trouve if ($row[$primary] != $valeur) { return 0; } // sinon, calculer le bon numero de page return floor($pos / $pas) * $pas; }
/** * Extends the object, depending on its instance class * * @param objetc $object * @param array $values * @return void */ protected function setToData($object, array $values) { $isDataInterface = $object instanceof Tx_Rnbase_Domain_Model_DataInterface; foreach ($values as $field => $value) { if ($isDataInterface) { $object->setProperty($field, $value); } else { $object->record[$field] = $value; } } }