当前位置: 首页>>代码示例>>PHP>>正文


PHP Adapter::query方法代码示例

本文整理汇总了PHP中Zend\Db\Adapter\Adapter::query方法的典型用法代码示例。如果您正苦于以下问题:PHP Adapter::query方法的具体用法?PHP Adapter::query怎么用?PHP Adapter::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Db\Adapter\Adapter的用法示例。


在下文中一共展示了Adapter::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: find

 public function find($params)
 {
     $sql = new Sql($this->getAdapter());
     $select = new Select();
     $select->from($params['from']);
     if (!empty($params['columns'])) {
         $select->columns($params['columns']);
     }
     foreach ($params['where'] as $where) {
         $select->where($where);
     }
     foreach ($params['joins'] as $join) {
         if (empty($join['columns'])) {
             $join['columns'] = Select::SQL_STAR;
         }
         if (empty($join['type'])) {
             $join['type'] = Select::JOIN_INNER;
         }
         $select->join($join['name'], $join['on'], $join['columns'], $join['type']);
     }
     $query = $sql->getSqlStringForSqlObject($select);
     $results = $this->adapter->query($query, Adapter::QUERY_MODE_EXECUTE);
     $data = $results->toArray();
     if (empty($data)) {
         return false;
     } else {
         if (count($data) == 1) {
             return $data[0];
         } else {
             return $data;
         }
     }
 }
开发者ID:baptistecosta,项目名称:mon-partenaire,代码行数:33,代码来源:AbstractMapper.php

示例2: onDispatch

 public function onDispatch(MvcEvent $e)
 {
     if (!$e->getRequest() instanceof ConsoleRequest) {
         throw new RuntimeException('You can only use this action from a console!');
     }
     $table = new Ddl\CreateTable('queue_messages');
     $table->addColumn(new Ddl\Column\Integer('id', false, null, ['autoincrement' => true]));
     $table->addColumn(new Ddl\Column\Varchar('queue_name', 100));
     $table->addColumn(new Ddl\Column\Integer('status', false));
     $table->addColumn(new Ddl\Column\Varchar('options', 250));
     $table->addColumn(new Ddl\Column\Text('message', null, true));
     $table->addColumn(new Ddl\Column\Text('output', null, true));
     $table->addColumn(new Ddl\Column\Datetime('started_dt', true));
     $table->addColumn(new Ddl\Column\Datetime('finished_dt', true));
     $table->addColumn(new Ddl\Column\Datetime('created_dt', false));
     $table->addColumn(new Ddl\Column\Datetime('updated_dt', true));
     $table->addConstraint(new Ddl\Constraint\PrimaryKey('id'));
     $sql = new Sql($this->dbAdapter);
     try {
         $this->dbAdapter->query($sql->buildSqlString($table), DbAdapter::QUERY_MODE_EXECUTE);
     } catch (\Exception $e) {
         // currently there are no db-independent way to check if table exists
         // so we assume that table exists when we catch exception
     }
 }
开发者ID:t4web,项目名称:queue,代码行数:25,代码来源:Init.php

示例3: create

 private function create(SqlInterface $table)
 {
     try {
         $sql = new Sql($this->dbAdapter);
         $this->dbAdapter->query($sql->buildSqlString($table), Adapter::QUERY_MODE_EXECUTE);
     } catch (PDOException $e) {
         $message = $e->getMessage() . PHP_EOL;
     }
 }
开发者ID:robaks,项目名称:Locations,代码行数:9,代码来源:InitController.php

示例4: executeQuery

 public function executeQuery($sql)
 {
     if (!$this->dbAdapter) {
         /** @var Adapter dbAdapter */
         $this->dbAdapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
     }
     /** @var ResultSet $photos */
     return $this->dbAdapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
 }
开发者ID:t4web,项目名称:migrations,代码行数:9,代码来源:AbstractMigration.php

示例5: insert

 /**
  * 
  * @param string $tableName
  * @param array $data
  * @return bool
  */
 public function insert($tableName, array $data)
 {
     $sql = new Sql($this->adapter);
     $insert = $sql->insert($tableName);
     $insert->values($data);
     $sqlString = $sql->getSqlStringForSqlObject($insert);
     $results = $this->adapter->query($sqlString, Adapter::QUERY_MODE_EXECUTE);
     return $results;
 }
开发者ID:KIVagant,项目名称:console-tools,代码行数:15,代码来源:Fixture.php

