• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP DBConnection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了DBConnection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: addNewAdmin

/**
 * Add new admin action
 * @param int $admins_id
 * @return string
 */
function addNewAdmin($admins_id = 0) {

	if ($admins_id && !isset($_POST['_form_submit'])){
		$_SESSION['admin']['uedit'] = $admins_id;
		$db = new DBConnection();
		$query = 'SELECT * FROM ul_logins WHERE id='.($admins_id+0).'';
		$res = $db->rq($query);
		foreach ($db->fetch($res) as $RowName => $RowValue){
			$FormFieldName = str_replace('adm_', '', $RowName);
			$_POST[$FormFieldName] = $RowValue;
		}
        
        $now = new \DateTime();
        $column = new \DateTime($_POST['block_expires']);
        if ($column > $now) {
            $_POST['status'] = 0;
        }
        else {
            $_POST['status'] = 1;
        }
        
        unset($_POST['password']);
        
		$db->close();
	}
	
	$view = new App\View\View('admin/add');
    $view->admin_id = $admins_id;
    $view->data = $_POST;
        
	return $view->render();
}
开发者ID:sahartak,项目名称:v1poject,代码行数:37,代码来源:users_admins.php


示例2: execute

 /**
  * Parse an XML database file and output the corresponding SQL statements.
  * See lib/pkp/dtd/xmlSchema.dtd for the format of the XML files.
  */
 function execute()
 {
     require_once './lib/pkp/lib/adodb/adodb-xmlschema.inc.php';
     if (in_array($this->command, array('print', 'save'))) {
         // Don't connect to actual database (so parser won't build upgrade XML)
         $conn = new DBConnection(Config::getVar('database', 'driver'), null, null, null, null, true, Config::getVar('i18n', 'connection_charset'));
         $dbconn = $conn->getDBConn();
     } else {
         // Create or upgrade existing database
         $dbconn =& DBConnection::getConn();
     }
     $schema = new adoSchema($dbconn);
     $dict =& $schema->dict;
     $dict->SetCharSet(Config::getVar('i18n', 'database_charset'));
     if ($this->type == 'schema') {
         // Parse XML schema files
         $sql = $schema->parseSchema($this->inputFile);
         switch ($this->command) {
             case 'execute':
                 $schema->ExecuteSchema();
                 break;
             case 'save':
             case 'save_upgrade':
                 $schema->SaveSQL($this->outputFile);
                 break;
             case 'print':
             case 'print_upgrade':
             default:
                 echo @$schema->PrintSQL('TEXT') . "\n";
                 break;
         }
     } else {
         if ($this->type == 'data') {
             // Parse XML data files
             $dataXMLParser = new DBDataXMLParser();
             $dataXMLParser->setDBConn($dbconn);
             $sql = $dataXMLParser->parseData($this->inputFile);
             switch ($this->command) {
                 case 'execute':
                     $schema->addSQL($sql);
                     $schema->ExecuteSchema();
                     break;
                 case 'save':
                 case 'save_upgrade':
                     $schema->addSQL($sql);
                     $schema->SaveSQL($this->outputFile);
                     break;
                 case 'print':
                 case 'print_upgrade':
                 default:
                     $schema->addSQL($sql);
                     echo @$schema->PrintSQL('TEXT') . "\n";
                     break;
             }
             $schema->destroy();
             $dataXMLParser->destroy();
         }
     }
 }
开发者ID:farhanabbas1983,项目名称:ojs-1,代码行数:63,代码来源:XmlToSqlTool.inc.php


