public function search($str)
 {
     $select = new Select('video');
     $spec = new Where();
     $spec->like('title', '% ' . $str . ' %');
     $select->where($spec);
     $select->where->OR->like('title', $str . ' %');
     $select->where->OR->like('title', '% ' . $str);
     //$select->where(array('title'=>$str));
     //$select->where(array('catelog'=>$title,'description'=>$description));
     $select->order('id ASC');
     /*
                  // create a new result set based on the Album entity
                  $resultSetPrototype = new ResultSet();
                  $resultSetPrototype->setArrayObjectPrototype(new Search());
                  // create a new pagination adapter object
                  $paginatorAdapter = new DbSelect(
                      // our configured select object
                      $select,
                      // the adapter to run it against
                      $this->tableGateway->getAdapter(),
                      // the result set to hydrate
                      $resultSetPrototype
                  );
                  $paginator = new Paginator($paginatorAdapter);
                 
                  return $paginator;
     */
     return $this->tableGateway->selectWith($select);
 }
Exemple #2
0
 public function setUp()
 {
     $this->column = $this->getMockBuilder('ZfcDatagrid\\Column\\Select')->disableOriginalConstructor()->getMock();
     $this->column->method('getSelectPart1')->willReturn('myCol');
     $this->column->method('getType')->willReturn(new \ZfcDatagrid\Column\Type\PhpString());
     $this->column->setUniqueId('myCol');
     $this->column->setSelect('myCol');
     $this->column2 = $this->getMockBuilder('ZfcDatagrid\\Column\\Select')->disableOriginalConstructor()->getMock();
     $this->column2->method('getSelectPart1')->willReturn('myCol2');
     $this->column2->method('getType')->willReturn(new \ZfcDatagrid\Column\Type\PhpString());
     $this->column2->setUniqueId('myCol2');
     $this->column2->setSelect('myCol2');
     $this->mockDriver = $this->getMock('Zend\\Db\\Adapter\\Driver\\DriverInterface');
     $this->mockConnection = $this->getMock('Zend\\Db\\Adapter\\Driver\\ConnectionInterface');
     $this->mockDriver->expects($this->any())->method('checkEnvironment')->will($this->returnValue(true));
     $this->mockDriver->expects($this->any())->method('getConnection')->will($this->returnValue($this->mockConnection));
     $this->mockPlatform = $this->getMock('Zend\\Db\\Adapter\\Platform\\PlatformInterface');
     $this->mockStatement = $this->getMock('Zend\\Db\\Adapter\\Driver\\StatementInterface');
     $this->mockDriver->expects($this->any())->method('createStatement')->will($this->returnValue($this->mockStatement));
     $this->adapter = new Adapter($this->mockDriver, $this->mockPlatform);
     $sql = new Sql($this->adapter, 'foo');
     $select = new Select('myTable');
     $select->columns(['myCol', 'myCol2']);
     $this->filterSelect = new FilterSelect($sql, $select);
 }
 /**
  * Sets the filter
  * @param \Zend\Db\Sql\Select $select
  * @param array $criteria
  * @return \Zend\Db\Sql\Select
  */
 private function setFilter($select, $criteria)
 {
     if (array_key_exists('profile_id', $criteria) && $criteria['profile_id'] != '') {
         $select->where('`profile_id` = ' . intval($criteria['profile_id']));
     }
     return $select;
 }
 public function fetchActive()
 {
     $select = new Select($this->getTable());
     $select->where->equalTo('active', 1);
     $select->order('id desc');
     return $this->selectWith($select)->toArray();
 }
 public function getUsersAndAbove(bool $paginated, $name = '', $roles = [])
 {
     $select = new Select('account');
     $where = new Where();
     if ($roles) {
         $sub = $where->nest();
         for ($i = 0; $i < count($roles); $i++) {
             $sub->equalTo('role', $roles[$i]);
             if ($i < count($roles) - 1) {
                 $sub->or;
             }
         }
         $sub->unnest();
     } else {
         $where->greaterThan('role', '0');
         $where->lessThan('role', '32');
     }
     if ($name) {
         $where->like('name', '%' . $name . '%');
     }
     $select->where($where)->order('name ASC');
     if ($paginated) {
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Account());
         $paginatorAdapter = new DbSelect($select, $this->tableGateway->getAdapter(), $resultSetPrototype);
         return new Paginator($paginatorAdapter);
     }
     return $this->tableGateway->select($select);
 }
 public function fetchByIdCategoryWithLimit($idCategory, $limit)
 {
     $select = new Select();
     $select->from('post')->where('id_category = ' . (int) $idCategory)->limit((int) $limit);
     $resultSet = $this->tableGateway->select($select);
     return $resultSet;
 }
