Example #1
0
 public function testReturnResultFromQueryBuilder()
 {
     $stub = \Mockery::mock('Entity\\Posts');
     MockEntityController::mock('post', $stub);
     $entityName = \PHPUnit_Framework_Assert::readAttribute($this->query->setQuery('post'), 'entityName');
     $this->assertEquals('Entity\\Posts', $entityName);
 }
Example #2
0
 /**
  *
  * @param string $position
  */
 private function loadMenuItmsByPosition(string $position)
 {
     $this->query->setQuery('menu')->findBy('position', $position)->limit(1);
     $content = $this->query->getStaticQuery();
     if (array_key_exists(0, $content)) {
         $this->menuItemsArray = $content[0]->getMenuItems();
     }
 }
Example #3
0
 /**
  *
  * @param string $column
  * @param mixed $value
  * @return boolean
  */
 private function dataNotExistInDatabase(string $column, $value, array $exception) : bool
 {
     $query = $this->query->setQuery($this->entityKey);
     if (!empty($exception)) {
         $query->query("c.{$column} NOT IN(?0)", [$exception]);
     }
     $query->findBy($column, $value);
     $result = $this->query->getStaticQuery();
     return count($result) === 0 ? true : false;
 }
Example #4
0
 private function selectPosts()
 {
     switch ($this->http->router->group()) {
         case 'post':
             $this->query->setQuery('post');
             break;
         case 'category':
             $catIdArray = RegistryFactory::start()->register('App\\Resource\\CategoryList')->child();
             $this->query->setQuery('post')->categoryId($catIdArray)->force();
             break;
         case 'date':
             $this->query->setQuery('post')->date($this->getDate())->force();
             break;
         default:
             $this->query->setQuery('post');
     }
     $this->post = $this->query->getQuery();
 }
Example #5
0
 private function setPageFromDB()
 {
     $this->query->setQuery('page');
     $this->page = $this->query->getQuery();
 }
Example #6
0
 /**
  *
  * @param string $alias
  * @return integer
  */
 public function getIdByAlias(string $alias) : int
 {
     $this->query->setQuery('category')->alias($alias);
     $content = $this->query->getStaticQuery();
     return $content ? $content[0]->getId() : 0;
 }
Example #7
0
 /**
  * @param $table Table name
  * @param $connName Connection name
  * @return Query
  */
 public function query($table, $connName)
 {
     $query = new Query($this->getConnection($connName), $this->getGrammar());
     return $query->table($table);
 }
Example #8
0
 /**
  * todo do something with paginate()
  * @return array
  */
 public function getResult() : array
 {
     return $this->query->getQuery();
 }