Esempio n. 1
0
 public function testLessThanOrEqualToCreatesOperatorPredicate()
 {
     $predicate = new Predicate();
     $predicate->lessThanOrEqualTo('foo.bar', 'bar');
     $parts = $predicate->getExpressionData();
     $this->assertEquals(1, count($parts));
     $this->assertContains('%s <= %s', $parts[0]);
     $this->assertContains(array('foo.bar', 'bar'), $parts[0]);
 }
 /**
  * Get all expired memberships connections
  *
  * @param integer $limit
  * @return array
  */
 public function getExpiredMembershipsConnections($limit)
 {
     $predicate = new Predicate();
     $select = $this->select();
     $select->from(['a' => 'membership_level_connection'])->columns(['id', 'user_id'])->join(['b' => 'membership_level'], 'a.membership_id = b.id', ['role_id'], 'left')->join(['c' => 'user_list'], 'a.user_id = c.user_id', ['nick_name', 'email', 'language'])->join(['d' => 'acl_role'], 'd.id = b.role_id', ['role_name' => 'name'], 'left')->limit($limit)->where(['a.active' => self::MEMBERSHIP_LEVEL_CONNECTION_ACTIVE, $predicate->lessThanOrEqualTo('a.expire_date', time())])->where->or->equalTo('a.active', self::MEMBERSHIP_LEVEL_CONNECTION_ACTIVE)->and->isNull('a.membership_id');
     $statement = $this->prepareStatementForSqlObject($select);
     $resultSet = new ResultSet();
     $resultSet->initialize($statement->execute());
     return $resultSet->toArray();
 }
 /**
  * Get all expired not paid transactions
  *
  * @param integer $limit
  * @return array
  */
 public function getExpiredTransactions($limit)
 {
     $predicate = new Predicate();
     $select = $this->select();
     $select->from('payment_transaction_list')->columns(['id', 'slug'])->where(['paid' => self::TRANSACTION_NOT_PAID, $predicate->lessThanOrEqualTo('date', time() - (int) SettingService::getSetting('payment_clearing_time'))])->limit($limit);
     $statement = $this->prepareStatementForSqlObject($select);
     $resultSet = new ResultSet();
     $resultSet->initialize($statement->execute());
     return $resultSet->toArray();
 }
 /**
  * Delete node
  *
  * @param integer $leftKey
  * @param integer $rightKey
  * @param array $filter
  * @param boolean $useTransaction
  * @return boolean|string
  */
 public function deleteNode($leftKey, $rightKey, array $filter = [], $useTransaction = true)
 {
     try {
         if ($useTransaction) {
             $this->tableGateway->getAdapter()->getDriver()->getConnection()->beginTransaction();
         }
         $predicate = new Predicate();
         $this->tableGateway->delete([$predicate->greaterThanOrEqualTo($this->left, $leftKey), $predicate->lessThanOrEqualTo($this->right, $rightKey)] + $filter);
         $predicate = new Predicate();
         $this->tableGateway->update([$this->left => new Expression('IF(' . $this->left . ' > ?, ' . $this->left . ' - (? - ? + 1), ' . $this->left . ')', [$leftKey, $rightKey, $leftKey]), $this->right => new Expression($this->right . ' - (? - ? + 1)', [$rightKey, $leftKey])], [$predicate->greaterThan($this->right, $rightKey)] + $filter);
         if ($useTransaction) {
             $this->tableGateway->getAdapter()->getDriver()->getConnection()->commit();
         }
     } catch (Exception $e) {
         if ($useTransaction) {
             $this->tableGateway->getAdapter()->getDriver()->getConnection()->rollback();
         }
         ErrorLogger::log($e);
         return $e->getMessage();
     }
     return true;
 }