Exemple #7
0
 /**
  *
  * @param \Zend\Db\Sql\Select $query
  */
 protected function initFilters($query)
 {
     $value = $this->getParamAdapter()->getValueOfFilter('idItem');
     if ($value != null) {
         $query->where("idItem = '" . $value . "' ");
     }
     $value = $this->getParamAdapter()->getValueOfFilter('nom');
     if ($value != null) {
         $query->where("nom like '%" . $value . "%' ");
     }
     $value = $this->getParamAdapter()->getValueOfFilter('ajouterPar');
     if ($value != null) {
         $query->where("ajouterPar like '%" . $value . "%' ");
     }
     $value = $this->getParamAdapter()->getValueOfFilter('majPar');
     if ($value != null) {
         $query->where("majPar like '%" . $value . "%' ");
     }
     $value = $this->getParamAdapter()->getValueOfFilter('idItemJeu');
     if ($value != null) {
         $query->where("idIBnet like '%" . $value . "%' ");
     }
     $value = $this->getParamAdapter()->getValueOfFilter('couleur');
     if ($value != null) {
         $query->where("couleur like '%" . $value . "%' ");
     }
 }
 public function getByProduct($product)
 {
     $select = new Select($this->tableGateway->getTable());
     $select->where(array("product" => $product));
     $rows = $this->tableGateway->selectWith($select);
     return $rows ? $rows : false;
 }
Exemple #9
0
 /**
  * {@inheritDoc}
  */
 public function getRoles()
 {
     /* @var $tableGateway \Zend\Db\TableGateway\TableGateway */
     $tableGateway = $this->serviceLocator->get('BjyAuthorize\\Service\\RoleDbTableGateway');
     $sql = new Select();
     $sql->from($this->tableName);
     /* @var $roles Role[] */
     $roles = array();
     $indexedRows = array();
     $rowset = $tableGateway->selectWith($sql);
     // Pass 1: collect all rows and index them by PK
     foreach ($rowset as $row) {
         $indexedRows[$row[$this->identifierFieldName]] = $row;
     }
     // Pass 2: build a role for each indexed row
     foreach ($indexedRows as $row) {
         $parentRoleId = isset($row[$this->parentRoleFieldName]) ? $indexedRows[$row[$this->parentRoleFieldName]][$this->roleIdFieldName] : null;
         $roleId = $row[$this->roleIdFieldName];
         $roles[$roleId] = new Role($roleId, $parentRoleId);
     }
     // Pass 3: Re-inject parent objects to preserve hierarchy
     foreach ($roles as $role) {
         $parentRoleObj = $role->getParent();
         if ($parentRoleObj && ($parentRoleId = $parentRoleObj->getRoleId())) {
             $role->setParent($roles[$parentRoleId]);
         }
     }
     return array_values($roles);
 }
