Nette 3.0 fixes
This commit is contained in:
53
app/model/Database/Facade/TermFacade.php
Normal file
53
app/model/Database/Facade/TermFacade.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database\Facade;
|
||||
|
||||
use App\Model\Database\Entity\Term;
|
||||
use App\Model\Database\EntityManager;
|
||||
|
||||
|
||||
class TermFacade
|
||||
{
|
||||
|
||||
/** @var EntityManager */
|
||||
private $em;
|
||||
private $direction;
|
||||
|
||||
public function __construct(
|
||||
EntityManager $em
|
||||
)
|
||||
{
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function setDirection(int $direction)
|
||||
{
|
||||
$this->direction = $direction;
|
||||
}
|
||||
/**
|
||||
* @param mixed[] $data
|
||||
*/
|
||||
public function findByString()
|
||||
{
|
||||
$query = $this->em->createQueryBuilder('t')->select('t')
|
||||
->addSelect('s1')
|
||||
->addSelect('s2')
|
||||
->from(Term::class,'t')
|
||||
->leftJoin('t.suffix1','s1')
|
||||
->leftJoin('t.suffix2','s2');
|
||||
if ($this->direction == 1) {
|
||||
$query->where('t.string1 LIKE :str')->setParameter('str',"test"."%");
|
||||
$query->orderBy('t.string1,t.id','ASC');
|
||||
} else if ($this->direction == 2) {
|
||||
$query->where('t.string2 LIKE :str')->setParameter('str', "test"."%");
|
||||
$query->orderBy('t.string2','ASC');
|
||||
$query->addOrderBy('t.order2','ASC');
|
||||
}
|
||||
$query->andWhere('t.dictionary = :dict')->setParameter(':dict',1);
|
||||
//if ($this->clen)
|
||||
// $query->andWhere('t.member LIKE :clen')->setParameter('clen','%'."".'%');
|
||||
|
||||
return $query->getQuery()->getResult();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user