示例6: loadConfig

 /**
  * Load config from db-adapter
  *
  * @param \Zend\Db\Adapter\Adapter $db
  * @return array
  */
 protected function loadConfig()
 {
     if (empty($this->dbAdapter)) {
         return $this->config;
     }
     $platform = $this->dbAdapter->getPlatform();
     $driver = $this->dbAdapter->getDriver();
     $query = $this->dbAdapter->query('
         SELECT ' . $platform->quoteIdentifier('value') . '
           FROM ' . $platform->quoteIdentifier('settings') . '
          WHERE ' . $platform->quoteIdentifier('key') . '
              = ' . $platform->quoteValue('ini-cache') . '
            AND ' . $platform->quoteIdentifier('type') . '
              = ' . $platform->quoteValue('ini-cache') . '
          LIMIT 1
     ');
     $this->config = array();
     $result = $query->execute();
     if ($result->getAffectedRows() > 0) {
         foreach ($result as $cache) {
             $this->config = ArrayUtils::merge($this->config, (array) unserialize($cache['value']));
         }
     } else {
         $query = $this->dbAdapter->query('
             SELECT ' . $platform->quoteIdentifier('key') . ',
                    ' . $platform->quoteIdentifier('value') . '
               FROM ' . $platform->quoteIdentifier('settings') . '
              WHERE ' . $platform->quoteIdentifier('type') . '
                  = ' . $platform->quoteValue('ini') . '
         ');
         foreach ($query->execute() as $pair) {
             $key = (string) $pair['key'];
             $value = (string) $pair['value'];
             $entry = array();
             $curr =& $entry;
             foreach (explode('.', $key) as $sub) {
                 $curr[$sub] = null;
                 $curr =& $curr[$sub];
             }
             $curr = $value;
             $this->config = ArrayUtils::merge($this->config, $entry);
         }
         $query = $this->dbAdapter->query('
             INSERT INTO ' . $platform->quoteIdentifier('settings') . '
                         ( ' . $platform->quoteIdentifier('key') . ',
                           ' . $platform->quoteIdentifier('value') . ',
                           ' . $platform->quoteIdentifier('type') . ' )
                  VALUES ( ' . $driver->formatParameterName('key') . ',
                           ' . $driver->formatParameterName('value') . ',
                           ' . $driver->formatParameterName('type') . ' )
         ');
         $query->execute(array('key' => 'ini-cache', 'value' => serialize($this->config), 'type' => 'ini-cache'));
     }
     $this->dbAdapter = null;
     return $this->config;
 }
开发者ID:gridguyz,项目名称:zork,代码行数:62,代码来源:LoaderListener.php

示例7: save

 public function save(Queue $queue)
 {
     if ($queue->getId()) {
         $query = $this->dbAdapter->query('UPDATE `queues` SET `name` = :name WHERE `id = :id`');
         $query->execute($queue->getArrayCopy());
     } else {
         $query = $this->dbAdapter->query("INSERT INTO `queues` (`name`) VALUES (:name)");
         $query->execute(['name' => $queue->getName()]);
         $queue->setId($this->dbAdapter->getDriver()->getLastGeneratedValue());
     }
     return $queue;
 }
开发者ID:dragonmantank,项目名称:dockerfordevs-app,代码行数:12,代码来源:QueueService.php

示例8: clear

 /**
  * Clear datas with $uid key
  * @param mixed $uid
  * @return void
  */
 public function clear($uid = null)
 {
     $options = $this->getOptions();
     if ($uid) {
         if (!$this->has($uid)) {
             return false;
         }
         $stmt = $this->adapter->query(sprintf('DELETE FROM %s WHERE %s = "%s"', $options['table'], $options['column_key'], $uid), Adapter::QUERY_MODE_EXECUTE);
         return true;
     }
     $stmt = $this->adapter->query(sprintf('TRUNCATE TABLE %s', $options['table']), Adapter::QUERY_MODE_EXECUTE);
     return true;
 }
开发者ID:cityware,项目名称:city-shared-memory,代码行数:18,代码来源:Db.php

示例9: createTable

 private function createTable($query)
 {
     try {
         $this->dbAdapter->query($query, DbAdapter::QUERY_MODE_EXECUTE);
     } catch (\PDOException $e) {
         if (strpos($e->getMessage(), 'table or view already exists') === false) {
             echo $e->getMessage() . PHP_EOL;
             exit(1);
         }
     } catch (\Exception $e) {
         echo $e->getMessage() . PHP_EOL;
         exit(1);
     }
 }
开发者ID:t4web,项目名称:mail,代码行数:14,代码来源:InitController.php

示例10: save

 public function save(User $user)
 {
     //select
     $sql1 = 'select max(userID) from user';
     $statement = $this->dbAdapter->query($sql1);
     $result = $statement->execute();
     $row = $result->current();
     //         Debug::dump($row  );
     $user->setUserID($row['max(userID)'] + 1);
     //insert
     $defaultfaceimgpath = '/data/face/defaultfaceimg.png';
     $sql = 'insert into user(userID,username,upassword,schoolID,faceimgpath) values(' . $user->getUserID() . ',"' . $user->getUsername() . '","' . $user->getUpassword() . '","' . $user->getSchoolID() . '","' . $defaultfaceimgpath . '")';
     //         echo $sql;
     $this->dbAdapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
 }
开发者ID:summerandelf,项目名称:CotestWeb_,代码行数:15,代码来源:UserService.php

示例11: authenticate

 /**
  * Autenticates the user
  * @return \Zend\Authentication\Result
  */
 public function authenticate()
 {
     extract($this->db->query('
   SELECT COUNT(`username`) as isAuthenticated FROM `login` WHERE 
   (SELECT `active` FROM `profile` WHERE `login`.`profile_id`=`profile`.`id`) = 1 AND
   `username`="' . addslashes($this->username) . '" AND
   `password`="' . addslashes(md5($this->password)) . '"
   ', \Zend\Db\Adapter\Adapter::QUERY_MODE_EXECUTE)->current()->getArrayCopy());
     if ($isAuthenticated > 0) {
         $code = \Zend\Authentication\Result::SUCCESS;
     } else {
         $code = \Zend\Authentication\Result::FAILURE;
     }
     return new \Zend\Authentication\Result($code, $_REQUEST['username']);
 }
开发者ID:caiofior,项目名称:cercaziende,代码行数:19,代码来源:Auth.php

示例12: dropTable

 /**
  * Drops the database table for session data
  *
  * @return void
  */
 protected function dropTable()
 {
     if (!$this->adapter) {
         return;
     }
     $this->adapter->query('DROP TABLE sessions', Adapter::QUERY_MODE_EXECUTE);
 }
开发者ID:benivaldo,项目名称:zf2-na-pratica,代码行数:12,代码来源:DbTableGatewayTest.php

示例13: query

 public function query($sql, $parametersOrQueryMode = self::QUERY_MODE_PREPARE)
 {
     $this->getProfiler()->startQuery($sql);
     $return = parent::query($sql, $parametersOrQueryMode);
     $this->getProfiler()->endQuery();
     return $return;
 }
开发者ID:phox,项目名称:xsale,代码行数:7,代码来源:ProfilingAdapter.php

示例14: query

 public function query($sql, $parametersOrQueryMode = self::QUERY_MODE_PREPARE, ResultSet\ResultSetInterface $resultPrototype = null)
 {
     $this->getProfiler()->startQuery($sql);
     $return = parent::query($sql, $parametersOrQueryMode, $resultPrototype);
     $this->getProfiler()->endQuery();
     return $return;
 }
开发者ID:gstearmit,项目名称:EshopVegeTable,代码行数:7,代码来源:ProfilingAdapter.php

示例15: createTableLanguages

 private function createTableLanguages()
 {
     $table = new Ddl\CreateTable('languages');
     $id = new Column\Integer('id');
     $id->setOption('autoincrement', true);
     $table->addColumn($id);
     $table->addColumn(new Column\Varchar('code', 2));
     $table->addColumn(new Column\Varchar('locale', 6));
     $table->addColumn(new Column\Varchar('name', 50));
     $table->addColumn(new Column\Integer('default', false, 0));
     $table->addConstraint(new Constraint\PrimaryKey('id'));
     $table->addConstraint(new Constraint\UniqueKey('code'));
     $table->addConstraint(new Constraint\UniqueKey('locale'));
     $sql = new Sql($this->dbAdapter);
     $this->dbAdapter->query($sql->buildSqlString($table), Adapter::QUERY_MODE_EXECUTE);
 }
开发者ID:sebaks,项目名称:Translate,代码行数:16,代码来源:InitController.php


注:本文中的Zend\Db\Adapter\Adapter::query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。