Exemple #10
0
 public function fetchAll($paginated = false, $sort = 'name', $order = 'ASC')
 {
     switch ($sort) {
         case "id":
             $sort = "C_Id";
             break;
         case "name":
             $sort = "C_Name";
             break;
         case "lastinvoice":
             $sort = "C_LastInvoice";
             break;
         default:
             $sort = "C_Name";
     }
     $select = new Select();
     $select->from($this->table);
     $subquery = "(SELECT I_BaseDate FROM Invoice WHERE Invoice.I_ClientId = Client.C_Id ORDER BY I_Id DESC LIMIT 1)";
     $select->columns(array('C_Id' => 'C_Id', 'C_Name' => 'C_Name', 'C_PaymentTerms' => 'C_PaymentTerms', 'C_Reference' => 'C_Reference', 'C_CRN' => 'C_CRN', 'C_Class' => 'C_Class', 'C_Updated' => 'C_Updated', 'C_LastInvoice' => new Expression($subquery)))->order($sort . ' ' . $order);
     if ($paginated) {
         return new Paginator(new DbSelect($select, $this->adapter, $this->resultSetPrototype));
     }
     $resultSet = $this->select($select);
     return $resultSet;
 }
 public function fetchAll($paginate = true, $usertype = 8)
 {
     if ($paginate) {
         switch ($usertype) {
             case 3:
                 $select = new Select('users');
                 $select->join('lookup_status', 'lookup_status.status_id = users.status_id', array('status'), 'left');
                 $select->join('user_feature_setting', 'user_feature_setting.user_id = users.id', array(), 'left');
                 $select->where('users.user_type_id = 3 and user_feature_setting.newsletter in (1,4)');
                 break;
             case 4:
                 $select = new Select('users');
                 $select->join('lookup_status', 'lookup_status.status_id = users.status_id', array('status'), 'left');
                 $select->join('user_feature_setting', 'user_feature_setting.user_id = users.id', array(), 'left');
                 $select->where('users.user_type_id = 4 and user_feature_setting.newsletter in (1,4)');
                 break;
             case 8:
                 $select = new Select('newsletter_subscription');
                 $select->join('lookup_status', 'lookup_status.status_id = newsletter_subscription.status_id', array('status'), 'left');
                 break;
             default:
                 $select = new Select('newsletter_subscription');
                 $select->join('lookup_status', 'lookup_status.status_id = newsletter_subscription.status_id', array('status'), 'left');
                 break;
         }
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new NewsletterSubscribers());
         $paginatorAdapter = new DbSelect($select, $this->tableGateway->getAdapter(), $resultSetPrototype);
         $paginator = new Paginator($paginatorAdapter);
         return $paginator;
     }
     return $this->tableGateway->select();
 }
Exemple #12
0
 function fetchAll($beginning, $limit)
 {
     $select = new Select($this->tableGateway->getTable());
     $select->limit($limit)->offset($beginning);
     $rowSet = $this->tableGateway->selectWith($select);
     return $rowSet;
 }
Exemple #13
0
 public function fetchByIdCategoryWithLimit($idCategory, $limit = 10, $nbDays = 30)
 {
     $select = new Select($this->tableGateway->getTable());
     $select->where("id_category = {$idCategory}")->where("created_at >= '" . date('Y-m-d H:i:s', time() - 86400 * $nbDays) . "'")->limit($limit);
     $resultset = $this->tableGateway->selectWith($select);
     return $resultset->toArray();
 }
 /**
  * Méthode get : récupère un ou plusieurs pays
  * 
  * @param string $code
  * @return array
  * @throws \Exception
  */
 public function getPays($code = "", $returnObject = false)
 {
     $select = new Select();
     $where = null;
     $result = [];
     try {
         $select->from('pays');
         if ($code) {
             $where = $this->constructWhereFromCode($code);
             $select->where($where);
         }
         $rowset = $this->tableGateway->selectWith($select);
         if ($rowset->count() > 1) {
             for ($i = 0; ($row = $rowset->current()) && $i < 30; $rowset->next(), $i++) {
                 $result[] = $row->toArray();
             }
         } else {
             if ($rowset->count() > 0) {
                 if ($returnObject) {
                     $result[] = $rowset->current();
                 } else {
                     $result[] = $rowset->current()->toArray();
                 }
             }
         }
         if (empty($result)) {
             throw new \Exception("Nous n'avons pas trouve le pays possedant ce code, alpha2 ou alpha3 egal  {$code}");
         }
     } catch (\Exception $e) {
         $result['error'] = $e->getMessage();
     }
     return $result;
 }
