php Zend-Db-Adapter-AdapterInterface类(方法)实例源码

下面列出了php Zend-Db-Adapter-AdapterInterface 类(方法)源码代码实例,从而了解它的用法。

作者:till    项目:vufin   
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:
     }
 }

作者:rachelleannmorale    项目:aboiti   
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;
 }

作者:babydra    项目:ZfSnapPhpDebugBa   
/**
  * @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);
     }
 }

作者:zendframewor    项目:zend-d   
/**
  * {@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;
 }

作者:rachelleannmorale    项目:aboiti   
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;
 }

作者:railsph    项目:framewor   
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:
     }
 }

作者:joacu    项目:sphinxsearc   
/**
  * 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;
 }

作者:karnuri    项目:zf2-turtoria   
/**
  * @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());
 }

作者:tejdeep    项目:tejcs.co   
/**
  * Prepare the delete statement
  *
  * @param  AdapterInterface $adapter
  * @param  StatementContainerInterface $statementContainer
  * @return void
  */
 public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
 {
     $driver = $adapter->getDriver();
     $platform = $adapter->getPlatform();
     $parameterContainer = $statementContainer->getParameterContainer();
     if (!$parameterContainer instanceof ParameterContainer) {
         $parameterContainer = new ParameterContainer();
         $statementContainer->setParameterContainer($parameterContainer);
     }
     $table = $this->table;
     $schema = null;
     // create quoted table name to use in delete processing
     if ($table instanceof TableIdentifier) {
         list($table, $schema) = $table->getTableAndSchema();
     }
     $table = $platform->quoteIdentifier($table);
     if ($schema) {
         $table = $platform->quoteIdentifier($schema) . $platform->getIdentifierSeparator() . $table;
     }
     $sql = sprintf($this->specifications[static::SPECIFICATION_DELETE], $table);
     // process where
     if ($this->where->count() > 0) {
         $whereParts = $this->processExpression($this->where, $platform, $driver, 'where');
         $parameterContainer->merge($whereParts->getParameterContainer());
         $sql .= ' ' . sprintf($this->specifications[static::SPECIFICATION_WHERE], $whereParts->getSql());
     }
     $statementContainer->setSql($sql);
 }

作者:AlexandrKozy    项目:ver_sit   
/**
  * 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();
     $parameters = array();
     $platform = $adapter->getPlatform();
     $driver = $adapter->getDriver();
     foreach ($this->specifications as $name => $specification) {
         $parameters[$name] = $this->{'process' . $name}($platform, $driver, $parameterContainer, $sqls, $parameters);
         if ($specification && is_array($parameters[$name])) {
             $sqls[$name] = $this->createSqlFromSpecificationAndParameters($specification, $parameters[$name]);
         }
     }
     $sql = implode(' ', $sqls);
     $statementContainer->setSql($sql);
     return;
 }

作者:karnuri    项目:zf2-turtoria   
/**
  * @param null|PlatformInterface|AdapterInterface $adapterOrPlatform
  *
  * @return PlatformInterface
  *
  * @throws Exception\InvalidArgumentException
  */
 protected function resolvePlatform($adapterOrPlatform)
 {
     if (!$adapterOrPlatform) {
         return $this->getDefaultPlatform();
     }
     if ($adapterOrPlatform instanceof AdapterInterface) {
         return $adapterOrPlatform->getPlatform();
     }
     if ($adapterOrPlatform instanceof PlatformInterface) {
         return $adapterOrPlatform;
     }
     throw new Exception\InvalidArgumentException(sprintf('$adapterOrPlatform should be null, %s, or %s', 'Zend\\Db\\Adapter\\AdapterInterface', 'Zend\\Db\\Adapter\\Platform\\PlatformInterface'));
 }

作者:railsph    项目:framewor   
public function __construct(AdapterInterface $adapter)
 {
     $this->adapter = $adapter;
     $this->defaultSchema = $adapter->getCurrentSchema() ?: self::DEFAULT_SCHEMA;
 }

作者:Maxlande    项目:shix   
/**
  * Prepare statement
  *
  * @param AdapterInterface $adapter
  * @param StatementContainerInterface $statementContainer
  * @return void
  */
 public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
 {
     $driver = $adapter->getDriver();
     $platform = $adapter->getPlatform();
     $parameterContainer = $statementContainer->getParameterContainer();
     if (!$parameterContainer instanceof ParameterContainer) {
         $parameterContainer = new ParameterContainer();
         $statementContainer->setParameterContainer($parameterContainer);
     }
     $table = $this->table;
     $schema = null;
     // create quoted table name to use in update processing
     if ($table instanceof TableIdentifier) {
         list($table, $schema) = $table->getTableAndSchema();
     }
     $table = $platform->quoteIdentifier($table);
     if ($schema) {
         $table = $platform->quoteIdentifier($schema) . $platform->getIdentifierSeparator() . $table;
     }
     $set = $this->set;
     if (is_array($set)) {
         $setSql = array();
         foreach ($set as $column => $value) {
             if ($value instanceof Expression) {
                 $exprData = $this->processExpression($value, $platform, $driver);
                 $setSql[] = $platform->quoteIdentifier($column) . ' = ' . $exprData->getSql();
                 $parameterContainer->merge($exprData->getParameterContainer());
             } else {
                 $setSql[] = $platform->quoteIdentifier($column) . ' = ' . $driver->formatParameterName($column);
                 $parameterContainer->offsetSet($column, $value);
             }
         }
         $set = implode(', ', $setSql);
     }
     $sql = sprintf($this->specifications[static::SPECIFICATION_UPDATE], $table, $set);
     // process where
     if ($this->where->count() > 0) {
         $whereParts = $this->processExpression($this->where, $platform, $driver, 'where');
         $parameterContainer->merge($whereParts->getParameterContainer());
         $sql .= ' ' . sprintf($this->specifications[static::SPECIFICATION_WHERE], $whereParts->getSql());
     }
     $statementContainer->setSql($sql);
 }

