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


PHP Sql::select方法代码示例

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


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

示例1: testSelect

 /**
  * @covers Zend\Db\Sql\Sql::select
  */
 public function testSelect()
 {
     $select = $this->sql->select();
     $this->assertInstanceOf('Zend\\Db\\Sql\\Select', $select);
     $this->assertSame('foo', $select->getRawState('table'));
     $this->setExpectedException('Zend\\Db\\Sql\\Exception\\InvalidArgumentException', 'This Sql object is intended to work with only the table "foo" provided at construction time.');
     $this->sql->select('bar');
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:11,代码来源:SqlTest.php

示例2: xhbExists

 public function xhbExists($xhbId)
 {
     try {
         $select = $this->_sql->select(Xhb::MAIN_TABLE);
         $select->columns(array('id'))->where(array('id' => $xhbId));
         $result = $this->_db->query($this->_sql->buildSqlString($select), Adapter::QUERY_MODE_EXECUTE);
     } catch (\RuntimeException $e) {
         return false;
     }
     return count($result) > 0;
 }
开发者ID:nanawel,项目名称:webhomebank,代码行数:11,代码来源:Db.php

示例3: getChiTietPhieuDoiTra

 public function getChiTietPhieuDoiTra($array_conditions = array(), $array_columns_1 = array(), $array_columns_2 = array(), $array_columns_3 = array(), $array_columns_4 = array(), $array_columns_5 = array(), $array_columns_6 = array(), $array_columns_7 = array())
 {
     /*
         chuyền vào 2 tham số:   1 tham số là mảng điều kiện, 
                                 1 tham số là mảng cột ở bảng 1 cần lấy ra,
                                 1 tham số là mảng cột ở bảng 2 cần lấy ra,
     */
     $adapter = $this->tableGateway->adapter;
     $sql = new Sql($adapter);
     // select
     $sqlSelect = $sql->select();
     $sqlSelect->from(array('t1' => 'phieu_doi_tra'));
     $sqlSelect->join(array('t2' => 'hoa_don'), 't1.id_hoa_don=t2.id_hoa_don', $array_columns_2, 'LEFT');
     $sqlSelect->join(array('t3' => 'ct_hoa_don'), 't2.id_hoa_don=t3.id_hoa_don', $array_columns_3, 'LEFT');
     $sqlSelect->join(array('t4' => 'san_pham'), 't3.id_san_pham=t4.id_san_pham', $array_columns_4, 'LEFT');
     $sqlSelect->join(array('t5' => 'khach_hang'), 't2.id_khach_hang=t5.id_khach_hang', $array_columns_5, 'LEFT');
     $sqlSelect->join(array('t6' => 'kenh_phan_phoi'), 't5.id_kenh_phan_phoi=t6.id_kenh_phan_phoi', $array_columns_6, 'LEFT');
     $sqlSelect->join(array('t7' => 'don_vi_tinh'), 't4.id_don_vi_tinh=t7.id_don_vi_tinh', $array_columns_7, 'LEFT');
     if ($array_columns_1) {
         $sqlSelect->columns($array_columns_1);
     }
     if ($array_conditions) {
         $sqlSelect->where($array_conditions);
     }
     $statement = $this->tableGateway->getSql()->prepareStatementForSqlObject($sqlSelect);
     $resultSets = $statement->execute();
     $allRow = array();
     foreach ($resultSets as $key => $resultSet) {
         $allRow[] = $resultSet;
     }
     return $allRow;
 }
开发者ID:phanvanthanh,项目名称:NhaSachMoi,代码行数:32,代码来源:PhieuDoiTraTable.php

示例4: getPerTime

 public function getPerTime($where_params = null, $is_super_admin = 0)
 {
     $obj_list = array();
     $sql = new Sql($this->adapter);
     $select = $sql->select();
     $select->from('publisherHourlyBidsBidsPerTime');
     if (!empty($where_params['DateCreatedGreater'])) {
         $select->where($select->where->greaterThanOrEqualTo('DateCreated', $where_params['DateCreatedGreater']));
     }
     if (!empty($where_params['DateCreatedLower'])) {
         $select->where($select->where->lessThanOrEqualTo('DateCreated', $where_params['DateCreatedLower']));
     }
     $statement = $sql->prepareStatementForSqlObject($select);
     $results = $statement->execute();
     foreach ($results as $obj) {
         if (!$is_super_admin) {
             array_walk($obj, function ($item, $key) use(&$obj) {
                 if (array_search($key, $this->adminFields) !== FALSE) {
                     $obj[$key] = FALSE;
                 }
             });
             $obj = array_filter($obj, function ($value) {
                 return $value !== FALSE;
             });
         }
         $obj['MDYH'] = $this->re_normalize_time($obj['MDYH']);
         $obj_list[] = $obj;
     }
     return $obj_list;
 }
开发者ID:cloudseo,项目名称:nginad,代码行数:30,代码来源:PublisherHourlyBids.php

示例5: getPhieuThuAndUserByArrayConditionAnd2ArrayColumn

 public function getPhieuThuAndUserByArrayConditionAnd2ArrayColumn($array_conditions = array(), $array_columns_1 = array(), $array_columns_2 = array())
 {
     /*
         chuyền vào 2 tham số:   1 tham số là mảng điều kiện, 
                                 1 tham số là mảng cột ở bảng 1 cần lấy ra,
                                 1 tham số là mảng cột ở bảng 2 cần lấy ra,
     */
     $adapter = $this->tableGateway->adapter;
     $sql = new Sql($adapter);
     // select
     $sqlSelect = $sql->select();
     $sqlSelect->from(array('t1' => 'phieu_thu'));
     $sqlSelect->join(array('t2' => 'user'), 't1.id_user=t2.user_id', $array_columns_2, 'LEFT');
     if ($array_columns_1) {
         $sqlSelect->columns($array_columns_1);
     }
     if ($array_conditions) {
         $sqlSelect->where($array_conditions);
     }
     $statement = $this->tableGateway->getSql()->prepareStatementForSqlObject($sqlSelect);
     $resultSets = $statement->execute();
     $allRow = array();
     foreach ($resultSets as $key => $resultSet) {
         $allRow[] = $resultSet;
     }
     return $allRow;
 }
开发者ID:phanvanthanh,项目名称:NhaSachMoi,代码行数:27,代码来源:PhieuThuTable.php

示例6: select

 /**
  *
  * @return Select
  */
 public function select()
 {
     if ($this->select === null) {
         $this->select = $this->sql->select();
     }
     return $this->select;
 }
开发者ID:robocoder,项目名称:solublecomponents,代码行数:11,代码来源:SqlSource.php

示例7: findUsersOfSite

 /**
  * {@inheritdoc}
  */
 public function findUsersOfSite($siteId, $order = null, $paginated = false)
 {
     $sql = new Sql($this->dbAdapter);
     $membershipCols = array();
     foreach (DbSelectColumns::MEMBERSHIP as $col) {
         $membershipCols[DbViewMembership::TABLE . '_' . $col] = $col;
     }
     $activityCols = array();
     foreach (DbSelectColumns::USER_ACTIVITY as $col) {
         $activityCols[DbViewUserActivity::TABLE . '_' . $col] = $col;
     }
     $userCols = array();
     foreach (DbSelectColumns::USER as $col) {
         $userCols[DbViewUsers::TABLE . '_' . $col] = $col;
     }
     $select = $sql->select()->from(array('u' => DbViewUsers::TABLE))->columns($userCols)->join(array('a' => DbViewUserActivity::TABLE), 'u.' . DbViewUsers::USERID . ' = a.' . DbViewUserActivity::USERID, $activityCols)->join(array('m' => DbViewMembership::TABLE), 'm.' . DbViewMembership::USERID . ' = u.' . DbViewUsers::USERID . ' AND m.' . DbViewMembership::SITEID . ' = a.' . DbViewUserActivity::SITEID, $membershipCols, Select::JOIN_LEFT)->where(array('a.' . DbViewUserActivity::SITEID . ' = ?' => $siteId, '(m.' . DbViewMembership::JOINDATE . ' IS NOT NULL OR (a.' . DbViewUserActivity::VOTES . ' > 0) OR (a.' . DbViewUserActivity::REVISIONS . ' > 0) or (a.' . DbViewUserActivity::PAGES . ' > 0))'));
     if (is_array($order)) {
         $this->orderSelect($select, $order);
     }
     $resultSet = new \Zend\Db\ResultSet\HydratingResultSet($this->userSiteHydrator, $this->objectPrototype);
     if ($paginated) {
         $adapter = new \Zend\Paginator\Adapter\DbSelect($select, $this->dbAdapter, $resultSet);
         return new \Zend\Paginator\Paginator($adapter);
     }
     return $resultSet->initialize($this->fetch($sql, $select));
 }
开发者ID:FiftyNine,项目名称:ScpperDB,代码行数:29,代码来源:UserDbSqlMapper.php

示例8: getUserByArrayConditionAndArrayColumn

 public function getUserByArrayConditionAndArrayColumn($array_conditions = array(), $array_columns = array())
 {
     /*
         chuyền vào 2 tham số:   1 tham số là mảng điều kiện, 
                                 1 tham số là mảng cột cần lấy ra
     */
     $adapter = $this->tableGateway->adapter;
     $sql = new Sql($adapter);
     // select
     $sqlSelect = $sql->select();
     $sqlSelect->from(array('t1' => 'user'));
     if ($array_columns) {
         $sqlSelect->columns($array_columns);
     }
     if ($array_conditions) {
         $sqlSelect->where($array_conditions);
     }
     $statement = $this->tableGateway->getSql()->prepareStatementForSqlObject($sqlSelect);
     $resultSets = $statement->execute();
     $allRow = array();
     foreach ($resultSets as $key => $resultSet) {
         $allRow[] = $resultSet;
     }
     return $allRow;
 }
开发者ID:phanvanthanh,项目名称:NhaSachMoi,代码行数:25,代码来源:UserTable.php

示例9: getUserRoles

 public function getUserRoles($where = array(), $columns = array(), $orderBy = '', $paging = false)
 {
     try {
         $sql = new Sql($this->getAdapter());
         $select = $sql->select()->from(array('sa' => $this->table));
         if (count($where) > 0) {
             $select->where($where);
         }
         $select->where($where);
         if (count($columns) > 0) {
             $select->columns($columns);
         }
         if (!empty($orderBy)) {
             $select->order($orderBy);
         }
         if ($paging) {
             $dbAdapter = new DbSelect($select, $this->getAdapter());
             $paginator = new Paginator($dbAdapter);
             return $paginator;
         } else {
             $statement = $sql->prepareStatementForSqlObject($select);
             $clients = $this->resultSetPrototype->initialize($statement->execute())->toArray();
             return $clients;
         }
     } catch (\Exception $e) {
         throw new \Exception($e->getPrevious()->getMessage());
     }
 }
开发者ID:ChristianKolling,项目名称:projeto-frotas,代码行数:28,代码来源:UserRole.php

示例10: getCertificateUserAndCertificateByArrayConditionAndArrayColumns

 public function getCertificateUserAndCertificateByArrayConditionAndArrayColumns($array_conditions = array(), $array_columns_1 = array(), $array_columns_2 = array())
 {
     /*
         chuyền vào 3 tham số:   1 tham số là mảng điều kiện, 
                                 1 tham số là mảng cột bảng thứ nhất cần lấy ra,
                                 1 tham số là cột bảng thứ 2 cần lấy
     */
     $adapter = $this->tableGateway->adapter;
     $sql = new Sql($adapter);
     // select
     $sqlSelect = $sql->select();
     $sqlSelect->from(array('t1' => 'jos_certificate_user'));
     $sqlSelect->join(array('t2' => 'jos_certificate'), 't1.certificate_id=t2.value_id', $array_columns_2, 'LEFT');
     if ($array_columns_1) {
         $sqlSelect->columns($array_columns_1);
     }
     if ($array_conditions) {
         $sqlSelect->where($array_conditions);
     }
     $statement = $this->tableGateway->getSql()->prepareStatementForSqlObject($sqlSelect);
     $resultSets = $statement->execute();
     $allRow = array();
     foreach ($resultSets as $key => $resultSet) {
         $allRow[] = $resultSet;
     }
     return $allRow;
 }
开发者ID:phanvanthanh,项目名称:LyLichKhoaHocTablegateway,代码行数:27,代码来源:JosCertificateUserTable.php

示例11: getConcertsByFilter

 public function getConcertsByFilter($params)
 {
     $adapter = $this->tableGateway->getAdapter();
     $sql = new Sql($adapter);
     $select = $sql->select();
     $select->from(array('c' => 'concerts'), array('place', 'address', 'city', 'date_concert', 'cost', 'id_artist'))->join(array('a' => 'artists'), 'c.id_artist = a.id', array('name', 'image', 'tags'));
     // join table with alias
     if (count($params) == 5) {
         $select->where(array('city' => $params['city'], 'tags' => $params['tags'], 'cost' => $params['cost']))->where->between('date_concert', $params['date_start'], $params['date_end']);
         $statement = $sql->prepareStatementForSqlObject($select);
         $results = $statement->execute();
         return $results->current();
     } else {
         foreach ($params as $key => $value) {
             if ($key == 'date_start') {
                 $select->where('date_concert >= ' . $value);
             } elseif ($key == 'date_end') {
                 $select->where('date_concert <= ' . $value);
             } else {
                 $select->where(array($key => $value));
             }
         }
         $statement = $sql->prepareStatementForSqlObject($select);
         $results = $statement->execute();
         return $results;
     }
 }
开发者ID:makhloufi-lounis,项目名称:management-concerts,代码行数:27,代码来源:ConcertTable.php

示例12: findAll

 /**
  * @return array|PostInterface[]
  */
 public function findAll()
 {
     $sql = new Sql($this->dbAdapter);
     $select = $sql->select('posts');
     $stmt = $sql->prepareStatementForSqlObject($select);
     $result = $stmt->execute();
     //return $result;
     //\Zend\Debug\Debug::dump($result);die(); // 141
     //TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
     /*
     if ($result instanceof ResultInterface && $result->isQueryResult()) {
       $resultSet = new ResultSet();
     
       \Zend\Debug\Debug::dump($resultSet->initialize($result)); // 142
       die();
     }
     
     die("no data");
     */
     //LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
     if ($result instanceof ResultInterface && $result->isQueryResult()) {
         // 143
         $resultSet = new HydratingResultSet($this->hydrator, $this->postPrototype);
         return $resultSet->initialize($result);
         // 144
     }
     return array();
     // 145
 }
开发者ID:Rud5G,项目名称:zf2-tutorial,代码行数:32,代码来源:ZendDbSqlMapper.php

示例13: login

 function login($data, $adapter)
 {
     $sql = new Sql($adapter);
     $select = $sql->select()->from('users')->where(array('email' => $data['email'], 'password' => md5($data['password'])))->limit(1);
     $result = $adapter->query($sql->buildSqlString($select), $adapter::QUERY_MODE_EXECUTE);
     return $result;
 }
开发者ID:BBFramework,项目名称:zend_start,代码行数:7,代码来源:UserTable.php

示例14: getFollowers

 public function getFollowers($profileID)
 {
     $sql = new Sql($this->tableGateway->adapter);
     $select = $sql->select()->from('follows')->where(array('id_user' => $profileID))->join('users', 'users.id = follows.id_follower');
     $statement = $this->tableGateway->getSql()->prepareStatementForSqlObject($select);
     $resultSet = $statement->execute();
     return $resultSet;
 }
开发者ID:anton-phpcurs,项目名称:aperture,代码行数:8,代码来源:FollowsTable.php

示例15: getUser

 /**
  * This function returns the user by ID
  * @param int $userId
  * @return array
  */
 public function getUser($userId)
 {
     $sql = new Sql($this->tableGateway->getAdapter());
     $select = $sql->select()->from(array('u' => 'user'))->join(array('r' => 'role'), 'r.id = u.role_id', array('*'))->where(array('u.id' => $userId))->order('u.id');
     $stmt = $sql->prepareStatementForSqlObject($select);
     $results = $stmt->execute();
     return $results;
 }
开发者ID:rhionair3,项目名称:myzend,代码行数:13,代码来源:UserTable.php


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