本文整理汇总了PHP中PDOConnect类的典型用法代码示例。如果您正苦于以下问题:PHP PDOConnect类的具体用法?PHP PDOConnect怎么用?PHP PDOConnect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PDOConnect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Error
public function Error($errorNo, $errorMessage = '')
{
header('Content-Type: text/xml; charset=utf8');
Debug::LogEntry('audit', $errorMessage, 'RestXml', 'Error');
// Roll back any open transactions if we are in an error state
try {
$dbh = PDOConnect::init();
$dbh->rollBack();
} catch (Exception $e) {
Debug::LogEntry('audit', 'Unable to rollback');
}
// Output the error doc
$xmlDoc = new DOMDocument('1.0');
$xmlDoc->formatOutput = true;
// Create the response node
$rootNode = $xmlDoc->createElement('rsp');
// Set the status to OK
$rootNode->setAttribute('status', 'error');
// Append the response node as the root
$xmlDoc->appendChild($rootNode);
// Create the error node
$errorNode = $xmlDoc->createElement('error');
$errorNode->setAttribute('code', $errorNo);
$errorNode->setAttribute('message', $errorMessage);
// Add the error node to the document
$rootNode->appendChild($errorNode);
// Log it
Debug::LogEntry('audit', $xmlDoc->saveXML());
// Return it as a string
return $xmlDoc->saveXML();
}
示例2: Version
/**
* Defines the Version and returns it
* @return
* @param $object String [optional]
*/
static function Version($object = '')
{
try {
$dbh = PDOConnect::init();
$sth = $dbh->prepare('SELECT app_ver, XlfVersion, XmdsVersion, DBVersion FROM version');
$sth->execute();
if (!($row = $sth->fetch())) {
throw new Exception('No results returned');
}
$appVer = Kit::ValidateParam($row['app_ver'], _STRING);
$xlfVer = Kit::ValidateParam($row['XlfVersion'], _INT);
$xmdsVer = Kit::ValidateParam($row['XmdsVersion'], _INT);
$dbVer = Kit::ValidateParam($row['DBVersion'], _INT);
if (!defined('VERSION')) {
define('VERSION', $appVer);
}
if (!defined('DBVERSION')) {
define('DBVERSION', $dbVer);
}
if ($object != '') {
return Kit::GetParam($object, $row, _STRING);
}
return $row;
} catch (Exception $e) {
trigger_error($e->getMessage());
trigger_error(__('No Version information - please contact technical support'), E_USER_WARNING);
}
}
示例3: Edit
public function Edit($setting, $value)
{
try {
$dbh = PDOConnect::init();
$sth = $dbh->prepare('UPDATE setting SET value = :value WHERE setting = :setting');
$sth->execute(array('setting' => $setting, 'value' => $value));
return true;
} catch (Exception $e) {
Debug::LogEntry('error', $e->getMessage());
if (!$this->IsError()) {
$this->SetError(25000, __('Update of settings failed'));
}
return false;
}
}
示例4: Log
public function Log($displayId, $type, $sizeInBytes)
{
try {
$dbh = PDOConnect::init();
$sth = $dbh->prepare('
INSERT INTO `bandwidth` (Month, Type, DisplayID, Size) VALUES (:month, :type, :displayid, :size)
ON DUPLICATE KEY UPDATE Size = Size + :size2
');
$sth->execute(array('month' => strtotime(date('m') . '/02/' . date('Y') . ' 00:00:00'), 'type' => $type, 'displayid' => $displayId, 'size' => $sizeInBytes, 'size2' => $sizeInBytes));
return true;
} catch (Exception $e) {
Debug::LogEntry('error', $e->getMessage());
return false;
}
}
示例5: Delete
/**
* Deletes a Category
* @param <type> $categoryID
* @return <type>
*/
public function Delete($categoryID)
{
try {
$dbh = PDOConnect::init();
$sth = $dbh->prepare('DELETE FROM category WHERE categoryID = :categoryid');
$sth->execute(array('categoryid' => $categoryID));
return true;
} catch (Exception $e) {
Debug::LogEntry('error', $e->getMessage());
if (!$this->IsError()) {
$this->SetError(25000, __('Cannot delete this category.'));
}
return false;
}
}
示例6: 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));
}
示例7: UnlinkAllFromMedia
/**
* Unlink all media from the provided media item
* @param int $mediaid The media item to unlink from
*/
public function UnlinkAllFromMedia($mediaid)
{
Debug::LogEntry('audit', 'IN', get_class(), __FUNCTION__);
try {
$dbh = PDOConnect::init();
$mediaid = Kit::ValidateParam($mediaid, _INT, false);
$sth = $dbh->prepare('DELETE FROM `lkmediadisplaygroup` WHERE mediaid = :mediaid');
$sth->execute(array('mediaid' => $mediaid));
return true;
} catch (Exception $e) {
Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__);
if (!$this->IsError()) {
$this->SetError(1, __('Unknown Error'));
}
return false;
}
}
示例8: Add
public function Add($type, $fromDT, $toDT, $scheduleID, $displayID, $layoutID, $mediaID, $tag)
{
try {
$dbh = PDOConnect::init();
// Lower case the type for consistancy
$type = strtolower($type);
// Prepare a statement
$sth = $dbh->prepare('INSERT INTO stat (Type, statDate, start, end, scheduleID, displayID, layoutID, mediaID, Tag) VALUES (:type, :statdate, :start, :end, :scheduleid, :displayid, :layoutid, :mediaid, :tag)');
// Construct a parameters array to execute
$params = array();
$params['statdate'] = date("Y-m-d H:i:s");
$params['type'] = $type;
$params['start'] = $fromDT;
$params['end'] = $toDT;
$params['scheduleid'] = $scheduleID;
$params['displayid'] = $displayID;
$params['layoutid'] = $layoutID;
// Optional parameters
$params['mediaid'] = null;
$params['tag'] = null;
// We should run different SQL depending on what Type we are
switch ($type) {
case 'media':
$params['mediaid'] = $mediaID;
break;
case 'layout':
// Nothing additional to do
break;
case 'event':
$params['layoutid'] = 0;
$params['tag'] = $tag;
break;
default:
// Nothing to do, just exit
return true;
}
$sth->execute($params);
return true;
} catch (Exception $e) {
Debug::LogEntry('error', $e->getMessage());
if (!$this->IsError()) {
$this->SetError(25000, 'Stat Insert Failed.');
}
return false;
}
}
示例9: UnlinkAll
/**
* Unlinks a display group from a group
* @return
* @param $displayGroupID Object
* @param $groupID Object
*/
public function UnlinkAll($displayGroupId)
{
Debug::LogEntry('audit', 'IN', 'DataSetGroupSecurity', 'Unlink');
try {
$dbh = PDOConnect::init();
$sth = $dbh->prepare('DELETE FROM lkdisplaygroupgroup WHERE DisplayGroupID = :displaygroupid');
$sth->execute(array('displaygroupid' => $displayGroupId));
Debug::LogEntry('audit', 'OUT', 'DataSetGroupSecurity', 'Unlink');
return true;
} catch (Exception $e) {
Debug::LogEntry('error', $e->getMessage());
if (!$this->IsError()) {
$this->SetError(25007, __('Could not Unlink All Display Groups from User Group'));
}
return false;
}
}
示例10: UnlinkAll
/**
* Unlinks a display group from a group
* @return
* @param $displayGroupID Object
* @param $groupID Object
*/
public function UnlinkAll($templateId)
{
Debug::LogEntry('audit', 'IN', 'TemplateGroupSecurity', 'UnlinkAll');
try {
$dbh = PDOConnect::init();
$sth = $dbh->prepare('DELETE FROM lktemplategroup WHERE TemplateID = :templateid');
$sth->execute(array('templateid' => $templateId));
Debug::LogEntry('audit', 'OUT', 'TemplateGroupSecurity', 'UnlinkAll');
return true;
} catch (Exception $e) {
Debug::LogEntry('error', $e->getMessage());
if (!$this->IsError()) {
$this->SetError(25025, __('Could not Unlink Template from Groups'));
}
return false;
}
}
示例11: ChangePassword
/**
* Change a users password
* @param <type> $userId
* @param <type> $oldPassword
* @param <type> $newPassword
* @param <type> $retypedNewPassword
* @return <type>
*/
public function ChangePassword($userId, $oldPassword, $newPassword, $retypedNewPassword, $forceChange = false)
{
try {
$dbh = PDOConnect::init();
// Validate
if ($userId == 0) {
$this->ThrowError(26001, __('User not selected'));
}
// We can force the users password to change without having to provide the old one.
// Is this a potential security hole - we must have validated that we are an admin to get to this point
if (!$forceChange) {
// Get the stored hash
$sth = $dbh->prepare('SELECT UserPassword FROM `user` WHERE UserID = :userid');
$sth->execute(array('userid' => $userId));
if (!($row = $sth->fetch())) {
$this->ThrowError(26000, __('Incorrect Password Provided'));
}
$good_hash = Kit::ValidateParam($row['UserPassword'], _STRING);
// Check the Old Password is correct
if ($this->validate_password($oldPassword, $good_hash) === false) {
$this->ThrowError(26000, __('Incorrect Password Provided'));
}
}
// Check the New Password and Retyped Password match
if ($newPassword != $retypedNewPassword) {
$this->ThrowError(26001, __('New Passwords do not match'));
}
// Check password complexity
if (!$this->TestPasswordAgainstPolicy($newPassword)) {
throw new Exception("Error Processing Request", 1);
}
// Generate a new SALT and Password
$hash = $this->create_hash($newPassword);
$sth = $dbh->prepare('UPDATE `user` SET UserPassword = :hash, CSPRNG = 1 WHERE UserID = :userid');
$sth->execute(array('hash' => $hash, 'userid' => $userId));
return true;
} catch (Exception $e) {
Debug::LogEntry('error', $e->getMessage());
if (!$this->IsError()) {
$this->SetError(25000, __('Could not edit Password'));
}
return false;
}
}
示例12: Link
/**
* Outputs a help link
* @return
* @param $topic Object[optional]
* @param $category Object[optional]
*/
public static function Link($topic = "", $category = "General")
{
// if topic is empty use the page name
$topic = $topic == '' ? Kit::GetParam('p', _REQUEST, _WORD) : $topic;
$topic = ucfirst($topic);
// Get the link
try {
$dbh = PDOConnect::init();
$sth = $dbh->prepare('SELECT Link FROM help WHERE Topic = :topic and Category = :cat');
$sth->execute(array('topic' => $topic, 'cat' => $category));
if (!($link = $sth->fetchColumn(0))) {
$sth->execute(array('topic' => $topic, 'cat' => 'General'));
$link = $sth->fetchColumn(0);
}
return Config::GetSetting('HELP_BASE') . $link;
} catch (Exception $e) {
return false;
}
}
示例13: Error
public function Error($errorNo, $errorMessage = '')
{
header('Content-Type: text/json; charset=utf8');
Debug::LogEntry('audit', $errorMessage, 'RestJson', 'Error');
// Roll back any open transactions if we are in an error state
try {
$dbh = PDOConnect::init();
$dbh->rollBack();
} catch (Exception $e) {
Debug::LogEntry('audit', 'Unable to rollback', 'RestJson', 'Error');
}
// Error
$array = array('status' => 'error', 'error' => array('code' => $errorNo, 'message' => $errorMessage));
$return = json_encode($array);
// Log it
Debug::LogEntry('audit', $return, 'RestJson', 'Error');
// Return it as a string
return $return;
}
示例14: Delete
/**
* Deletes a layout
* @param <type> $layoutId
* @return <type>
*/
public function Delete($templateId)
{
try {
$dbh = PDOConnect::init();
// Remove any permissions
Kit::ClassLoader('templategroupsecurity');
$security = new TemplateGroupSecurity($this->db);
$security->UnlinkAll($templateId);
// Remove the Template
$sth = $dbh->prepare('DELETE FROM template WHERE TemplateId = :templateid');
$sth->execute(array('templateid' => $templateId));
return true;
} catch (Exception $e) {
Debug::LogEntry('error', $e->getMessage());
if (!$this->IsError()) {
$this->SetError(25105, __('Unable to delete template'));
}
return false;
}
}
示例15: add
public function add($tag)
{
try {
$dbh = PDOConnect::init();
// See if it exists
$sth = $dbh->prepare('SELECT * FROM `tag` WHERE tag = :tag');
$sth->execute(array('tag' => $tag));
if ($row = $sth->fetch()) {
return Kit::ValidateParam($row['tagId'], _INT);
}
// Insert if not
$sth = $dbh->prepare('INSERT INTO `tag` (tag) VALUES (:tag)');
$sth->execute(array('tag' => $tag));
return $dbh->lastInsertId();
} catch (Exception $e) {
Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__);
if (!$this->IsError()) {
$this->SetError(1, __('Unknown Error'));
}
return false;
}
}