當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DBConnection類代碼示例

本文整理匯總了PHP中DBConnection的典型用法代碼示例。如果您正苦於以下問題:PHP DBConnection類的具體用法?PHP DBConnection怎麽用?PHP DBConnection使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了DBConnection類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的DBConnection類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。