Exemple #15
0
 /**
  *
  * @param \Zend\Db\Sql\Select $query
  */
 protected function initFilters($query)
 {
     $value = $this->getParamAdapter()->getValueOfFilter('idGuildes');
     if ($value != null) {
         $query->where("idGuildes = '" . $value . "' ");
     }
     $value = $this->getParamAdapter()->getValueOfFilter('nom');
     if ($value != null) {
         $query->where("nom like '%" . $value . "%' ");
     }
     $value = $this->getParamAdapter()->getValueOfFilter('serveur');
     if ($value != null) {
         $query->where("serveur like '%" . $value . "%' ");
     }
     $value = $this->getParamAdapter()->getValueOfFilter('niveau');
     if ($value != null) {
         $query->where("niveau like '%" . $value . "%' ");
     }
     $value = $this->getParamAdapter()->getValueOfFilter('miniature');
     if ($value != null) {
         $query->where("miniature like '%" . $value . "%' ");
     }
     $value = $this->getParamAdapter()->getValueOfFilter('idFaction');
     if ($value != null) {
         $query->where("idFaction = '" . $value . "' ");
     }
 }
 /**
  * index Action
  * Receive the search params
  * Build the search query
  * Generate the search result as a list
  * @return type
  * Author: Tahmina Khatoon
  */
 public function indexAction()
 {
     $searchform = new UserRolesSearchForm();
     $searchform->get('submit')->setValue('Search');
     $select = new Select();
     $order_by = $this->params()->fromRoute('order_by') ? $this->params()->fromRoute('order_by') : 'id';
     $order = $this->params()->fromRoute('order') ? $this->params()->fromRoute('order') : Select::ORDER_DESCENDING;
     $page = $this->params()->fromRoute('page') ? (int) $this->params()->fromRoute('page') : 1;
     $item_per_page = $this->params()->fromRoute('item_per_page') ? (int) $this->params()->fromRoute('item_per_page') : 10;
     $page_range = $this->params()->fromRoute('page_range') ? (int) $this->params()->fromRoute('page_range') : 7;
     $select->order($order_by . ' ' . $order);
     $search_by = $this->params()->fromRoute('search_by') ? $this->params()->fromRoute('search_by') : '';
     $where = new \Zend\Db\Sql\Where();
     $formdata = array();
     if (!empty($search_by)) {
         $formdata = (array) json_decode($search_by);
         if (!empty($formdata['user_id'])) {
             $where->addPredicate(new \Zend\Db\Sql\Predicate\Like('user_id', '%' . $formdata['user_id'] . '%'));
         }
         if (!empty($formdata['role_id'])) {
             $where->addPredicate(new \Zend\Db\Sql\Predicate\Like('role_id', '%' . $formdata['role_id'] . '%'));
         }
     }
     if (!empty($where)) {
         $select->where($where);
     }
     $paginator = $this->getUserRolesTable()->fetchAll($select, true);
     $paginator->setCurrentPageNumber($page)->setItemCountPerPage($item_per_page)->setPageRange($page_range);
     $totalRecord = $paginator->getTotalItemCount();
     $currentPage = $paginator->getCurrentPageNumber();
     $totalPage = $paginator->count();
     $searchform->setData($formdata);
     $this->vm->setVariables(array('flashMessages' => $this->flashMessenger()->getMessages(), 'search_by' => $search_by, 'order_by' => $order_by, 'order' => $order, 'page' => $page, 'item_per_page' => $item_per_page, 'paginator' => $paginator, 'pageAction' => 'user_roles/index', 'form' => $searchform, 'totalRecord' => $totalRecord, 'currentPage' => $currentPage, 'totalPage' => $totalPage));
     return $this->vm;
 }
