query-builder

Laravel - Querybuilder with join and concat

女生的网名这么多〃 提交于 2020-08-22 12:09:41
问题 Im trying to pull all users from the users table who match a certain group in the users_groups pivot table. Im using Sentry 2 from Cartalyst btw. This works to get all users with first and last name concatenated. User::select(DB::raw('CONCAT(last_name, ", ", first_name) AS full_name'), 'id') ->where('activated', '=', '1') ->orderBy('last_name') ->lists('full_name', 'id'); when i try to change it to also filter users who do not belong to a certain group I get a syntax error. User::select(DB:

How to do case insensitive search using querybuilder rest api in cq

廉价感情. 提交于 2020-07-11 04:49:06
问题 How to use case insensitive search in Querybuilder REST API in CQ5. This is my query localhost path query . Here i want to add fn:lower-case to my property. But it is not working. property=fn:lower-case(@jcr:content) This code is not working in querybuilder REST API. The same logic i can able to do using Xpath like [(fn:lower-case(@jcr:content), 'test'] and it's working fine, when i used in Querybuilder Java API. The same logic need to implement querybuilder REST API as well. Where i need to

How to do case insensitive search using querybuilder rest api in cq

て烟熏妆下的殇ゞ 提交于 2020-07-11 04:49:06
问题 How to use case insensitive search in Querybuilder REST API in CQ5. This is my query localhost path query . Here i want to add fn:lower-case to my property. But it is not working. property=fn:lower-case(@jcr:content) This code is not working in querybuilder REST API. The same logic i can able to do using Xpath like [(fn:lower-case(@jcr:content), 'test'] and it's working fine, when i used in Querybuilder Java API. The same logic need to implement querybuilder REST API as well. Where i need to

AEM query builder: search multiple properties

こ雲淡風輕ζ 提交于 2020-07-10 08:53:26
问题 How can I list all the properties and respective values for more than one property under a give node. For example, the below code, I could search for one property only. But I need to search for 10 different property(alttext, img, promos.. etc) and get respective values(if exist) for it. Map<String, String> map = new HashMap<String, String>(); map.put(TYPE_PREDICATE, "nt:base"); map.put(PATH_PREDICATE, printAttachmentJsonNodePath); map.put("property", "fileReference"); map.put("p.excerpt",

Get maximum id inside Doctrine entity

痞子三分冷 提交于 2020-05-17 07:15:06
问题 I need to get maximum ID of a table inside of symfony 2.7 entity. But instead of having the id I'm getting this issue. Notice: Undefined property: AppBundle\Entity\BlogPost::$container This is my BlogPost entity, <?php namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\HttpFoundation\File\UploadedFile; /** * BlogPost * * @ORM\Table() * @ORM\Entity */ class BlogPost { const SERVER_PATH_TO_IMAGE_FOLDER = '/uploads'; /** * @var integer * * @ORM\Column(name="id",

CakePHP 3.x Specify a Different Count Query for Pagination

混江龙づ霸主 提交于 2020-04-07 09:26:27
问题 I am trying to customize the pagination query for CakePHP I am using a Model based around a view. The view has some complex calculations in it and when the pagination runs it takes about 3 seconds to pull the 20 rows or so. Then it is running the same view wrapped in a count for the count used in pagination. I can run a simple table count on another table which would cut the load times in half but I am unable to find a simple way to customize a seperate query to run for the counts. Is this

How to transform raw SQL into Yii2 like find query

此生再无相见时 提交于 2020-03-05 05:20:04
问题 I can't convert raw SQL query in to Yii2 like method. I'd like to implement grid view from my RAW sql with filtering and sorting. I'm using ActiveDataProvider with method in the ModelSearch as Yii default way. I did try to use Model::findBySql but it is not letting me filter or sort my results in the grid view. I don't want to useSQLDataProvider because I have relations in my queries. I see that changing Model::FindBySql($sql) to Model::find is letting me sort and filter but the results are

Where_in in codeigniter

别等时光非礼了梦想. 提交于 2020-03-03 04:26:56
问题 I'm using Codeigniter 3 to build a website. But now I have an issue with get data from database. this is my Model: public function Get($arr_condition = null) { if(!is_null($arr_condition)) { $this->db->where($arr_condition); } $query = $this->db->get('cus'); if($query->num_rows()>0) { return $query->result_array(); } return false; } In Controller, I use an array ($arr_condition) to get list conditional: $arr_condition['Cus_team'] = 1; $arr_condition['Cus_user != '] = 2; $arr_condition['Cus

Where_in in codeigniter

大城市里の小女人 提交于 2020-03-03 04:26:08
问题 I'm using Codeigniter 3 to build a website. But now I have an issue with get data from database. this is my Model: public function Get($arr_condition = null) { if(!is_null($arr_condition)) { $this->db->where($arr_condition); } $query = $this->db->get('cus'); if($query->num_rows()>0) { return $query->result_array(); } return false; } In Controller, I use an array ($arr_condition) to get list conditional: $arr_condition['Cus_team'] = 1; $arr_condition['Cus_user != '] = 2; $arr_condition['Cus

How to use WITH clause in Laravel Query Builder

爱⌒轻易说出口 提交于 2020-02-25 04:18:43
问题 I have SQL query (see example). But I can't find a way how I can write it in Query Builder. Do you have any ideas how is it possible? WITH main AS ( SELECT id FROM table1 ) SELECT * FROM table2 WHERE table2.id IN (SELECT * FROM main) I want to get format like: $latestPosts = DB::table('posts') ->select('user_id', DB::raw('MAX(created_at) as last_post_created_at')) ->where('is_published', true) ->groupBy('user_id'); $users = DB::table('users') ->joinSub($latestPosts, 'latest_posts', function (