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


PHP Adapter\AdapterInterface類代碼示例

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


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

示例1: __construct

 public function __construct(AdapterInterface $adapter)
 {
     $this->adapter = $adapter;
     $platform = $adapter->getPlatform();
     switch (strtolower($platform->getName())) {
         case 'mysql':
             $platform = new Mysql\Mysql();
             $this->decorators = $platform->decorators;
             break;
         case 'sqlserver':
             $platform = new SqlServer\SqlServer();
             $this->decorators = $platform->decorators;
             break;
         case 'oracle':
             $platform = new Oracle\Oracle();
             $this->decorators = $platform->decorators;
             break;
         case 'ibm db2':
         case 'ibm_db2':
         case 'ibmdb2':
             $platform = new IbmDb2\IbmDb2();
             $this->decorators = $platform->decorators;
         default:
     }
 }
開發者ID:tillk,項目名稱:vufind,代碼行數:25,代碼來源:Platform.php

示例2: industries

 public function industries(AdapterInterface $adapter)
 {
     $sql = "SELECT industries_id,industry_name from industries where status=1 ORDER by xorder ASC";
     $statement = $adapter->query($sql);
     $result = $statement->execute();
     return $result;
 }
開發者ID:rachelleannmorales,項目名稱:aboitiz,代碼行數:7,代碼來源:SendEmailTable.php

示例3: prepareDbAdapter

 /**
  * @param AdapterInterface $adapter
  * @param DebugBar $debugbar
  */
 protected function prepareDbAdapter(AdapterInterface $adapter, DebugBar $debugbar)
 {
     $driver = $adapter->getDriver();
     if ($driver instanceof Pdo) {
         $pdo = $driver->getConnection()->getResource();
         $traceablePdo = new TraceablePDO($pdo);
         $pdoCollector = new PDOCollector($traceablePdo);
         $debugbar->addCollector($pdoCollector);
     }
 }
開發者ID:babydraz,項目名稱:ZfSnapPhpDebugBar,代碼行數:14,代碼來源:PhpDebugBarFactory.php

示例4: prepareStatement

 /**
  * {@inheritDoc}
  *
  * @return StatementContainerInterface
  */
 public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
 {
     $parameterContainer = $statementContainer->getParameterContainer();
     if (!$parameterContainer instanceof ParameterContainer) {
         $parameterContainer = new ParameterContainer();
         $statementContainer->setParameterContainer($parameterContainer);
     }
     $statementContainer->setSql($this->buildSqlString($adapter->getPlatform(), $adapter->getDriver(), $parameterContainer));
     return $statementContainer;
 }
開發者ID:zendframework,項目名稱:zend-db,代碼行數:15,代碼來源:AbstractPreparableSql.php

示例5: UnsubscribeList

 public function UnsubscribeList(AdapterInterface $adapter, $from = null, $to = null)
 {
     $sql = 'SELECT * FROM user_unsubscribes';
     $array_data = array();
     if (!empty($from) && !empty($to)) {
         $sql .= ' where created_at >= ? and created_at <= ?';
         $array_data = array($from, $to);
     }
     $statement = $adapter->createStatement($sql, $array_data);
     $result = $statement->execute();
     return $result;
 }
開發者ID:rachelleannmorales,項目名稱:aboitiz,代碼行數:12,代碼來源:UnsubscribeTable.php

示例6: __construct

 public function __construct(AdapterInterface $adapter)
 {
     $this->adapter = $adapter;
     $platform = $adapter->getPlatform();
     switch (strtolower($platform->getName())) {
         case 'mysql':
             $platform = new ZfPlatform\Mysql\Mysql();
             $this->decorators = $platform->decorators;
             $this->setTypeDecorator('Zend\\Db\\Sql\\Select', new Mysql\SelectDecorator());
             break;
         case 'sqlserver':
             $platform = new ZfPlatform\SqlServer\SqlServer();
             $this->decorators = $platform->decorators;
             $this->setTypeDecorator('Zend\\Db\\Sql\\Select', new SqlServer\SelectDecorator());
             break;
         case 'oracle':
             $platform = new ZfPlatform\Oracle\Oracle();
             $this->decorators = $platform->decorators;
             $this->setTypeDecorator('Zend\\Db\\Sql\\Select', new Oracle\SelectDecorator());
             break;
         default:
     }
 }
