FIND_IN_SET() in Zend Framework? - zend-db

I have been troubled in working with the FIND_IN_SET() sql query with zend framework
I have the code like this
$profileIds = "1,2,3";
$matchjobQry = $this->_db->select()->from('user_resume_skill')
->where('rsl_status=1')
->FIND_IN_SET('rsl_prf_id ',"$profileIds");
$matchjobRes = $this->_db->fetchAll($matchjobQry);
ping me with proper query,,
thanks in advance

At last i come to know the exact way of achieving this query,,guys use it
$profileIds = "1,2,3";
$matchjobQry = $this->_db->select()->from('user_resume_skill')
->where('rsl_status=1')
//this is the exact way of approaching zend, and finally got the answer
->where('FIND_IN_SET(rsl_prf_id,(?))', "$profileIds");
$matchjobRes = $this->_db->fetchAll($matchjobQry);

Related

Rally API Fetch All Features under specific Epic

Hi I cannot find this anywhere and it seems so easy.
I am trying to get All the Features under specific Epic with Alteryx.
I am using this to get them all, but I want to make more precise.
https://rally1.rallydev.com/slm/webservice/v2.0/portfolioitem/feature?pagesize=2000
https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement?workspace=https://rally1.rallydev.com/slm/webservice/v2.0/workspace/....
Can anyone help please?
Got another solution but it is still not perfect:
First I am getting SubEpics
https://rally1.rallydev.com/slm/webservice/v2.0/portfolioitem/subepic?pagesize=2000&&start=1&query=(Parent.FormattedID = E101)
And then Features:
https://rally1.rallydev.com/slm/webservice/v2.0/portfolioitem/feature?pagesize=2000&query=(((Parent.FormattedID = SE104) OR (Parent.FormattedID = SE101)) OR ((Parent.FormattedID = 102) OR (Parent.FormattedID = 103)))
OK! Correct answer for Feature is :) Got it with help from SAGI GABAY from CA:
https://rally1.rallydev.com/slm/webservice/v2.0/portfolioitem/feature?pagesize=2000&&start=1&query=(Parent.Parent.FormattedID
= E101)
I have also asked about the User Stories level and going this way (Parent.Parent.Parent.FormattedID) doesn't work anymore but you can do this:
https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement?pagesize=2000&&start=1&query=(Feature.Parent.FormattedID = SE101)

Product Index Using Django ORM

I have a list of Products with a field called 'Title' and I have been trying to get a list of initial letters with not much luck. The closes I have is the following that dosn't work as 'Distinct' fails to work.
atoz = Product.objects.all().only('title').extra(select={'letter': "UPPER(SUBSTR(title,1,1))"}).distinct('letter')
I must be going wrong somewhere,
I hope someone can help.
You can get it in python after the queryset got in, which is trivial:
products = Project.objects.values_list('title', flat=True).distinct()
atoz = set([i[0] for i in products])
If you are using mysql, I found another answer useful, albeit using sql(django execute sql directly):
SELECT DISTINCT LEFT(title, 1) FROM product;
The best answer I could come up with, which isn't 100% ideal as it requires post processing is this.
atoz = sorted(set(Product.objects.all().extra(select={'letter': "UPPER(SUBSTR(title,1,1))"}).values_list('letter', flat=True)))

Unable to query using 4 conditions with WHERE clause

I am trying to query a database to obtain rows that matches 4 conditions.
The code I'm using is the following:
$result = db_query("SELECT * FROM transportesgeneral WHERE CiudadOrigen LIKE '$origen%' AND DepartamentoOrigen LIKE '$origendep' AND DepartamentoDestino LIKE '$destinodep' AND CiudadDestino LIKE '$destino%'");
But it is not working; Nevertheless, when I try it using only 3 conditions; ie:
$result = db_query("SELECT * FROM transportesgeneral WHERE CiudadOrigen LIKE '$origen%' AND DepartamentoOrigen LIKE '$origendep' AND DepartamentoDestino LIKE '$destinodep'");
It does work. Any idea what I'm doing wrong? Or is it not possible at all?
Thank you so much for your clarification smozgur.
Apparently this was the problem:
I was trying to query the database by using the word that contained a tittle "Petén" so I changed the database info and replaced that word to the same one without the tittle "Peten" and it worked.
Now, im not sure why it does not accept the tittle but that was the problem.
If you have any ideas on how I can use the tittle, I would appreciate that very much.

Rails 3 Error when using OR with a where clause

I'm having a strange issue when using the Where clause in Rails. I imagine it has something to do with my OR operator syntax. Here is my query:
Cookie.where("ID = ? OR ID = ? OR ID = ? OR ID = ?", chocolate.to_s, sugar.to_s, peanut_butter.to_s, oatmeal.to_s)
When I attempt to execute the query my application just hangs endlessly. However, If I submit a query that looks like this:
Cookie.where("ID = ?", chocolate.to_s)
I get the expected result. Any help with the proper format to this where clause would be greatly appreciated. Thanks.
UPDATE
I went into the rails console and did as you suggested. This was the result:
SELECT \"TBLCookies\".* FROM \"TBLCookies\" WHERE (ID in ('4','3','2','1'))
This seems correct. I opened up SQL Developer, pasted this query in, and ran it. I got the expected result. So everything seems to be fine there. However, when I try to run the query in the rails console I get nothing back. The console just hangs indefinitely. Any insight into what could be going wrong would be great.
Why not do this
Cookie.where("ID in (?)",[chocolate, sugar, peanut_butter, oatmeal].collect(&:to_s))

Pagination not working Subsonic

I am having trouble with the pagination. It does not work, i.e. List staffs count is always zero for the code below.
If I remove the Paged method, correct results appear. How else can I solve this? I am using Subsonic 2.2. Pls help - thanks
SubSonic.SqlQuery query = DB.Select().Paged(startIndex, pageSize)
.From<Staff>()
.InnerJoin(StaffLocation.Schema.TableName, StaffLocation.Columns.StaffId, Staff.Schema.TableName, Staff.Columns.StaffId)
.InnerJoin(StaffClientGroup.Schema.TableName, StaffClientGroup.Columns.StaffId, Staff.Schema.TableName, Staff.Columns.StaffId)
.InnerJoin(StaffOutcome.Schema.TableName, StaffOutcome.Columns.StaffId, Staff.Schema.TableName, Staff.Columns.StaffId);
query.Where("1").IsEqualTo("1");
if (regionId > 0) query.And(StaffLocation.Columns.RegionId).IsEqualTo(regionId);
if (clientGroup > 0) query.And(StaffClientGroup.Columns.ClientGroupId).IsEqualTo(clientGroup);
if (outcome > 0) query.And(StaffOutcome.Columns.OutcomeId).IsEqualTo(outcome);
query.Distinct();
query.OrderBys.Add(Staff.Columns.FirstName);
List<Staff> staffs = query.ExecuteTypedList<Staff>();
return staffs;
Put a breakpoint on the second to last line and when it's hit execute query.BuildSqlStatement() in the Visual Studio immediate window and inspect the generated SQL. That might help narrow it down.
Well, I can tell you that it does work :) and I have a feeling that...
Your startIndex is wrong - try using 1 or 2
Your pageSize isn't set
What is "Where("1").IsEqualTo("1")?
You might try to grab the SQL to see what's being produced...