| 1236 | | return Doctrine_Manager::getInstance()->getQueryRegistry() |
| 1237 | | ->get($queryKey, $this->getComponentName()); |
| | 1236 | $queryRegistry = Doctrine_Manager::getInstance()->getQueryRegistry(); |
| | 1237 | |
| | 1238 | if (strpos($queryKey, '/') !== false) { |
| | 1239 | $e = explode('/', $queryKey); |
| | 1240 | |
| | 1241 | return $queryRegistry->get($e[0], $e[1]); |
| | 1242 | } |
| | 1243 | |
| | 1244 | return $queryRegistry->get($queryKey, $this->getComponentName()); |
| 1244 | | * @param $id database row id |
| 1245 | | * @param int $hydrationMode Doctrine::HYDRATE_ARRAY or Doctrine::HYDRATE_RECORD |
| 1246 | | * @return mixed Array or Doctrine_Record or false if no result |
| 1247 | | */ |
| 1248 | | public function find($id, $hydrationMode = null) |
| 1249 | | { |
| 1250 | | if (is_null($id)) { |
| | 1251 | * @param mixed $name Database Row ID or Query Name defined previously as a NamedQuery |
| | 1252 | * @param mixed $params This argument is the hydration mode (Doctrine::HYDRATE_ARRAY or |
| | 1253 | * Doctrine::HYDRATE_RECORD) if first param is a Database Row ID. |
| | 1254 | * Otherwise this argument expect an array of query params. |
| | 1255 | * @param int $hydrationMode Optional Doctrine::HYDRATE_ARRAY or Doctrine::HYDRATE_RECORD if |
| | 1256 | * first argument is a NamedQuery |
| | 1257 | * @return mixed Doctrine_Collection, array, Doctrine_Record or false if no result |
| | 1258 | */ |
| | 1259 | public function find() |
| | 1260 | { |
| | 1261 | $num_args = func_num_args(); |
| | 1262 | |
| | 1263 | // Named Query or IDs |
| | 1264 | $name = func_get_arg(0); |
| | 1265 | |
| | 1266 | if (is_null($name)) { |
| 1254 | | $id = is_array($id) ? array_values($id) : array($id); |
| 1255 | | |
| 1256 | | $q = $this->createQuery('dctrn_find') |
| 1257 | | ->where( |
| 1258 | | 'dctrn_find.' . implode( |
| 1259 | | ' = ? AND dctrn_find.', (array) $this->getIdentifier() |
| 1260 | | ) . ' = ?', $id |
| 1261 | | ) |
| 1262 | | ->limit(1); |
| 1263 | | $res = $q->fetchOne(array(), $hydrationMode); |
| | 1270 | // Define query to be used |
| | 1271 | if ( |
| | 1272 | ! is_array($name) && |
| | 1273 | Doctrine_Manager::getInstance()->getQueryRegistry()->has($name, $this->getComponentName()) |
| | 1274 | ) { |
| | 1275 | // We're dealing with a named query |
| | 1276 | $q = $this->createNamedQuery($name); |
| | 1277 | |
| | 1278 | // Parameters construction |
| | 1279 | $params = ($num_args >= 2) ? func_get_arg(1) : array(); |
| | 1280 | |
| | 1281 | // Hydration mode |
| | 1282 | $hydrationMode = ($num_args == 3) ? func_get_arg(2) : null; |
| | 1283 | |
| | 1284 | // Executing query |
| | 1285 | $res = $q->execute($params, $hydrationMode); |
| | 1286 | } else { |
| | 1287 | // We're passing a single ID or an array of IDs |
| | 1288 | $q = $this->createQuery('dctrn_find') |
| | 1289 | ->where('dctrn_find.' . implode(' = ? AND dctrn_find.', (array) $this->getIdentifier()) . ' = ?') |
| | 1290 | ->limit(1); |
| | 1291 | |
| | 1292 | // Parameters construction |
| | 1293 | $params = is_array($name) ? array_values($name) : array($name); |
| | 1294 | |
| | 1295 | // Hydration mode |
| | 1296 | $hydrationMode = ($num_args == 2) ? func_get_arg(1) : null; |
| | 1297 | |
| | 1298 | // Executing query |
| | 1299 | $res = $q->fetchOne($params, $hydrationMode); |
| | 1300 | } |
| | 1301 | |