Exemple #17
0
 public function getBlogList()
 {
     $select = new Select();
     $select->from($this->table);
     $select->order('date DESC');
     return new \Zend\Paginator\Paginator(new \Zend\Paginator\Adapter\DbSelect($select, $this->adapter, $this->resultSetPrototype));
 }
 public function dataProvider()
 {
     $select0 = new Select();
     $select0->from('foo')->columns(array('bar', 'baz'))->order('bar')->limit(5)->offset(10);
     $expectedPrepareSql0 = 'SELECT [bar], [baz] FROM ( SELECT [foo].[bar] AS [bar], [foo].[baz] AS [baz], ROW_NUMBER() OVER (ORDER BY [bar] ASC) AS [__ZEND_ROW_NUMBER] FROM [foo] ) AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN ?+1 AND ?+?';
     $expectedParams0 = array('offset' => 10, 'limit' => 5, 'offsetForSum' => 10);
     $expectedSql0 = 'SELECT [bar], [baz] FROM ( SELECT [foo].[bar] AS [bar], [foo].[baz] AS [baz], ROW_NUMBER() OVER (ORDER BY [bar] ASC) AS [__ZEND_ROW_NUMBER] FROM [foo] ) AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN 10+1 AND 5+10';
     $expectedFormatParamCount0 = 3;
     $select1 = new Select();
     $select1->from('foo')->columns(array('bar', 'bam' => 'baz'))->limit(5)->offset(10);
     $expectedPrepareSql1 = 'SELECT [bar], [bam] FROM ( SELECT [foo].[bar] AS [bar], [foo].[baz] AS [bam], ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS [__ZEND_ROW_NUMBER] FROM [foo] ) AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN ?+1 AND ?+?';
     $expectedParams1 = array('offset' => 10, 'limit' => 5, 'offsetForSum' => 10);
     $expectedSql1 = 'SELECT [bar], [bam] FROM ( SELECT [foo].[bar] AS [bar], [foo].[baz] AS [bam], ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS [__ZEND_ROW_NUMBER] FROM [foo] ) AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN 10+1 AND 5+10';
     $expectedFormatParamCount1 = 3;
     $select2 = new Select();
     $select2->from('foo')->order('bar')->limit(5)->offset(10);
     $expectedPrepareSql2 = 'SELECT * FROM ( SELECT [foo].*, ROW_NUMBER() OVER (ORDER BY [bar] ASC) AS [__ZEND_ROW_NUMBER] FROM [foo] ) AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN ?+1 AND ?+?';
     $expectedParams2 = array('offset' => 10, 'limit' => 5, 'offsetForSum' => 10);
     $expectedSql2 = 'SELECT * FROM ( SELECT [foo].*, ROW_NUMBER() OVER (ORDER BY [bar] ASC) AS [__ZEND_ROW_NUMBER] FROM [foo] ) AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN 10+1 AND 5+10';
     $expectedFormatParamCount2 = 3;
     $select3 = new Select();
     $select3->from('foo');
     $expectedPrepareSql3 = 'SELECT [foo].* FROM [foo]';
     $expectedParams3 = array();
     $expectedSql3 = 'SELECT [foo].* FROM [foo]';
     $expectedFormatParamCount3 = 0;
     return array(array($select0, $expectedPrepareSql0, $expectedParams0, $expectedSql0, $expectedFormatParamCount0), array($select1, $expectedPrepareSql1, $expectedParams1, $expectedSql1, $expectedFormatParamCount1), array($select2, $expectedPrepareSql2, $expectedParams2, $expectedSql2, $expectedFormatParamCount2), array($select3, $expectedPrepareSql3, $expectedParams3, $expectedSql3, $expectedFormatParamCount3));
 }
 /**
  * Returns all the comments pending approval for a thread.
  *
  * @param string $thread
  * @return ResultSet
  */
 public function fetchAllPendingForThread($thread)
 {
     $select = new Select($this->tableGateway->getTable());
     $select->columns(array('id', 'author', 'content', 'contact', 'published_on_raw' => 'published_on', 'published_on' => new Expression("DATE_FORMAT(published_on, '%M %d, %Y %H:%i')")))->where(array('thread' => $thread, 'visible' => 0))->order('published_on_raw ASC');
     $resultSet = $this->tableGateway->selectWith($select);
     return $resultSet;
 }
