本文整理汇总了PHP中Zend_Db_Adapter_Abstract类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Adapter_Abstract类的具体用法?PHP Zend_Db_Adapter_Abstract怎么用?PHP Zend_Db_Adapter_Abstract使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Db_Adapter_Abstract类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: applyTo
/**
* Apply filter
* @param Zend_Db_Adapter_Abstract $db
* @param Db_Select | Zend_Db_Select $sql
* @throws Exception
*/
public function applyTo(Zend_Db_Adapter_Abstract $db, $sql)
{
if (!$sql instanceof Db_Select && !$sql instanceof Zend_Db_Select) {
throw new Exception('Db_Select_Filter::applyTo $sql must be instance of Db_Select/Zend_Db_Select');
}
$quotedField = $db->quoteIdentifier($this->field);
switch ($this->type) {
case self::LT:
case self::GT:
case self::EQ:
case self::GT_EQ:
case self::LT_EQ:
case self::LIKE:
case self::NOT:
case self::NOT_LIKE:
$sql->where($quotedField . ' ' . $this->type . ' ?', $this->value);
break;
case self::IN:
case self::NOT_IN:
$sql->where($quotedField . ' ' . $this->type . ' (?)', $this->value);
break;
case self::NOT_NULL:
case self::IS_NULL:
$sql->where($quotedField . ' ' . $this->type);
break;
case self::BETWEEN:
case self::NOT_BETWEEN:
$sql->where($quotedField . ' ' . $this->type . ' ' . $db->quote($this->value[0]) . ' AND ' . $db->quote($this->value[1]));
break;
}
}
示例2: _truncate
/**
* Truncate a given table.
*
* @param Zend_Db_Adapter_Abstract $db
* @param string $tableName
* @return void
*/
protected function _truncate(Zend_Db_Adapter_Abstract $db, $tableName)
{
$tableName = $db->quoteIdentifier($tableName, true);
if ($db instanceof Zend_Db_Adapter_Pdo_Sqlite) {
$db->query('DELETE FROM ' . $tableName);
} else {
if ($db instanceof Zend_Db_Adapter_Db2) {
/*if(strstr(PHP_OS, "WIN")) {
$file = tempnam(sys_get_temp_dir(), "zendtestdbibm_");
file_put_contents($file, "");
$db->query('IMPORT FROM '.$file.' OF DEL REPLACE INTO '.$tableName);
unlink($file);
} else {
$db->query('IMPORT FROM /dev/null OF DEL REPLACE INTO '.$tableName);
}*/
require_once "Zend/Exception.php";
throw Zend_Exception("IBM Db2 TRUNCATE not supported.");
} else {
if ($this->_isMssqlOrOracle($db)) {
$db->query('TRUNCATE TABLE ' . $tableName);
} else {
if ($db instanceof Zend_Db_Adapter_Pdo_Pgsql) {
$db->query('TRUNCATE ' . $tableName . ' CASCADE');
} else {
$db->query('TRUNCATE ' . $tableName);
}
}
}
}
}
示例3: attachmentPostDelete
/**
* Code to run after deleting an associated attachment.
*
* @see XenForo_AttachmentHandler_Abstract::attachmentPostDelete()
*/
public function attachmentPostDelete(array $attachment, Zend_Db_Adapter_Abstract $db)
{
$db->query('
UPDATE xf_user_profile
SET about_attach_count = IF(about_attach_count > 0, about_attach_count - 1, 0)
WHERE user_id = ?
', $attachment['content_id']);
}
示例4: attachmentPostDelete
/**
* Code to run after deleting an associated attachment.
*
* @see XenForo_AttachmentHandler_Abstract::attachmentPostDelete()
*/
public function attachmentPostDelete(array $attachment, Zend_Db_Adapter_Abstract $db)
{
$db->query('
UPDATE xf_conversation_message
SET attach_count = IF(attach_count > 0, attach_count - 1, 0)
WHERE message_id = ?
', $attachment['content_id']);
}
示例5: setAutocommit
/**
* setAutocommit
*
* @param Zend_Db_Adapter_Abstract $adapter
* @param boolean $on
*/
public static function setAutocommit($adapter, $on)
{
if ($on) {
$adapter->query('SET AUTOCOMMIT=1;');
} else {
$adapter->query('SET AUTOCOMMIT=0;');
}
}
示例6: _getSqlDropSequence
protected function _getSqlDropSequence(Zend_Db_Adapter_Abstract $db, $sequenceName)
{
$seqList = $db->fetchCol('SELECT sequence_name FROM ALL_SEQUENCES');
if (in_array($sequenceName, $seqList)) {
return 'DROP SEQUENCE';
}
return null;
}
示例7: processTokenData
/**
* Process the data and return the answers that should be changed.
*
* Storing the changed values is handled by the calling function.
*
* @param \Gems_Tracker_Token $token Gems token object
* @return array Containing the changed values
*/
public function processTokenData(\Gems_Tracker_Token $token)
{
if (!$token->getReceptionCode()->isSuccess()) {
return;
}
$answers = $token->getRawAnswers();
if (isset($answers['informedconsent'])) {
$consent = $this->util->getConsent($answers['informedconsent']);
if ($consent->exists) {
// Is existing consent description as answer
$consentCode = $consent->getDescription();
} else {
if ($answers['informedconsent']) {
// Uses start of consent description as answer (LS has only 5 chars for an answer option)
$consentCode = $this->db->fetchOne("SELECT gco_description FROM gems__consents WHERE gco_description LIKE ? ORDER BY gco_order", $answers['informedconsent'] . '%');
} else {
$consentCode = false;
}
if (!$consentCode) {
if ($answers['informedconsent']) {
// Code not found, use first positive consent
$consentCode = $this->db->fetchOne("SELECT gco_description FROM gems__consents WHERE gco_code != ? ORDER BY gco_order", $this->util->getConsentRejected());
} else {
// Code not found, use first negative consent
$consentCode = $this->db->fetchOne("SELECT gco_description FROM gems__consents WHERE gco_code = ? ORDER BY gco_order", $this->util->getConsentRejected());
}
}
}
$respondent = $token->getRespondent();
$values = array('gr2o_patient_nr' => $respondent->getPatientNumber(), 'gr2o_id_organization' => $respondent->getOrganizationId(), 'gr2o_consent' => $consentCode);
$respondent->getRespondentModel()->save($values);
}
return false;
}
示例8: getById
/**
* Fetches a single order by its unique Id.
*
* @param int $id
* @return Order
*/
public function getById($id)
{
try {
$result = $this->_database->fetchOne(
'SELECT o.*,c.* FROM order o INNER JOIN customer c ON o.customer_id = c.id WHERE o.id = ?',
array($id));
if ($result == null) throw new \Exception("Could not find order with id " . $id);
$customer = new Customer();
$customer->setName($result['name']);
$customer->setAddress1($result['address_1']);
$customer->setAddress2($result['address_2']);
$customer->setCity($result['city']);
$customer->setState($result['state']);
$customer->setPostalCode($result['postal_code']);
$customer->setCellphone($result['cell_phone']);
$customer->setEmail($result['email']);
$customer->setCallbackUrl($result['callback_url']);
$order = new Order();
$order->setId($id);
$order->setCustomer($customer);
return $order;
}
catch (\Exception $e)
{
throw $e;
}
}
示例9: execute
/**
* Should handle execution of the task, taking as much (optional) parameters as needed
*
* The parameters should be optional and failing to provide them should be handled by
* the task
*/
public function execute($lineNr = null, $organizationData = null)
{
$batch = $this->getBatch();
$import = $batch->getVariable('import');
if (isset($organizationData['gor_id_organization']) && $organizationData['gor_id_organization']) {
$oldId = $organizationData['gor_id_organization'];
} else {
$oldId = false;
$batch->addToCounter('import_errors');
$batch->addMessage(sprintf($this->_('No gor_id_organization not specified for organization at line %d.'), $lineNr));
}
if (isset($organizationData['gor_name']) && $organizationData['gor_name']) {
if ($oldId) {
$orgId = $this->db->fetchOne("SELECT gor_id_organization FROM gems__organizations WHERE gor_name = ?", $organizationData['gor_name']);
if ($orgId) {
$import['organizationIds'][$oldId] = $orgId;
$import['formDefaults']['gtr_organizations'][] = $orgId;
} else {
$import['organizationIds'][$oldId] = false;
}
}
} else {
$orgId = false;
$batch->addToCounter('import_errors');
$batch->addMessage(sprintf($this->_('No gor_name not specified for organization at line %d.'), $lineNr));
}
}
示例10: execute
/**
* Should handle execution of the task, taking as much (optional) parameters as needed
*
* The parameters should be optional and failing to provide them should be handled by
* the task
*
* @param array $row Row to save
*/
public function execute($row = null)
{
if ($row) {
if (!isset($row['grs_id_user']) && isset($row['grs_ssn']) && $this->targetModel instanceof \Gems_Model_RespondentModel && $this->targetModel->hashSsn !== \Gems_Model_RespondentModel::SSN_HIDE) {
if (\Gems_Model_RespondentModel::SSN_HASH === $this->targetModel->hashSsn) {
$search = $this->targetModel->saveSSN($row['grs_ssn']);
} else {
$search = $row['grs_ssn'];
}
$sql = 'SELECT grs_id_user FROM gems__respondents WHERE grs_ssn = ?';
$id = $this->db->fetchOne($sql, $search);
// Check for change in patient ID
if ($id) {
if (isset($row['gr2o_id_organization']) && $this->targetModel instanceof \MUtil_Model_DatabaseModelAbstract) {
$sql = 'SELECT gr2o_patient_nr
FROM gems__respondent2org
WHERE gr2o_id_user = ? AND gr2o_id_organization = ?';
$patientId = $this->db->fetchOne($sql, array($id, $row['gr2o_id_organization']));
if ($patientId) {
// Change the patient number
$copyId = $this->targetModel->getKeyCopyName('gr2o_patient_nr');
$row[$copyId] = $patientId;
}
}
$row['grs_id_user'] = $id;
$row['gr2o_id_user'] = $id;
}
}
parent::execute($row);
}
}
示例11: execute
/**
* Should handle execution of the task, taking as much (optional) parameters as needed
*
* The parameters should be optional and failing to provide them should be handled by
* the task
*/
public function execute($sourceId = null, $userId = null)
{
$now = new \MUtil_Db_Expr_CurrentTimestamp();
$values = array('gso_last_synch' => $now, 'gso_changed' => $now, 'gso_changed_by' => $userId);
$where = $this->db->quoteInto('gso_id_source = ?', $sourceId);
$this->db->update('gems__sources', $values, $where);
}
示例12: __construct
public function __construct()
{
$this->_db = XenForo_Application::getDb();
$this->_importModel = XenForo_Model::create('XenForo_Model_Import');
$this->_db->setProfiler(false);
// this causes lots of memory usage in debug mode, so stop that
}
示例13: deleteOther
public function deleteOther(ActiveSync_Model_SyncState $_syncState)
{
// remove all other synckeys
$where = array($this->_db->quoteInto('device_id = ?', $_syncState->device_id), $this->_db->quoteInto('type = ?', $_syncState->type), $this->_db->quoteInto('counter != ?', $_syncState->counter));
$this->_db->delete(SQL_TABLE_PREFIX . 'acsync_synckey', $where);
return true;
}
示例14: isValid
public function isValid($value, $context = null)
{
$result = true;
$this->_value = $value;
$where = array();
$where[] = $this->dbAdapter->quoteInto("(p.url_id = ? OR pt.url_id = ?)", $value);
if (isset($this->_data['id'])) {
$where[] = $this->dbAdapter->quoteInto("(p.id <> ?)", $this->_data['id']);
}
if (isset($this->_data['type_id'])) {
$where[] = $this->dbAdapter->quoteInto("(p.type_id = ?)", $this->_data['type_id']);
}
$where = implode(' AND ', $where);
$sql = "SELECT COUNT(p.id) AS doubles\n FROM cms_page AS p\n LEFT JOIN cms_page_tr AS pt ON (p.id = pt.translation_id AND pt.language = '" . $this->_lang . "')\n WHERE {$where}";
//echo "\n\n$sql\n\n"; die();
$resultSet = $this->dbAdapter->fetchAll($sql);
if (0 == count($resultSet)) {
return false;
}
$row = $resultSet[0];
$result = $row['doubles'] == 0;
if (!$result) {
$this->_error(self::URLID_EXISTS);
}
return $result;
}
示例15: processFilterAndSort
/**
* Overrule to implement snippet specific filtering and sorting.
*
* @param \MUtil_Model_ModelAbstract $model
*/
protected function processFilterAndSort(\MUtil_Model_ModelAbstract $model)
{
$filter[] = $this->db->quoteInto("gr2t_id_respondent_track IN (\n SELECT gr2t2a_id_respondent_track\n FROM gems__respondent2track2appointment\n WHERE gr2t2a_id_appointment = ?)", $this->request->getParam(\Gems_Model::APPOINTMENT_ID));
// \MUtil_Model::$verbose = true;
$model->setFilter($filter);
$this->processSortOnly($model);
}