spiralCore/components/dbal.php
97 {
98 $pdoDSN = $config['dbDriver'] . ':dbname=' . $config['dbName'];
99
100 if ($config['dbServer'])
101 {
102 //Server
103 $pdoDSN .= ';host=' . $config['dbServer'];
104 }
105
106 //Connection
107 self::$pdo = new PDO($pdoDSN, $config['dbUser'], $config['dbPassword'], $config['pdoOptions']);
108 }
109 catch (pdoException $pdoException)
110 {
111 self::$benchmarks['connection'] = microtime(true) - self::$benchmarks['connection'];
112 throw $pdoException;
113 }
114
115 self::$benchmarks['connection'] = microtime(true) - self::$benchmarks['connection'];
116 return self::$pdo;
117 }
spiralCore/components/dbal/builders/select.php
480
481 //Create join (only AND conditions)
482 $query .= 'ON (' . join(' AND ', $conditions[2]) . ')';
483 }
484 }
485 }
486
487 if ($this->where)
488 {
489 //Create where conditions (limits will be placed in another part of query)
490 $query .= ' WHERE ' . self::buildWhere($this->where);
491 }
492
493 if ($this->groupBy)
494 {
495 //Grouping
496 $query .= ' GROUP BY ' . join(',', $this->groupBy);
497 }
498
499 if ($this->having)
500 {
spiralApplication/classes/meta.php
122 static public function callError($event, $data)
123 {
124 if ($data == 'notFound') {
125 //Checking for permanent redirecting
126 $url = explode('/', strtolower(trim(request::$originalURL, '/')));
127
128 //For media
129 if ($url[0] == 'viewmedia' && $url[1] == 'view') {
130 //Media file
131 $mediaURL = dbal::select('publicURL')->from('items')->where('publicID', '=',
132 $url[2])->where('status', '=', 'active')->makeQuery()->fetchColumn();
133
134 if ($mediaURL) {
135 header("HTTP/1.1 301 Moved Permanently");
136 header("Location: " . $mediaURL);
137 header("Connection: close");
138 spiralCore::closeOutput(false);
139 }
140 }
141
142 //For media
spiralCore/events.php
43 * @static
44 * @param string $event
45 * @param mixed $data
46 */
47 static public function callEvent($event, $data = false)
48 {
49 if (!empty(self::$events[$event]))
50 {
51 foreach (self::$events[$event] as $callback)
52 {
53 $data = call_user_func($callback, $event, $data);
54 }
55
56 spiralDebug && spiralCore::debugMessage("Event $event was successfully processed.");
57 }
58
59 return $data;
60 }
61
62 /**
63 * Adds event callback.
spiralCore/spiral.php
326 {
327 if ($errorType === 'shutdown') {
328 if (!self::shutdown()) {
329 return;
330 }
331
332 $errorType = 'notFound';
333 }
334
335 //Some classes can be connected to catch errors
336 spiralEvents::callEvent('callError', $errorType);
337
338 if (!isset(self::$globalConfig['spiral']['errorHandlers'][$errorType])) {
339 //Unspecified error
340 self::closeOutput(null);
341 }
342
343 $errorHandler = self::$globalConfig['spiral']['errorHandlers'][$errorType];
344
345 if ($errorHandler['header']) {
346 header($errorHandler['header'], true, $errorHandler['httpCode']);
spiralCore/loader.php
268 return;
269 }
270
271 /**
272 * Class path wasn't cached, we should find it, and allocate is it instance of spiralAlias.
273 */
274 $result = [self::findClass($name), false];
275
276 if (!$result[0]) {
277 if (mb_strpos($name, 'action') === 0) {
278 spiralCore::callError('notFound');
279 }
280 throw new spiralException("Unable to load class '$name', no route found to declaration.");
281 }
282
283 require $result[0];
284 spiralDebug && spiralCore::debugMessage("Declaration file '" . $result[0] . "' was successfully loaded for class '$name' (no loadmap).");
285
286 if (!class_exists($name, false)) {
287 throw new spiralException("Unable to load class '$name', required class declaration not found in '$result[0]'.");
288 }
‹ 3 ·ï܃