Exemple #20
0
 public function fetchAll($request, $paginated = false)
 {
     if ($paginated) {
         // create a new Select object for the table album
         $select = new Select('album');
         $select->order($request['sort'] . " " . $request['order']);
         // Search
         if ($request['search']) {
             $x = $request['search'] . '%';
             $where = new \Zend\Db\Sql\Where();
             $where->like('title', $x);
             $where->or->like('artist', $x);
             $select->where($where);
         }
         // New result set based on the Album entity
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Album());
         // New pagination adapter object
         $paginatorAdapter = new DbSelect($select, $this->tableGateway->getAdapter(), $resultSetPrototype);
         $paginator = new Paginator($paginatorAdapter);
         return $paginator;
     }
     $resultSet = $this->tableGateway->select();
     return $resultSet;
 }
 public function get($outputInventoryId, $id = false)
 {
     $select = new Select($this->tableGateway->getTable());
     $select->join('output_inventory', "output_inventory.id = " . $this->tableGateway->getTable() . ".output_inventory", array(), 'inner');
     $select->where(array($this->tableGateway->getTable() . ".output_inventory" => $outputInventoryId));
     if ($id) {
         $select->where(array($this->tableGateway->getTable() . ".id" => $id));
         $resultSet = $this->tableGateway->selectWith($select);
         $result = $resultSet->current();
         $product = $this->productTable->getName(false, $result->getProduct());
         $result->setProduct(implode($product));
     } else {
         $resultSet = $this->tableGateway->selectWith($select);
         $result = array();
         foreach ($resultSet as $rows) {
             $product = $this->productTable->getName(false, $rows->getProduct());
             $rows->setProduct(implode($product));
             switch ($rows->getIva()) {
                 case 1:
                     $rows->setIvaAccumulated($rows->getCost() - $rows->getCost() / 1.16);
                     $rows->setCost($rows->getCost() / 1.16);
                     break;
                 case 2:
                     $rows->setIvaAccumulated($rows->getCost() * 0.16);
                     break;
                 case 3:
                     $rows->setIvaAccumulated(0);
                     break;
             }
             $result[] = $rows;
         }
     }
     return $result;
 }
 public function indexAction()
 {
     /* 	$temp = $this->forward()->dispatch('Application/Controller/Album', array('action' => 'index'));
     		
     		echo '<pre>'; print_r($temp); echo '<pre>';die; */
     $auth = new AuthenticationService();
     if (!$auth->hasIdentity()) {
         return $this->redirect()->toRoute('home');
     }
     $select = new Select();
     $search = @$_REQUEST['search'];
     if (!empty($search)) {
         $select->where->like('name', '%' . $search . '%');
     }
     $order_by = $this->params()->fromRoute('order_by') ? $this->params()->fromRoute('order_by') : 'id';
     $order = $this->params()->fromRoute('order') ? $this->params()->fromRoute('order') : Select::ORDER_ASCENDING;
     $page = $this->params()->fromRoute('page') ? (int) $this->params()->fromRoute('page') : 1;
     $category = $this->getCategoryTable()->fetchAllCategory($select->order($order_by . ' ' . $order), $search);
     $itemPerPage = 2;
     $category->current();
     $paginator = new Paginator(new PaginatorIterator($category));
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage($itemPerPage);
     $paginator->setPageRange(10);
     return new ViewModel(array('order_by' => $order_by, 'order' => $order, 'page' => $page, 'paginator' => $paginator));
 }
 public function indexAction()
 {
     $searchform = new AlbumSearchForm();
     $searchform->get('submit')->setValue('Search');
     $select = new Select();
     $order_by = $this->params()->fromRoute('order_by') ? $this->params()->fromRoute('order_by') : 'id';
     $order = $this->params()->fromRoute('order') ? $this->params()->fromRoute('order') : Select::ORDER_ASCENDING;
     $page = $this->params()->fromRoute('page') ? (int) $this->params()->fromRoute('page') : 1;
     $select->order($order_by . ' ' . $order);
     $search_by = $this->params()->fromRoute('search_by') ? $this->params()->fromRoute('search_by') : '';
     $where = new \Zend\Db\Sql\Where();
     $formdata = array();
     if (!empty($search_by)) {
         $formdata = (array) json_decode($search_by);
         if (!empty($formdata['artist'])) {
             $where->addPredicate(new \Zend\Db\Sql\Predicate\Like('artist', '%' . $formdata['artist'] . '%'));
         }
         if (!empty($formdata['title'])) {
             $where->addPredicate(new \Zend\Db\Sql\Predicate\Like('title', '%' . $formdata['title'] . '%'));
         }
     }
     if (!empty($where)) {
         $select->where($where);
     }
     $album = $this->getAlbumTable()->fetchAll($select);
     $totalRecord = $album->count();
     $itemsPerPage = 2;
     $album->current();
     $paginator = new Paginator(new paginatorIterator($album));
     $paginator->setCurrentPageNumber($page)->setItemCountPerPage($itemsPerPage)->setPageRange(7);
     $searchform->setData($formdata);
     return new ViewModel(array('search_by' => $search_by, 'order_by' => $order_by, 'order' => $order, 'page' => $page, 'paginator' => $paginator, 'pageAction' => 'album', 'form' => $searchform, 'totalRecord' => $totalRecord));
 }
