当前位置: 首页>>代码示例>>PHP>>正文


PHP PDOConnect::init方法代码示例

本文整理汇总了PHP中PDOConnect::init方法的典型用法代码示例。如果您正苦于以下问题:PHP PDOConnect::init方法的具体用法?PHP PDOConnect::init怎么用?PHP PDOConnect::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PDOConnect的用法示例。


在下文中一共展示了PDOConnect::init方法的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();
 }
开发者ID:fignew,项目名称:xibo-cms,代码行数:31,代码来源:restxml.class.php

示例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);
     }
 }
开发者ID:abbeet,项目名称:server39,代码行数:33,代码来源:config.class.php

示例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;
     }
 }
开发者ID:fignew,项目名称:xibo-cms,代码行数:15,代码来源:setting.data.class.php

示例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;
     }
 }
开发者ID:fignew,项目名称:xibo-cms,代码行数:15,代码来源:bandwidth.data.class.php

示例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;
     }
 }
开发者ID:jisuzz,项目名称:Test,代码行数:20,代码来源:category.data.class.php

示例6: 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;
     }
 }
开发者ID:abbeet,项目名称:server39,代码行数:46,代码来源:stat.data.class.php

示例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;
     }
 }
开发者ID:fignew,项目名称:xibo-cms,代码行数:21,代码来源:lkmediadisplaygroup.data.class.php

示例8: 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;
     }
 }
开发者ID:abbeet,项目名称:server39,代码行数:23,代码来源:templategroupsecurity.data.class.php

示例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;
     }
 }
开发者ID:fignew,项目名称:xibo-cms,代码行数:23,代码来源:displaygroupsecurity.data.class.php

示例10: 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;
     }
 }
开发者ID:abbeet,项目名称:server39,代码行数:52,代码来源:userdata.data.class.php

示例11: 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;
     }
 }
开发者ID:fignew,项目名称:xibo-cms,代码行数:25,代码来源:helpmanager.class.php

示例12: 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;
 }
开发者ID:fignew,项目名称:xibo-cms,代码行数:19,代码来源:restjson.class.php

示例13: 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;
     }
 }
开发者ID:abbeet,项目名称:server39,代码行数:25,代码来源:template.data.class.php

示例14: 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;
     }
 }
开发者ID:fignew,项目名称:xibo-cms,代码行数:22,代码来源:tag.data.class.php

示例15: Error

 public function Error($errorNo, $errorMessage = '')
 {
     Debug::LogEntry('audit', $errorMessage, 'RestXml', 'Error');
     header('Content-Type: text/json; charset=utf8');
     // 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;
     $response['rsp']['status'] = 'error';
     $response['rsp']['status']['error']['code'] = $errorNo;
     $response['rsp']['status']['error']['message'] = $errorMessage;
     $return = json_encode($response);
     // Log it
     Debug::LogEntry('audit', $return);
     // Return it as a string
     return $return;
 }
开发者ID:abbeet,项目名称:server39,代码行数:23,代码来源:restjson.class.php


注:本文中的PDOConnect::init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。