コード例 #1
0
ファイル: Actions.php プロジェクト: thebuggenie/caspar
 /**
  * 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);
 }
コード例 #2
0
ファイル: Resultset.php プロジェクト: thebuggenie/b2db
 /**
  * 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;
 }
コード例 #3
0
ファイル: debugger-row.php プロジェクト: thebuggenie/caspar
?>
					</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>&nbsp;&nbsp;<span class="csp-dbg-log-msg"><?php 
    echo $entry['message'];
コード例 #4
0
ファイル: Debugger.php プロジェクト: thebuggenie/caspar
 /**
  * Shortcut to get array of log entries
  *
  * @return array
  */
 public function getLog()
 {
     return \caspar\core\Logging::getEntries();
 }
コード例 #5
0
ファイル: Statement.php プロジェクト: nrensen/b2db
 /**
  * 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;
     }
 }
コード例 #6
0
ファイル: Statement.php プロジェクト: thebuggenie/b2db
 /**
  * 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;
     }
 }