Exemple #24
0
 public function indexAction()
 {
     /* $service1=new \Lib\Service1\Custom();
     		echo $service1->demo(); die; */
     /* $plugin=$this->CustomPlugin();
     		print_r($plugin->doSomthing()); die; */
     /* $facebook = new \Facebook(array(
     				'appId'  => 'xxx',
     				'secret' => 'xxx',
     			));
     			print_r($facebook); die; */
     $auth = new AuthenticationService();
     if (!$auth->hasIdentity()) {
         return $this->redirect()->toRoute('home');
     }
     $select = new Select();
     $search = @$_REQUEST['search'];
     if (!empty($search)) {
         $select->where->like('name', '%' . $search . '%')->or->like('email', '%' . $search . '%')->or->like('mob', '%' . $search . '%')->or->like('title', '%' . $search . '%');
     }
     $order_by = $this->params()->fromRoute('order_by') ? $this->params()->fromRoute('order_by') : 'id';
     $order = $this->params()->fromRoute('order') ? $this->params()->fromRoute('order') : Select::ORDER_ASCENDING;
     $page = $this->params()->fromRoute('page') ? (int) $this->params()->fromRoute('page') : 1;
     $album = $this->getAdminTable()->fetchAll($select->order($order_by . ' ' . $order), $search);
     $itemPerPage = 2;
     $album->current();
     $paginator = new Paginator(new PaginatorIterator($album));
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage($itemPerPage);
     $paginator->setPageRange(10);
     //print_r($paginator); die;
     return new ViewModel(array('order_by' => $order_by, 'order' => $order, 'page' => $page, 'paginator' => $paginator));
 }
Exemple #25
0
 /**
  *
  * @param \Zend\Db\Sql\Select $query
  */
 protected function initFilters($query)
 {
     $value = $this->getParamAdapter()->getValueOfFilter('idRaid');
     if ($value != null) {
         $query->where("idRaid like '%" . $value . "%' ");
     }
     $value = $this->getParamAdapter()->getValueOfFilter('idEvenements');
     if ($value != null) {
         $query->where("idEvenements = '" . $value . "' ");
     }
     $value = $this->getParamAdapter()->getValueOfFilter('date');
     if ($value != null) {
         $query->where("date like '%" . $value . "%' ");
     }
     $value = $this->getParamAdapter()->getValueOfFilter('note');
     if ($value != null) {
         $query->where("note like '%" . $value . "%' ");
     }
     $value = $this->getParamAdapter()->getValueOfFilter('valeur');
     if ($value != null) {
         $query->where("valeur = '" . $value . "' ");
     }
     $value = $this->getParamAdapter()->getValueOfFilter('ajoutePar');
     if ($value != null) {
         $query->where("ajoutePar like '%" . $value . "%' ");
     }
     $value = $this->getParamAdapter()->getValueOfFilter('majPar');
     if ($value != null) {
         $query->where("majPar like '%" . $value . "%' ");
     }
 }
