/** * Forward the user to a specified url * * @param string $url The URL to forward to * @param integer $code[optional] HTTP status code * @param integer $method[optional] 2 for meta redirect instead of header */ public function forward($url, $code = 200) { if (Caspar::getRequest()->isAjaxCall() || Caspar::getRequest()->getRequestedFormat() == 'json') { $this->getResponse()->ajaxResponseText($code, Caspar::getMessageAndClear('forward')); } \caspar\core\Logging::log("Forwarding to url {$url}"); \caspar\core\Logging::log('Triggering header redirect function'); $this->getResponse()->headerRedirect($url, $code); }
/** * Returns the current row * * @return Row */ public function getCurrentRow() { if ($this->int_ptr == 0 && Core::isDebugLoggingEnabled()) { \caspar\core\Logging::log('This is not a valid row'); } if (isset($this->rows[$this->int_ptr - 1])) { return $this->rows[$this->int_ptr - 1]; } return null; }
?> </div> <div id="csp-dbg-row-<?php echo $cspdbgrow; ?> -content-tab-4-panel" class="csp-dbg-tab-panel" style="display: none;"> <p><i>Additional items can be added to this list using the <code>log</code> method in the Logging class - see the documentation for details.</i></p> <div> <?php foreach ($dbglog as $entry) { ?> <?php $color = \caspar\core\Logging::getCategoryColor($entry['category']); ?> <?php $lname = \caspar\core\Logging::getLevelName($entry['level']); ?> <span class="csp-dbg-log-level"><?php echo $lname; ?> </span> <span class="csp-dbg-log-source" style="color: #<?php echo $color; ?> ">[<?php echo $entry['category']; ?> ]</span> <span class="csp-dbg-log-time"><?php echo $entry['time']; ?> </span> <span class="csp-dbg-log-msg"><?php echo $entry['message'];
/** * Shortcut to get array of log entries * * @return array */ public function getLog() { return \caspar\core\Logging::getEntries(); }
/** * Performs a query, then returns a resultset * * @param string $action[optional] The crud action performed (select, insert, update, delete, create, alter) * * @return Resultset */ public function performQuery() { try { $values = $this->getCriteria() instanceof Criteria ? $this->getCriteria()->getValues() : array(); if (Core::isDebugMode()) { if (Core::isDebugLoggingEnabled()) { \caspar\core\Logging::log('executing PDO query (' . Core::getSQLCount() . ') - ' . ($this->getCriteria() instanceof Criteria ? $this->getCriteria()->action : 'unknown'), 'B2DB'); } $pretime = Core::getDebugTime(); } for ($i = 0; $i < sizeof($values); $i++) { $value = $values[$i]['value']; $type = $values[$i]['type']; switch ($type) { case 'boolean': $pdotype = \PDO::PARAM_BOOL; break; case 'integer': $pdotype = \PDO::PARAM_INT; break; case 'blob': $pdotype = \PDO::PARAM_LOB; break; default: $pdotype = \PDO::PARAM_STR; } $this->statement->bindValue($i + 1, $value, $pdotype); } $res = $this->statement->execute(); if (!$res) { $error = $this->statement->errorInfo(); if (Core::isDebugMode()) { Core::sqlHit($this, $pretime); } throw new Exception($error[2], $this->printSQL()); } if (Core::isDebugLoggingEnabled()) { \caspar\core\Logging::log('done', 'B2DB'); } if ($this->getCriteria() instanceof Criteria && $this->getCriteria()->action == 'insert') { if (Core::getDBtype() == 'mysql') { $this->insert_id = Core::getDBLink()->lastInsertId(); } elseif (Core::getDBtype() == 'pgsql') { $this->insert_id = Core::getDBLink()->lastInsertId(Core::getTablePrefix() . $this->getCriteria()->getTable()->getB2DBName() . '_id_seq'); if (Core::isDebugLoggingEnabled()) { \caspar\core\Logging::log('sequence: ' . Core::getTablePrefix() . $this->getCriteria()->getTable()->getB2DBName() . '_id_seq', 'b2db'); \caspar\core\Logging::log('id is: ' . $this->insert_id, 'b2db'); } } } $retval = new Resultset($this); if (Core::isDebugMode()) { Core::sqlHit($this, $pretime); } if (!$this->getCriteria() || $this->getCriteria()->action != 'select') { $this->statement->closeCursor(); } return $retval; } catch (\Exception $e) { throw $e; } }
/** * Performs a query, then returns a resultset * * @param string $action[optional] The crud action performed (select, insert, update, delete, create, alter) * * @return Resultset */ public function performQuery() { try { $values = $this->getCriteria() instanceof Criteria ? $this->getCriteria()->getValues() : array(); if (Core::isDebugMode()) { if (Core::isDebugLoggingEnabled()) { \caspar\core\Logging::log('executing PDO query (' . Core::getSQLCount() . ') - ' . ($this->getCriteria() instanceof Criteria ? $this->getCriteria()->action : 'unknown'), 'B2DB'); } $pretime = Core::getDebugTime(); } $res = $this->statement->execute($values); if (!$res) { $error = $this->statement->errorInfo(); if (Core::isDebugMode()) { Core::sqlHit($this, $pretime); } throw new Exception($error[2], $this->printSQL()); } if (Core::isDebugLoggingEnabled()) { \caspar\core\Logging::log('done', 'B2DB'); } if ($this->getCriteria() instanceof Criteria && $this->getCriteria()->action == 'insert') { if (Core::getDBtype() == 'mysql') { $this->insert_id = Core::getDBLink()->lastInsertId(); } elseif (Core::getDBtype() == 'pgsql') { $this->insert_id = Core::getDBLink()->lastInsertId(Core::getTablePrefix() . $this->getCriteria()->getTable()->getB2DBName() . '_id_seq'); if (Core::isDebugLoggingEnabled()) { \caspar\core\Logging::log('sequence: ' . Core::getTablePrefix() . $this->getCriteria()->getTable()->getB2DBName() . '_id_seq', 'b2db'); \caspar\core\Logging::log('id is: ' . $this->insert_id, 'b2db'); } } } $retval = new Resultset($this); if (Core::isDebugMode()) { Core::sqlHit($this, $pretime); } if (!$this->getCriteria() || $this->getCriteria()->action != 'select') { $this->statement->closeCursor(); } return $retval; } catch (\Exception $e) { throw $e; } }