開發者ID:railsphp,項目名稱:framework,代碼行數:23,代碼來源:Platform.php

示例7: prepareStatement

 /**
  * Prepare statement
  *
  * @param AdapterInterface $adapter
  * @param StatementContainerInterface $statementContainer
  * @return void
  */
 public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
 {
     // ensure statement has a ParameterContainer
     $parameterContainer = $statementContainer->getParameterContainer();
     if (!$parameterContainer instanceof ParameterContainer) {
         $parameterContainer = new ParameterContainer();
         $statementContainer->setParameterContainer($parameterContainer);
     }
     $sqls = array();
     $sqls[self::SHOW] = sprintf($this->specifications[static::SHOW], $this->show);
     $likePart = $this->processLike($adapter->getPlatform(), $adapter->getDriver(), $parameterContainer);
     if (is_array($likePart)) {
         $sqls[self::LIKE] = $this->createSqlFromSpecificationAndParameters($this->specifications[static::LIKE], $likePart);
     }
     $sql = implode(' ', $sqls);
     $statementContainer->setSql($sql);
     return;
 }
開發者ID:joacub,項目名稱:sphinxsearch,代碼行數:25,代碼來源:Show.php

示例8: buildSqlString

 /**
  * @param SqlInterface     $sqlObject
  * @param AdapterInterface $adapter
  *
  * @return string
  *
  * @throws Exception\InvalidArgumentException
  */
 public function buildSqlString(SqlInterface $sqlObject, AdapterInterface $adapter = null)
 {
     return $this->sqlPlatform->setSubject($sqlObject)->getSqlString($adapter ? $adapter->getPlatform() : $this->adapter->getPlatform());
 }
開發者ID:karnurik,項目名稱:zf2-turtorial,代碼行數:12,代碼來源:Sql.php

示例9: getRandomUser

 public function getRandomUser($used = 1)
 {
     $usedCount = $this->getUnusedCount();
     if (intval($usedCount) == 0) {
         return false;
     }
     $userData = $this->getOrderByRand($this->table, array("is_used" => 0), 1);
     if (!$userData) {
         return false;
     }
     $uid = $userData[0]["id"];
     $where = array("id" => $uid);
     $connection = $this->dbAdapter->getDriver()->getConnection();
     $connection->beginTransaction();
     $sql = "select * from " . $this->table . "  where id =? for update";
     $result = $this->dbAdapter->query($sql, array($uid));
     $userInfo = $result->toArray();
     //        $updateData = array("is_used" => $used, "used_time" => time());
     $updateData = array("is_used" => $used);
     if ($userInfo[0]["is_used"] == 0) {
         $this->updateData($this->table, $where, $updateData);
         $connection->commit();
         if (!empty($userInfo)) {
             return $userInfo[0];
         }
     } else {
         $connection->commit();
         return $this->getRandomUser($used);
     }
 }
開發者ID:brighten01,項目名稱:zf2-openstack-api,代碼行數:30,代碼來源:UserSqlMapper.php

示例10: getNewRFollowID

 public function getNewRFollowID()
 {
     $sql = "select max(rfollowID) from rfollow";
     //         echo $sql;
     $statement = $this->dbAdapter->query($sql);
     $result = $statement->execute();
     return $result->current()['max(rfollowID)'] + 1;
 }
開發者ID:pengtt0119,項目名稱:CotestWeb_,代碼行數:8,代碼來源:RFollowMapper.php

示例11: executeInsert

 /**
  * @todo add $columns support
  *
  * @param Insert $insert
  * @return int
  * @throws Exception\RuntimeException
  */
 protected function executeInsert(Insert $insert)
 {
     $insertState = $insert->getRawState();
     if ($insertState['table'] != $this->table) {
         throw new Exception\RuntimeException('The table name of the provided Insert object must match that of the table');
     }
     // apply preInsert features
     $this->featureSet->apply(EventFeatureEventsInterface::EVENT_PRE_INSERT, [$insert]);
     // Most RDBMS solutions do not allow using table aliases in INSERTs
     // See https://github.com/zendframework/zf2/issues/7311
     $unaliasedTable = false;
     if (is_array($insertState['table'])) {
         $tableData = array_values($insertState['table']);
         $unaliasedTable = array_shift($tableData);
         $insert->into($unaliasedTable);
     }
     $statement = $this->sql->prepareStatementForSqlObject($insert);
     $result = $statement->execute();
     $this->lastInsertValue = $this->adapter->getDriver()->getConnection()->getLastGeneratedValue();
     // apply postInsert features
     $this->featureSet->apply(EventFeatureEventsInterface::EVENT_POST_INSERT, [$statement, $result]);
     // Reset original table information in Insert instance, if necessary
     if ($unaliasedTable) {
         $insert->into($insertState['table']);
     }
     return $result->getAffectedRows();
 }
