當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。