本文整理汇总了PHP中Zend_Db_Adapter_Pdo_Mysql类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Adapter_Pdo_Mysql类的具体用法?PHP Zend_Db_Adapter_Pdo_Mysql怎么用?PHP Zend_Db_Adapter_Pdo_Mysql使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Db_Adapter_Pdo_Mysql类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveImage
/**
* Faz o upload da imagem
*
* @return array
*/
public function saveImage($array)
{
$db = new Zend_Db_Adapter_Pdo_Mysql(array('host' => 'localhost', 'username' => 'root', 'password' => '', 'dbname' => 'painelpadrao_imagem'));
$form = array("nm_avatar" => $array["file"]["name"], "tp_avatar" => $array["file"]["type"], "sz_avatar" => $array["file"]["size"], "arquivo" => file_get_contents($array["file"]["tmp_name"]));
$result = $db->insert("imagem", $form);
//$sql = "SELECT * FROM imagem WHERE id_avatar = ".$id;
return $result;
}
示例2: indexAction
public function indexAction()
{
$db = new Zend_Db_Adapter_Pdo_Mysql(array('host' => 'localhost', 'username' => 'root', 'password' => '', 'dbname' => 'alphahyd'));
$aTables = $db->listTables();
$this->view->tables = $aTables;
$sql = 'SHOW COLUMNS FROM alphahyd.tmp';
$aRowTables = $db->describeTable('categories');
$this->view->rowTable = $aRowTables;
//var_dump($aRowTables);
}
示例3: testAdapterExceptionInvalidLoginCredentials
public function testAdapterExceptionInvalidLoginCredentials()
{
$params = $this->_util->getParams();
$params['password'] = 'xxxxxxxx';
// invalid password
try {
$db = new Zend_Db_Adapter_Pdo_Mysql($params);
$db->getConnection();
// force a connection
$this->fail('Expected to catch Zend_Db_Adapter_Exception');
} catch (Zend_Exception $e) {
$this->assertType('Zend_Db_Adapter_Exception', $e, 'Expecting object of type Zend_Db_Adapter_Exception, got ' . get_class($e));
}
}
示例4: jsonAction
public function jsonAction()
{
$this->_helper->viewRenderer->setNoRender();
$db_params = OpenContext_OCConfig::get_db_config();
$db = new Zend_Db_Adapter_Pdo_Mysql($db_params);
$db->getConnection();
$requestParams = $this->_request->getParams();
$host = App_Config::getHost();
$reference = new Reference();
$reference->initialize($requestParams);
if ($reference->get_refs()) {
header('Content-Type: application/json; charset=utf8');
//echo Zend_Json::encode($reference->placeTokens);
echo Zend_Json::encode($reference->tmPlaces);
} else {
$this->view->requestURI = $this->_request->getRequestUri();
return $this->render('404error');
}
}
示例5: getAllAsociado
/**
* SUPER-FIXME!
*/
public static function getAllAsociado($sitio = null, $pagina = null, $limit = 0, $orden = "id")
{
$registry = Zend_Registry::getInstance();
$r = $registry->get('config');
$db = new Zend_Db_Adapter_Pdo_Mysql(array('host' => $r->db->config->host, 'username' => $r->db->config->username, 'password' => $r->db->config->password, 'dbname' => $r->db->config->dbname));
$sql = ' select distinct(a.id),a.*, pa.* from archivos as a left join paginas_archivos as pa ON pa.id_archivo = a.id ';
if ($sitio) {
$where = "where ";
$sql_add[] = "a.id_sitio = " . $sitio . " ";
}
if ($pagina) {
$where = "where ";
$sql_add[] = "pa.id_pagina = " . $pagina . " ";
}
$where = $where . implode(' AND ', $sql_add);
echo $sql . $where;
$result = $db->query($sql . $where);
$archivos = $result->fetchAll();
return $archivos;
}
示例6: query
/**
* Special handling for PDO query().
* All bind parameter names must begin with ':'.
*
* @param string|Zend_Db_Select $sql The SQL statement with placeholders.
* @param mixed $bind An array of data or data itself to bind to the placeholders.
*
* @return Zend_Db_Statement_Pdo
* @throws Zend_Db_Adapter_Exception To re-throw PDOException.
*/
public function query($sql, $bind = [])
{
$this->_debugTimer();
$result = null;
try {
$this->_checkDdlTransaction($sql);
$this->_prepareQuery($sql, $bind);
$maxTries = 1 + (isset($this->_config['retries']) ? min(max(intval($this->_config['retries']), 0), 5) : 5);
$retryPower = isset($this->_config['retry_power']) ? min(max(intval($this->_config['retry_power']), 1), 5) : 2;
$try = 0;
while ($try < $maxTries) {
try {
$result = Zend_Db_Adapter_Pdo_Mysql::query($sql, $bind);
$try = $maxTries;
} catch (Exception $e) {
$try++;
Mage::log("Max retry:{$maxTries} retry power:{$retryPower}", Zend_Log::DEBUG);
if ($try < $maxTries) {
$message = null;
if ($e instanceof PDOException) {
$message = $e->getMessage();
} elseif ($e->getPrevious() instanceof PDOException) {
$message = $e->getPrevious()->getMessage();
} else {
Mage::log("Exception is instance of " . get_class($e), Zend_Log::DEBUG);
Mage::log("Previous Exception is instance of " . get_class($e->getPrevious()), Zend_Log::DEBUG);
}
if ($message && in_array($message, $this->retryOnMessages)) {
$sleepSeconds = pow($try, $retryPower);
Mage::log("Retrying query [retry:{$try} delay:{$sleepSeconds}]: {$message}", Zend_Log::DEBUG);
if ($try === 1) {
Mage::logException($e);
}
sleep($sleepSeconds);
continue;
}
}
throw $e;
}
}
} catch (Exception $e) {
$this->_debugStat(self::DEBUG_QUERY, $sql, $bind);
$this->_debugException($e);
}
$this->_debugStat(self::DEBUG_QUERY, $sql, $bind, $result);
return $result;
}
示例7: testFetchItem
public function testFetchItem()
{
$data = [1 => 'test'];
$statementMock = $this->getMock('Zend_Db_Statement_Pdo', ['fetch'], [], '', false);
$statementMock->expects($this->once())->method('fetch')->will($this->returnValue($data));
$this->adapterMock->expects($this->once())->method('query')->with($this->selectMock, $this->anything())->will($this->returnValue($statementMock));
$objectMock = $this->getMock('Magento\\Framework\\Model\\AbstractModel', ['setData'], [], '', false);
$objectMock->expects($this->once())->method('setData')->with($data);
$this->entityFactoryMock->expects($this->once())->method('create')->with('Magento\\Review\\Model\\Review\\Summary')->will($this->returnValue($objectMock));
$item = $this->collection->fetchItem();
$this->assertEquals($objectMock, $item);
$this->assertEquals('id', $item->getIdFieldName());
}
示例8: _connect
/**
* Connects to the database.
*
*/
protected function _connect()
{
parent::_connect();
if (!$this->_initialized) {
$this->_initialized = true;
if ($this->_config['timezone']) {
// Requires PHP 5.2+
$dtz = new DateTimeZone($this->_config['timezone']);
$offset = $dtz->getOffset(new DateTime('NOW')) / 60 / 60;
if ($offset > 0) {
$offset = "+" . $offset;
}
/*
echo "location: ".$dtz->getLocation()."<br />";
echo "offset: ".$dtz->getOffset(new DateTime('NOW'))."<br />";
echo "offset 2: ". $offset."<br />";
echo "SET time_zone = '$offset:00'"."<br />";
*/
$this->query("SET time_zone = '{$offset}:00';");
//sprintf("SET time_zone = '%d:00'", $offset));
/*
$timezone = new DateTimeZone($this->_config['timezone']);
$minutes = $timezone->getOffset(new DateTime('NOW')) / 60 / 60;
//$offset = sprintf("SET time_zone = '%d:%2d'", $minutes / 60, $minutes % 60);
$offset = sprintf("SET time_zone = '%d:00'", $offset);
*
*/
}
}
}
示例9: rollBack
function rollBack()
{
$this->_transaction_depth--;
if ($this->shouldEmulateNesting()) {
return;
}
return parent::rollBack();
}
示例10: rollback
public function rollback()
{
if ($this->_transactionLevel === 1) {
return parent::rollback();
}
$this->_transactionLevel--;
return $this;
}
示例11: insert
/**
* Inserts a table row with specified data.
*
* @param mixed $table The table to insert data into.
* @param array $bind Column-value pairs.
* @return int The number of affected rows.
*/
public function insert($table = null, array $bind = null)
{
if (is_null($table) && is_null($bind)) {
return new Harmoni_Db_Insert($this);
} else {
return parent::insert($table, $bind);
}
}
示例12: _checkRequiredOptions
/**
* Checks if the required options have been provided into the $config array
*
* @param array $config configuration options
* @return void
* @throws Streamwide_Db_Adapter_Exception
*/
protected function _checkRequiredOptions(array $config)
{
if (!array_key_exists('host', $config)) {
require_once 'Zend/Db/Adapter/Exception.php';
throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'host' naming the hostname or ip of the database server");
}
parent::_checkRequiredOptions($config);
}
示例13: _connect
protected function _connect()
{
// if we already have a PDO object, no need to re-connect.
if ($this->_connection) {
return;
}
parent::_connect();
// set connection to utf8
$this->query('SET NAMES utf8');
}
示例14: addSingleRight
/**
* add single role rights
*
* @param int $_roleId
* @param int $_applicationId
* @param string $_right
*/
public function addSingleRight($_roleId, $_applicationId, $_right)
{
// check if already in
$select = $this->_roleRightsTable->select();
$select->where($this->_db->quoteInto($this->_db->quoteIdentifier('role_id') . ' = ?', $_roleId))->where($this->_db->quoteInto($this->_db->quoteIdentifier('right') . ' = ?', $_right))->where($this->_db->quoteInto($this->_db->quoteIdentifier('application_id') . ' = ?', $_applicationId));
if (!($row = $this->_roleRightsTable->fetchRow($select))) {
$data = array('role_id' => $_roleId, 'application_id' => $_applicationId, 'right' => $_right);
$this->_roleRightsTable->insert($data);
}
}
示例15: _connect
/**
* Creates a PDO object and connects to the database.
*
* @return void
* @throws Zend_Db_Adapter_Exception
*/
protected function _connect()
{
if ($this->_connection) {
return;
}
if (!empty($this->_config['timeout'])) {
$this->_config['driver_options'][PDO::ATTR_TIMEOUT] = $this->_config['timeout'];
}
parent::_connect();
}