本文整理汇总了PHP中resource::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP resource::setAttribute方法的具体用法?PHP resource::setAttribute怎么用?PHP resource::setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类resource
的用法示例。
在下文中一共展示了resource::setAttribute方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: open
/**
* Opens an SQLite database.
*
* @param type $filename Path to the SQLite database, or :memory: to use
* in-memory database.
*
* @throws SQLiteException on failure.
*/
private function open($filename)
{
try {
$this->link = new PDO('sqlite:' . $filename);
} catch (PDOException $e) {
throw new SQLiteException($e->getMessage());
}
$this->link->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
示例2: _connect
/**
* Creates a connection to the database.
*/
protected function _connect()
{
if ($this->connection) {
return;
}
$this->connection = new PDO($this->_dsn(), $this->cfg->user, $this->cfg->pass, $this->cfg->driverOptions);
foreach ($this->cfg->conQuery as $q) {
$this->connection->query($q);
}
$this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
示例3: PDO
function __construct()
{
/*//Conectando ao banco de dados
$this->o_db = new PDO("sqlite:./databases/db.sq3");*/
//Mudando para MySQL
$st_host = 'localhost';
$st_banco = 'ufpa_pdti';
$st_usuario = 'root';
$st_senha = '';
$st_dsn = "mysql:host={$st_host};dbname={$st_banco}";
$this->o_db = new PDO($st_dsn, $st_usuario, $st_senha);
$this->o_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
示例4: query
/**
* Query the database
*
* @param string $queryStr SQL query string
* @return resource MySQL result set
*/
public function query($queryStr, $unbuffered = false)
{
// set the result to false
$result = false;
try {
// set buffer attribute
$this->connection->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, !$unbuffered);
$result = $this->connection->query($queryStr);
$this->_result = $result;
} catch (PDOException $e) {
$this->_handleError($e, true, "Query String: " . $queryStr);
}
return $result;
}
示例5: getConnection
public function getConnection()
{
try {
if ($this->dbh == null) {
$this->dbh = new PDO($this->connectionString, $this->username, $this->password);
$this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->dbh->query("SET NAMES 'utf8'");
}
return $this->dbh;
} catch (Exception $e) {
Logger::getLogger('system.services.Storage.GenericDAO')->error('Cannot connect to the database: ' . $e->getMessage());
throw $e;
}
}
示例6: catch
function __construct($db = null)
{
if (class_exists('jqGridDB') && $db) {
$interface = jqGridDB::getInterface();
} else {
$interface = 'chartarray';
}
$this->conn = $db;
if ($interface == 'pdo') {
try {
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->dbtype = $this->conn->getAttribute(PDO::ATTR_DRIVER_NAME);
} catch (Exception $e) {
}
} else {
$this->dbtype = $interface;
}
# Set Default Values
$this->coptions['credits']['enabled'] = false;
$this->coptions['chart']['renderTo'] = '';
$this->coptions['series'] = array();
$this->i_serie_index = 0;
$this->jscode = false;
}
示例7: query
/**
* 执行查询语句
*
* @access public
* @param $sql
* @return array|boolean
*/
public function query($sql)
{
$this->connect();
if (!$this->_linkId) {
return false;
}
try {
$this->_linkId->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
$this->_queryId = $this->_linkId->query($sql);
} catch (PDOException $e) {
trigger_error('MySQL PDO query error: ' . $e->getMessage() . ' [' . $sql . ']');
}
$result = array();
if ($this->_queryId) {
$this->_queryId->setFetchMode(PDO::FETCH_ASSOC);
$result = $this->_queryId->fetchAll();
$this->_numRows = count($result);
}
return $result;
}
示例8: addSearch
/**
* Fügt eine Beschreibung der Suchfunktionalität ein
* @param string Name der Suchseite, z. B. "Search"
* @param string Beschreibung der Suchseite, z. B.
* "Search SitePoint..."
* @param string URL der Suchseite
* @param string GET-Variable für die Suche, z. B.
* "q" für "?q="
* @return void
* @access public
*/
public function addSearch($title, $desc, $url, $var)
{
$this->addChannelTextInput($url);
$this->textinput = $this->dom->createElement('textinput');
$this->textinput->setAttribute('rdf:about', $url);
$titleNode = $this->dom->createElement('title');
$titleNodeText = $this->dom->createTextNode($title);
$titleNode->appendChild($titleNodeText);
$this->textinput->appendChild($titleNode);
$descNode = $this->dom->createElement('description');
$descNodeText = $this->dom->createTextNode($desc);
$descNode->appendChild($descNodeText);
$this->textinput->appendChild($descNode);
$nameNode = $this->dom->createElement('name');
$nameNodeText = $this->dom->createTextNode($var);
$nameNode->appendChild($nameNodeText);
$this->textinput->appendChild($nameNode);
$linkNode = $this->dom->createElement('link');
$linkNodeText = $this->dom->createTextNode($url);
$linkNode->appendChild($linkNodeText);
$this->textinput->appendChild($linkNode);
}
示例9: PDO
function __construct()
{
$this->o_db = new PDO('mysql:host=localhost;dbname=teste', 'root', '', array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
$this->o_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->o_db->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_EMPTY_STRING);
}