開發者ID:zendframework,項目名稱:zend-db,代碼行數:34,代碼來源:AbstractTableGateway.php

示例12: rollbackTransaction

 public function rollbackTransaction()
 {
     self::$transactionCounter--;
     if (!self::$transactionCounter) {
         $connection = $this->adapter->getDriver()->getConnection();
         $connection->rollback();
     }
 }
開發者ID:jiromm,項目名稱:zf3-skeleton-application,代碼行數:8,代碼來源:CommonTableGateway.php

示例13: getNewPageID

 public function getNewPageID()
 {
     $sql1 = 'select max(pageID) from page';
     $statement = $this->dbAdapter->query($sql1);
     $result = $statement->execute();
     $row = $result->current();
     //         Debug::dump($row  );
     return $row['max(pageID)'] + 1;
 }
開發者ID:summerandelf,項目名稱:CotestWeb_,代碼行數:9,代碼來源:ZendDbSqlMapper.php

示例14: getSqlStringForSqlObject

 /**
  * Get sql string using platform or sql object
  *
  * @param SqlInterface      $sqlObject
  * @param PlatformInterface $platform
  *
  * @return string
  */
 public function getSqlStringForSqlObject(SqlInterface $sqlObject, PlatformInterface $platform = null)
 {
     $platform = $platform ?: $this->adapter->getPlatform();
     if ($this->sqlPlatform) {
         $this->sqlPlatform->setSubject($sqlObject);
         return $this->sqlPlatform->getSqlString($platform);
     }
     return $sqlObject->getSqlString($platform);
 }
開發者ID:tillk,項目名稱:vufind,代碼行數:17,代碼來源:Sql.php

示例15: generateDbConstants

 /**
  * Generates PHP files with field names as constants
  */
 public function generateDbConstants()
 {
     $metadata = new \Zend\Db\Metadata\Metadata($this->dbAdapter);
     $schema = $this->dbAdapter->getDriver()->getConnection()->getCurrentSchema();
     $tables = $metadata->getTableNames($schema, true);
     foreach ($tables as $table) {
         $words = explode('_', $table);
         $class = 'Db';
         foreach ($words as $word) {
             $word[0] = strtoupper($word[0]);
             $class = $class . $word;
         }
         $filename = __DIR__ . '/../Utils/DbConsts/' . $class . '.php';
         if (file_exists($filename)) {
             unlink($filename);
         }
         $writer = new \Zend\Log\Writer\Stream($filename);
         $writer->setFormatter(new \Zend\Log\Formatter\Simple('%message%'));
         $logger = new \Zend\Log\Logger();
         $logger->addWriter($writer);
         $logger->info('<?php');
         $logger->info('');
         $logger->info('namespace Application\\Utils\\DbConsts;');
         $logger->info('');
         $logger->info("class {$class}");
         $logger->info('{');
         $logger->info("    const TABLE = '{$table}';");
         $columns = $metadata->getColumnNames($table, $schema);
         foreach ($columns as $column) {
             $logger->info(vsprintf("    const %s = '%s';", array(strtoupper($column), $column)));
         }
         $logger->info('');
         $hasConst = '
 static public function hasField($field) 
 {
     if (!is_string($field)) {
         return false;
     }
     $field = strtoupper($field);
     $reflect = new \\ReflectionClass(__CLASS__);
     foreach ($reflect->getConstants() as $name => $value) {
         if (strtoupper($value) === $field) {
             return true;
         }
     };
     return false;
 }';
         $logger->info($hasConst);
         $logger->info('}');
         $logger = null;
         chmod($filename, 0777);
     }
 }
開發者ID:FiftyNine,項目名稱:ScpperDB,代碼行數:56,代碼來源:UtilityService.php


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