示例3: asSql

 /**
  * Returns the fragment SQL string
  *
  * @param   rdbms.DBConnection conn
  * @return  string
  * @throws  rdbms.SQLStateException
  */
 public function asSql(DBConnection $conn)
 {
     $s = '';
     foreach ($this->projections as $e) {
         $s .= 0 != strlen($e['alias']) ? $conn->prepare(', %c as %l', $e['projection']->asSql($conn), $e['alias']) : $conn->prepare(', %c', $e['projection']->asSql($conn));
     }
     return substr($s, 1);
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:15,代码来源:ProjectionList.class.php


示例4: executeSelect

 /**
  * Executes an SQL SELECT statement
  *
  * @param   rdbms.DBConnection conn
  * @param   rdbms.Peer peer
  * @param   rdbms.join.Joinprocessor jp optional
  * @param   bool buffered default TRUE
  * @return  rdbms.ResultSet
  */
 public function executeSelect(DBConnection $conn, Peer $peer, $jp = null, $buffered = true)
 {
     $statement = preg_replace('/object\\(([^\\)]+)\\)/i', '$1.' . implode(', $1.', array_keys($peer->types)), $this->statement);
     if ($buffered) {
         return $conn->query($statement, ...$this->arguments);
     } else {
         return $conn->open($statement, ...$this->arguments);
     }
 }
开发者ID:xp-framework,项目名称:rdbms,代码行数:18,代码来源:Statement.class.php


示例5: addLog

function addLog($log_area = '', $log_section = '', $log_user = '', $log_admin = '', $log_details = '')
{
    $user_ip = GetHostByName($_SERVER["REMOTE_ADDR"]);
    $db = new DBConnection();
    $query = 'INSERT INTO logs SET 
	log_area="' . $log_area . '",log_section="' . $log_section . '",log_user="' . $log_user . '",log_admin="' . $log_admin . '",log_details="' . $log_details . '", 
	log_date="' . date('Y-m-d H:i:s', CUSTOMTIME) . '", log_ip="' . $user_ip . '"';
    $db->rq($query);
}
开发者ID:sahartak,项目名称:v1poject,代码行数:9,代码来源:global_funcs.php


示例6: testInitCustomDBConnection

 /**
  * @covers DBConnection::DBConnection
  * @covers DBConnection::initCustomDBConnection
  * @covers DBConnection::initConn
  */
 public function testInitCustomDBConnection()
 {
     $this->setTestConfiguration(self::CONFIG_PGSQL);
     $conn = new DBConnection('sqlite', 'localhost', 'ojs', 'ojs', 'ojs', true, false, false);
     $dbConn = $conn->getDBConn();
     self::assertType('ADODB_sqlite', $dbConn);
     $conn->disconnect();
     unset($conn);
 }
开发者ID:anorton,项目名称:pkp-lib,代码行数:14,代码来源:DBConnectionTest.inc.php


示例7: getSurveyById

		public static function getSurveyById($id) {
			if(!is_int($id)) {
				throw new Exception('Given ID is not integer');
			}
			$table = "lime_survey_" . $id;
			$con = new DBConnection();
			$rs = $con->executeQuery("SELECT * FROM " . $table);			
			return $rs;
		}
开发者ID:KirsiOikarinen,项目名称:LimeSurvey,代码行数:9,代码来源:Dao.php


示例8: addNewAdvisor

function addNewAdvisor($users_advisors_id=0) {
	if ($users_advisors_id&&!$_POST['_form_submit']){
		$_SESSION['admin']['uedit']=$users_advisors_id;
		$db=new DBConnection();
		$query='SELECT * FROM users_advisors WHERE users_advisors_id='.($users_advisors_id+0).'';
		$res=$db->rq($query);
		foreach ($db->fetch($res) as $RowName=>$RowValue){
			$FormFieldName=str_replace('advisor_', '', $RowName);
			$_POST[$FormFieldName]=$RowValue;
		}
		$db->close();
	}
	
	$pcontent='';
	$pcontent.='
<div class="mainHolder">
<div class="hintHolder ui-state-default"><b>'.(($users_advisors_id>0)?'Editing':'Creating New').' Advisor</b></div> 
<script type="text/javascript" src="../js/jquery.validate.js"></script>
<script type="text/javascript" src="js/forms/advisors.js"></script>
<form name="addNewAdvisor" method="POST" id="MainForms" action="">
<fieldset class="mainFormHolder">
	<legend>User information</legend>
	<div class="formsLeft">REF:</div>
	<div class="formsRight">
		<input class="text-input" type="text" name="ref" id="ref" value="'.$_POST['ref'].'" />
	</div>
	<br />
	<div class="formsLeft">Names:</div>
	<div class="formsRight">
		<input class="text-input" name="names" id="names" value="'.$_POST['names'].'" />
	</div>
	<br />
	<div class="formsLeft">Firm:</div>
	<div class="formsRight">
		<input class="text-input" name="firm" id="firm" value="'.$_POST['firm'].'" />
	</div>
	<br />
	<div class="formsLeft">Contacts:</div>
	<div class="formsRight">
		<input class="text-input" name="contacts" id="contacts" value="'.$_POST['contacts'].'" />
	</div>
	<input type="hidden" name="_form_submit" value="1" />
	<input type="submit" name="_submit" value="'.getLang('sform_savebtn').'" class="submitBtn ui-state-default" />
	';
	if ($users_advisors_id){
		$pcontent.='
	<input type="hidden" name="advid" value="'.$users_advisors_id.'">
	<input type="button" name="_delete" value="'.getLang('sform_delbtn').'" class="submitBtn ui-state-default" onclick="if(confirm(\'Are you sure you want to delete this advisor?\')) location=\'?action=delete&advid='.($_POST['users_advisors_id']+0).'\';" />';
	}
	$pcontent.='
	<input type="button" name="_cancel" value="'.getLang('sform_backbtn').'" class="submitBtn ui-state-default" onclick="location=\'users_advisors.php\';" />
	</fieldset>
</form>
</div>';
	return $pcontent;
}
开发者ID:sahartak,项目名称:v1poject,代码行数:56,代码来源:users_advisors.php


示例9: getAssignedAssociateName

function getAssignedAssociateName($username)
{
    $db = new DBConnection();
    $q = "call getAssociate(:assigned)";
    $stmt = $db->prepare($q);
    //    $stmt->setFetchMode(PDO::FETCH_CLASS, 'User');
    $stmt->execute(array(':assigned' => $username));
    $associate = $stmt->fetch(PDO::FETCH_OBJ);
    return $associate->a_name;
}
开发者ID:Kittykras,项目名称:planning,代码行数:10,代码来源:customerHandler.php


示例10: hasTasks

function hasTasks($m_id)
{
    $db = new DBConnection();
    $q = "call checktaskonmain(:mid)";
    $stmt = $db->prepare($q);
    //    $stmt->setFetchMode(PDO::FETCH_OBJ);
    $stmt->execute(array('mid' => $m_id));
    $havetask = $stmt->fetchColumn();
    return $havetask;
}
开发者ID:Kittykras,项目名称:planning,代码行数:10,代码来源:changeBtnTitleAs.php


示例11: __construct

 /**
  * Class constructor
  *
  * @param string $readWriteMode "read", "write" or "admin"
  * @throws ControllerException
  */
 public function __construct($readWriteMode = 'write')
 {
     try {
         $dbc = new DBConnection($readWriteMode);
         $this->_dbh = $dbc->getConnection();
         $this->_dbh->autocommit(TRUE);
     } catch (Exception $e) {
         throw new ControllerException('Problem connecting to database: ' . $this->_dbh->error);
     }
 }
开发者ID:kbcmdba,项目名称:pjs2,代码行数:16,代码来源:ControllerBase.php


示例12: getUserFromCookie

function getUserFromCookie()
{
    $db = new DBConnection();
    $q = "call getassociate(:username)";
    $stmt = $db->prepare($q);
    $userac = htmlEntities2($_COOKIE["UserName"]);
    //    $stmt->setFetchMode(PDO::FETCH_CLASS, 'User');
    $stmt->execute(array(':username' => $userac));
    $user = $stmt->fetch(PDO::FETCH_OBJ);
    $_SESSION["UserName"] = $user;
}
开发者ID:Kittykras,项目名称:planning,代码行数:11,代码来源:userHandler.php


示例13: update

 public function update($id)
 {
     $values = [];
     $columns = [];
     foreach (static::$columns as $column) {
         $values[':' . $column] = $this->{$column};
         $columns[] = $column . '=:' . $column;
     }
     $sql = 'UPDATE' . ' ' . static::$table . ' ' . 'SET' . ' ' . implode(',', $columns) . ' ' . 'WHERE id=:id';
     echo $sql;
     $res = new DBConnection();
     $res->query($sql, $id, $values);
 }
开发者ID:spoliv,项目名称:classfin,代码行数:13,代码来源:AbstractModel.php


示例14: getCalendarByRange

function getCalendarByRange($id)
{
    try {
        $db = new DBConnection();
        $db->getConnection();
        $sql = "select * from `jqcalendar` where `id` = " . $id;
        $handle = mysql_query($sql);
        //echo $sql;
        $row = mysql_fetch_object($handle);
    } catch (Exception $e) {
    }
    return $row;
}
开发者ID:arjint2004,项目名称:uni912015,代码行数:13,代码来源:edit.php


示例15: getwebsitepages

function getwebsitepages($websiteid)
{
    $viewpage = new Website();
    $res = $viewpage->fetchwebpages($websiteid);
    $db = new DBConnection();
    $pagearr = array();
    $count = 0;
    while ($pagerow = $db->fetch_assoc($res)) {
        if (empty($pagecontent)) {
            $pagearr[$count] = $pagerow['page_id'];
            $count++;
        }
    }
    return $pagearr;
}
开发者ID:hscale,项目名称:mtptool,代码行数:15,代码来源:createpage1.php


示例16: getInstance

 public static function getInstance()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new DBConnection();
     }
     return self::$_instance;
 }