作者:zhangyuxia    项目:qoro   
/**
  * Prepare statement
  *
  * @param  AdapterInterface $adapter
  * @param  StatementContainerInterface $statementContainer
  * @return void
  */
 public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
 {
     $driver = $adapter->getDriver();
     $platform = $adapter->getPlatform();
     $parameterContainer = $statementContainer->getParameterContainer();
     if (!$parameterContainer instanceof ParameterContainer) {
         $parameterContainer = new ParameterContainer();
         $statementContainer->setParameterContainer($parameterContainer);
     }
     $table = $this->table;
     $schema = null;
     // create quoted table name to use in insert processing
     if ($table instanceof TableIdentifier) {
         list($table, $schema) = $table->getTableAndSchema();
     }
     $table = $platform->quoteIdentifier($table);
     if ($schema) {
         $table = $platform->quoteIdentifier($schema) . $platform->getIdentifierSeparator() . $table;
     }
     $columns = array();
     $values = array();
     foreach ($this->columns as $cIndex => $column) {
         $columns[$cIndex] = $platform->quoteIdentifier($column);
         if (isset($this->values[$cIndex]) && $this->values[$cIndex] instanceof Expression) {
             $exprData = $this->processExpression($this->values[$cIndex], $platform, $driver);
             $values[$cIndex] = $exprData->getSql();
             $parameterContainer->merge($exprData->getParameterContainer());
         } else {
             $values[$cIndex] = $driver->formatParameterName($column);
             if (isset($this->values[$cIndex])) {
                 $parameterContainer->offsetSet($column, $this->values[$cIndex]);
             } else {
                 $parameterContainer->offsetSet($column, null);
             }
         }
     }
     $sql = sprintf($this->specifications[self::SPECIFICATION_INSERT], $table, implode(', ', $columns), implode(', ', $values));
     $statementContainer->setSql($sql);
 }

作者:rachelleannmorale    项目:aboiti   
public function childModuleAccessRights(AdapterInterface $adapter, $module_id, $function_name)
 {
     //Get user credentials
     $session = new Container('base');
     $user = $session->offsetGet('user');
     $this->adapter = $adapter;
     $statement = $adapter->query("SELECT `module_name`, function_name\n                                        FROM\n                                         `app_sub_accesses`\n                                        LEFT JOIN\n                                         `app_modules`\n                                        ON\n                                         `app_modules`.`app_modules_id` = `app_sub_accesses`.`module_id`\n                                         LEFT JOIN\n                                         `app_roles`\n                                         ON\n                                          `app_sub_accesses`.`role_id` = `app_roles`.`app_roles_id`\n                                          WHERE\n                                          `app_roles`.`app_roles_id`= " . $user['role_id'] . "\n                                          AND `app_modules`.`app_modules_id` = {$module_id}\n                                          AND `app_roles`.`status`=1\n                                          AND function_name='" . $function_name . "'\n                                        ");
     $result = $statement->execute();
     //Count number of records
     if (count($result) > 0) {
         return true;
     } else {
         return false;
     }
 }

作者:onti    项目:zend-module-bas   
/**
  * Set the database adapter.
  * 
  * @param AdapterInterface $adapter
  * @return AbstractMapper
  */
 public function setAdapter(AdapterInterface $adapter)
 {
     $this->adapter = $adapter;
     if ($adapter instanceof MasterSlaveAdapterInterface) {
         $this->slaveAdapter = $adapter->getSlaveAdapter();
     }
     return $this;
 }

作者:gridguy    项目:zor   
/**
  * @param   AdapterInterface            $adapter
  * @param   StatementContainerInterface $statementContainer
  * @return  void
  */
 public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
 {
     $driver = $adapter->getDriver();
     $platform = $adapter->getPlatform();
     $parameterContainer = $statementContainer->getParameterContainer();
     if (!$parameterContainer instanceof ParameterContainer) {
         $parameterContainer = new ParameterContainer();
         $statementContainer->setParameterContainer($parameterContainer);
     }
     $function = $platform->quoteIdentifierChain($this->function);
     $resultKey = $platform->quoteIdentifier($this->resultKey);
     $arguments = array();
     $i = 0;
     foreach ($this->arguments as $argument) {
         if ($argument instanceof Expression) {
             $exprData = $this->processExpression($argument, $platform, $driver);
             $arguments[] = $exprData->getSql();
             $parameterContainer->merge($exprData->getParameterContainer());
         } else {
             $parameterName = 'func_arg_' . $i++;
             $arguments[] = $driver->formatParameterName($parameterName);
             $parameterContainer->offsetSet($parameterName, $argument);
         }
     }
     $sql = sprintf($this->specifications[$this->mode], $function, implode(', ', $arguments), $resultKey);
     $statementContainer->setSql($sql);
 }

作者:brighten0    项目:zf2-openstack-ap   
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);
     }
 }

作者:pengtt011    项目:CotestWeb   
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;
 }

作者:zendframewor    项目:zend-d   
/**
  * @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();
 }


问题


面经


文章

微信
公众号

扫码关注公众号