query-builder

Doctrine QueryBuilder returns QueryException

China☆狼群 提交于 2019-12-12 01:02:32
问题 I'm trying to get my Page Entities using the Doctrine QueryBuilder. I have succesfully implemented the ORM and it generated my database without any trouble. Now that I want to grab the Entities from the database, it seems to return a QueryException Fatal error: Uncaught exception 'Doctrine\ORM\Query\QueryException' with message 'SELECT page FROM Website\Model\Body\Page page WHERE page.isActive = 1' in path\to\orm\Doctrine\ORM\Query\QueryException.php:39 Stack trace: #0 path\to\orm\Doctrine

Doctrine Query Builder Delete Statement

亡梦爱人 提交于 2019-12-11 22:12:07
问题 I am using Symfony2, i must use the Doctrine QueryBuilder ( http://docs.doctrine-project.org/en/latest/reference/query-builder.html ) The documentation does not have an example for the delete or update statement. My entity is : object(stdClass)[417] public '__CLASS__' => string 'Les\DataBundle\Entity\News' (length=26) public 'id' => int 1 public 'restoId' => int 1 public 'category' => string 'dessert' (length=7) public 'text' => string 'jlkdjsalkdj sa' (length=14) public 'dateCreated' =>

Translate SQL query to CakePHP 3.0

老子叫甜甜 提交于 2019-12-11 21:24:46
问题 The query is as follows select T.username, sum(T.size) as totSize, count(*) total, count(case when T.type = 'facebook' then 1 else null end) as facebook, count(case when T.type = 'instagram' then 1 else null end) as instagram, count(case when T.type = 'device' then 1 else null end) as device from (SELECT users.username, pictures.size, pictures.type from users left join pictures on pictures.user_id = users.id) as T group by T.username Associated to each 'user' there are several 'picture'.

Doctrine Query Builder Bug?

泪湿孤枕 提交于 2019-12-11 19:51:23
问题 I have run into an issue in Doctrine. I have built the following query with queryBuilder $qb = $query = $this->repoLibrary->createQueryBuilder('l'); $query = $qb ->innerJoin('l.productVariant', 'v') ->innerJoin('v.product', 'p') ->innerJoin('p.taxons', 't', 'WITH', 't.id IN (:array)') ->where('l.user = :user') ->groupBy('l.id HAVING count(DISTINCT t.id) >= :count') ->setParameter('user', $user) ->setParameter('array', $s) ->setParameter('count', count($taxons)) ->getQuery(); Here is the query

Why are angular2 Lifecycle Hooks not working after using jquery query builder?

拈花ヽ惹草 提交于 2019-12-11 15:57:30
问题 I imported jquery query builder in my project as How to use Jquery Query Builder in Angular told. ngOnInit() { this.templateService.getTags(this.contentType) .then(tags => { this.tags = tags; }); } ngAfterViewInit() { this.getQueryBuilder(); } getQueryBuilder() { let self = this; if (self.builder) { $(self.builder.nativeElement).queryBuilder({ plugins: ['bt-tooltip-errors','not-group'], filters: [{ id: 'tag', label: 'Tag', type: 'string', input: 'select', values: { 1: 'Books', 2: 'Movies', 3:

How to calculate age using query builder in laravel?

折月煮酒 提交于 2019-12-11 15:25:45
问题 I have saved the date of birth in MySQL database. table name : **users** field name : **dob** now I want to show age on view. My query is : $user_info = DB::table('users')->select('(year(curdate())-year(dob)) as age')->get(); I'm using Laravel 5.5. but this is creating error. How to calculate age using query builder in laravel? 回答1: I recommend you to make a custom attribute in your app/User.php model. For example: In your User.php public function getAgeAttribute() { return $this->dob-

Convert mysql query logic to Laravel query builder

半城伤御伤魂 提交于 2019-12-11 11:42:24
问题 I am trying to convert my mysql query logic to Laravel query builder. I I have no Idea how to convert it as laravel query. my query logic is SELECT id,name, case when visibility_status = '1' then 'Visible' when visibility_status = '0' then 'Invisible' end as visibility_status FROM `flowers` generally I write a select query using query builder but cant implement above logic $result = DB::table('flowers') ->select('flowers.id as id', 'flowers.name as name', 'flowers.visibility_status as

php mysql full text search multiple table joined by id

自闭症网瘾萝莉.ら 提交于 2019-12-11 09:49:06
问题 I have been reading on full text search for some time now, I have read some articles that say its possible but they don't provide sample query, I'm stuck finding a workaround on how to search on multiple table joined by an ID using full text search this is my minified table look like here is what i have so far $users = User::select('users.*','departments.department_name') ->join('departments', 'departments.id', ' =', 'users.dept_id') ->whereRaw( "MATCH(user_name) AGAINST(? IN BOOLEAN MODE)",

How can I pass a parameter to a Doctrine2 custom function in the Query Builder select() method?

假装没事ソ 提交于 2019-12-11 08:46:11
问题 In my Symfony2 project I am retrieving an ordered set of entity IDs from an Elasticsearch index. I'm then passing this list to Doctrine2 to retrieve the actual entities, by way of a WHERE IN() call. This doesn't return them in the correct order, so I think I need to use the MySQL-specific FIELD() function. I've created a custom DQL function to allow the functionality. So now I'm using the following code to build a Doctrine query object, but the parameters aren't being parsed into the select()

DateTime comparison in ObjectQuery.Where

夙愿已清 提交于 2019-12-11 07:58:14
问题 I'm using Entity Framework, and I have a COMMENT entity. A COMMENT has a DATEMODIFIED property, which is a Nullable Date. I'm trying to build a query that will filter COMMENTs by date, so I create a startDate object, and do the following: Dim q As ObjectQuery(Of COMMENT) = _ (From c In model.COMMENT Select c) If startDate.HasValue Then q = q.Where(Function(c) startDate.Value <= c.DATEMODIFIED) End If The problem is that q.toList() is not returning any comments, even though I think it should.