开发者ID:jaags,项目名称:satellite,代码行数:7,代码来源:DBConnection.php


示例17: execute

 /**
  * Execute the command
  */
 function execute()
 {
     $stderr = fopen('php://stdout', 'w');
     $locales = AppLocale::getAllLocales();
     $dbConn = DBConnection::getConn();
     foreach ($locales as $locale => $localeName) {
         fprintf($stderr, "Checking {$localeName}...\n");
         $oldTemplatesText = $this->fetchFileVersion('ojs', "locale/{$locale}/emailTemplates.xml", $this->oldTag);
         $newTemplatesText = $this->fetchFileVersion('ojs', "locale/{$locale}/emailTemplates.xml", $this->newTag);
         if ($oldTemplatesText === false || $newTemplatesText === false) {
             fprintf($stderr, "Skipping {$localeName}; could not fetch.\n");
             continue;
         }
         $oldEmails = $this->parseEmails($oldTemplatesText);
         $newEmails = $this->parseEmails($newTemplatesText);
         foreach ($oldEmails['email_text'] as $oi => $junk) {
             $key = $junk['attributes']['key'];
             $ni = null;
             foreach ($newEmails['email_text'] as $ni => $junk) {
                 if ($key == $junk['attributes']['key']) {
                     break;
                 }
             }
             if ($oldEmails['subject'][$oi]['value'] != $newEmails['subject'][$ni]['value']) {
                 echo "UPDATE email_templates_default_data SET subject='" . $dbConn->escape($newEmails['subject'][$ni]['value']) . "' WHERE key='" . $dbConn->escape($key) . "' AND locale='" . $dbConn->escape($locale) . "' AND subject='" . $dbConn->escape($oldEmails['subject'][$oi]['value']) . "';\n";
             }
             if ($oldEmails['body'][$oi]['value'] != $newEmails['body'][$ni]['value']) {
                 echo "UPDATE email_templates_default_data SET body='" . $dbConn->escape($newEmails['body'][$ni]['value']) . "' WHERE key='" . $dbConn->escape($key) . "' AND locale='" . $dbConn->escape($locale) . "' AND body='" . $dbConn->escape($oldEmails['body'][$oi]['value']) . "';\n";
             }
         }
     }
     fclose($stderr);
 }