Exemple #26
0
 public function fetchAll()
 {
     $select = new Select($this->tableGateway->getTable());
     $select->where("id != 1");
     $resultSet = $this->tableGateway->selectWith($select);
     return $resultSet;
 }
 /**
  * Data provider for testGetSqlString
  *
  * @return array
  */
 public function dataProvider()
 {
     $select0 = new Select();
     $select0->from(array('x' => 'foo'));
     $expectedSql0 = 'SELECT "x".* FROM "foo" "x"';
     return array(array($select0, $expectedSql0));
 }
Exemple #28
0
 public function join(Select $select, $on, $prefix = null)
 {
     if (!$prefix) {
         $prefix = $on;
     }
     $select->join(array('table' . $prefix => $this->tableGateway->getTable()), 'table' . $prefix . '.id = ' . $on, array($prefix . '_id' => 'id', $prefix . '_name' => 'name', $prefix . '_path' => 'path', $prefix . '_mime' => 'mime', $prefix . '_size' => 'size', $prefix . '_created' => 'created', $prefix . '_status' => 'status'), 'left');
 }
Exemple #29
0
 public function setParameters(Parameters $params)
 {
     $groupsPostsTable = Api::_()->getDbTable('Group\\DbTable\\GroupsPosts');
     $groupsPostsTableName = $groupsPostsTable->initTableName()->getTable();
     $groupsCategoriesTable = Api::_()->getDbTable('Group\\DbTable\\CategoriesGroups');
     $groupsCategoriesTableName = $groupsCategoriesTable->initTableName()->getTable();
     if ($params->group_id || $params->groupCategory) {
         $params->inGroup = true;
     }
     if ($params->inGroup) {
         $groupId = $params->group_id;
         $categoryId = $params->groupCategory;
         $this->where(function ($where) use($groupsPostsTableName, $groupsCategoriesTableName, $groupId, $categoryId) {
             $select = new Select($groupsPostsTableName);
             $select->columns(array('post_id'));
             if ($groupId) {
                 $select->where(array('group_id' => $groupId));
             }
             if ($categoryId) {
                 $cateSelect = new Select($groupsCategoriesTableName);
                 $cateSelect->columns(array('group_id'));
                 $cateSelect->where(array('category_id' => $categoryId));
                 $select->where(function ($where) use($cateSelect) {
                     $where->in('group_id', $cateSelect);
                     return $where;
                 });
             }
             $where->in('id', $select);
             return $where;
         });
     }
     return parent::setParameters($params);
 }
 /**
  *
  * @param \Zend\Db\Sql\Select $query
  */
 protected function initFilters($query)
 {
     $value = $this->getParamAdapter()->getValueOfFilter('idEvenement_personnage');
     if ($value != null) {
         $query->where("idEvenement_personnage = '" . $value . "' ");
     }
     $value = $this->getParamAdapter()->getValueOfFilter('status');
     if ($value != null) {
         $query->where("status like '%" . $value . "%' ");
     }
     $value = $this->getParamAdapter()->getValueOfFilter('dateCreation');
     if ($value != null) {
         $query->where("dateCreation like '%" . $value . "%' ");
     }
     $value = $this->getParamAdapter()->getValueOfFilter('dateModification');
     if ($value != null) {
         $query->where("dateModification like '%" . $value . "%' ");
     }
     $value = $this->getParamAdapter()->getValueOfFilter('idEvenements');
     if ($value != null) {
         $query->where("idEvenements = '" . $value . "' ");
     }
     $value = $this->getParamAdapter()->getValueOfFilter('idPersonnage');
     if ($value != null) {
         $query->where("idPersonnage = '" . $value . "' ");
     }
 }