当前位置: 首页>>代码示例>>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;未经允许,请勿转载。