开发者ID:laelnasan,项目名称:UTFPR-ojs,代码行数:36,代码来源:genEmailUpdates.php


示例18: getInstance

 public static function getInstance()
 {
     if (!self::$m_pInstance) {
         self::$m_pInstance = new DBConnection();
     }
     return self::$m_pInstance;
 }
开发者ID:kendelt,项目名称:MOS,代码行数:7,代码来源:dbConnection.php


示例19: GetComputersByLab

 /**
  * Gets the computers of the asked lab
  */
 public static function GetComputersByLab($lab_id)
 {
     $sql = "select * from Computers where LabID = " . $lab_id . " order by X1, Y1;";
     $results = DBConnection::ExecuteSelectQuery($sql);
     $computers = self::GetArrayFromDBTable($results);
     return $computers;
 }
开发者ID:davyx8,项目名称:cloud-computing-finap-project,代码行数:10,代码来源:computer.php


示例20: loadData

 /**
  * @copydoc GridHandler::loadData()
  */
 protected function loadData($request, $filter)
 {
     $dbconn = DBConnection::getConn();
     $dbServerInfo = $dbconn->ServerInfo();
     $serverInfo = array('admin.server.platform' => Core::serverPHPOS(), 'admin.server.phpVersion' => Core::serverPHPVersion(), 'admin.server.apacheVersion' => function_exists('apache_get_version') ? apache_get_version() : __('common.notAvailable'), 'admin.server.dbDriver' => Config::getVar('database', 'driver'), 'admin.server.dbVersion' => empty($dbServerInfo['description']) ? $dbServerInfo['version'] : $dbServerInfo['description']);
     return $serverInfo;
 }
开发者ID:jprk,项目名称:pkp-lib,代码行数:10,代码来源:ServerInfoGridHandler.inc.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP DBConnector类代码示例发布时间:2022-05-23
下一篇:
PHP DBConnect类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap