Welcome Guest, Not a member yet? Register   Sign In
ActiveRecords named queries
#1

[eluser]fatman[/eluser]
Hi,

I'm using CodeIgniter 1.7.2, and i have a long query with about 14 parameters to bind.
The catch is that there are actually only 2 params that i need to bind and they repeat themselves.

Is it possible to tell ActiveRecords to use the same variable over and over so for example:

Code:
SELECT agg.createDate, SUM(agg.leadQty) AS leadQty,
  SUM(agg.leadSuccess) AS leadSuccess, ROUND((SUM(agg.leadSuccess)/SUM(agg.leadQty))*100) AS 'leadSuccessP',
  SUM(agg.leadFailure) AS leadFailure
  FROM (
  SELECT DATE(createDate) AS createDate, COUNT(leadId) AS leadQty, 0 AS leadSuccess, 0 AS leadFailure
  FROM analyticengine.lds_Leads_vw
  where createDate >= ?
  and createDate < ?
  GROUP BY DATE(createDate)
  UNION ALL
  SELECT DATE(createDate) AS createDate, 0 AS leadQty, COUNT(leadId) AS leadSuccess, 0 AS leadFailure
  FROM analyticengine.lds_Leads_vw
  WHERE leadStatusId = 1
  AND createDate >= ?
  AND createDate < ?
  GROUP BY DATE(createDate)
  UNION ALL...

instead of sending the same date over and over i'd like replace the '?' with ':date' and tell it to replace all of ':date' with the same variable.




Messages In This Thread
ActiveRecords named queries - by El Forum - 06-10-2012, 07:18 AM
ActiveRecords named queries - by El Forum - 06-10-2012, 12:45 PM
ActiveRecords named queries - by El Forum - 06-11-2012, 01:23 AM
ActiveRecords named queries - by El Forum - 06-11-2012, 08:55 AM



Theme © iAndrew 2016 - Forum software by © MyBB