本文整理汇总了PHP中PDOConnect::newConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP PDOConnect::newConnection方法的具体用法?PHP PDOConnect::newConnection怎么用?PHP PDOConnect::newConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PDOConnect
的用法示例。
在下文中一共展示了PDOConnect::newConnection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public static function init()
{
if (!self::$conn) {
self::$conn = PDOConnect::newConnection();
}
return self::$conn;
}
示例2: audit
/**
* Audit Log
* @param string $entity
* @param int $entityId
* @param string $message
* @param string|object|array $object
*/
public static function audit($entity, $entityId, $message, $object)
{
\Debug::Audit(sprintf('Audit Trail message recorded for %s with id %d. Message: %s', $entity, $entityId, $message));
if (self::$_auditLogStatement == null) {
$dbh = \PDOConnect::newConnection();
self::$_auditLogStatement = $dbh->prepare('
INSERT INTO `auditlog` (logDate, userId, entity, message, entityId, objectAfter)
VALUES (:logDate, :userId, :entity, :message, :entityId, :objectAfter)
');
}
// If we aren't a string then encode
if (!is_string($object)) {
$object = json_encode($object);
}
self::$_auditLogStatement->execute(array('logDate' => time(), 'userId' => \Kit::GetParam('userid', _SESSION, _INT, 0), 'entity' => $entity, 'message' => $message, 'entityId' => $entityId, 'objectAfter' => $object));
}
示例3: log
/**
* Log
* @param string $type
* @param string $message
* @param string $page[Optional]
* @param string $function[Optional]
* @param string $logDate[Optional]
* @param int $displayId[Optional]
* @param int $scheduleId[Optional]
* @param int $layoutId[Optional]
* @param string $mediaId[Optional]
*/
public static function log($type, $message, $page = null, $function = null, $logDate = null, $displayId = 0, $scheduleId = 0, $layoutId = 0, $mediaId = null)
{
if (self::$pdo == NULL) {
self::$pdo = PDOConnect::newConnection();
}
$currentDate = date("Y-m-d H:i:s");
$requestUri = Kit::GetParam('REQUEST_URI', $_SERVER, _STRING, 'Not Supplied');
$requestIp = Kit::GetParam('REMOTE_ADDR', $_SERVER, _STRING, 'Not Supplied');
$requestUserAgent = Kit::GetParam('HTTP_USER_AGENT', $_SERVER, _STRING, 'Not Supplied');
$requestUserAgent = substr($requestUserAgent, 0, 253);
$userId = Kit::GetParam('userid', _SESSION, _INT, 0);
$message = Kit::ValidateParam($message, _HTMLSTRING);
// Prepare the variables
if ($logDate == null) {
$logDate = $currentDate;
}
if ($page == null) {
$page = Kit::GetParam('p', _GET, _WORD);
}
// Insert into the DB
try {
$dbh = self::$pdo;
$SQL = 'INSERT INTO log (logdate, type, page, function, message, requesturi, remoteaddr, useragent, userid, displayid, scheduleid, layoutid, mediaid)
VALUES (:logdate, :type, :page, :function, :message, :requesturi, :remoteaddr, :useragent, :userid, :displayid, :scheduleid, :layoutid, :mediaid) ';
$sth = $dbh->prepare($SQL);
$params = array('logdate' => $logDate, 'type' => $type, 'page' => $page, 'function' => $function, 'message' => $message, 'requesturi' => $requestUri, 'remoteaddr' => $requestIp, 'useragent' => $requestUserAgent, 'userid' => $userId, 'displayid' => Kit::ValidateParam($displayId, _INT), 'scheduleid' => Kit::ValidateParam($scheduleId, _INT), 'layoutid' => Kit::ValidateParam($layoutId, _INT), 'mediaid' => Kit::ValidateParam($mediaId, _INT));
$sth->execute($params);
} catch (PDOException $e) {
// In this case just silently log the error
error_log($message . '\\n\\n', 3, './err_log.xml');
error_log($e->getMessage() . '\\n\\n', 3, './err_log.xml');
}
}