Welcome Guest, Not a member yet? Register   Sign In
should I keep as is or possible to re-write using Active Record?
#1

[eluser]Brad K Morse[/eluser]
I am refactoring most of my queries using Active Record, this is for an application that uses Oracle for a database.

Should I leave this query as is or is there an option for BETWEEN and what about using preg_replace within it?

I am guessing I could use something like:

Code:
->where('SP_COMMENTS.SP_COMMENTS_COMPLETION_DATE >, preg_replace('/(\d{6})(\d{2})/', '${1}01', date("Ymd", strtotime($this->input->post("user_begin_date"))))
->where('SP_COMMENTS.SP_COMMENTS_COMPLETION_DATE <, preg_replace('/(\d{6})(\d{2})/', '${1}01', date("Ymd", strtotime($this->input->post("user_end_date"))))

Code:
$q = $this->db->query("
SELECT distinct
  *
FROM
  SP_COMMENTS
WHERE
  SP_COMMENTS.SP_COMMENTS_USERNAME = '".$user."'
AND
  SP_COMMENTS.SP_COMMENTS_YEAR_CODE = '".$year_code."'
AND
  SP_COMMENTS.SP_COMMENTS_COMPLETION_DATE
BETWEEN ".preg_replace('/(\d{6})(\d{2})/', '${1}01', date("Ymd", strtotime($this->input->post("user_begin_date"))))."
AND ".date("Ymd", strtotime($this->input->post("user_end_date")))."
");




Theme © iAndrew 2016 - Forum software by © MyBB