CodeIgniter Forums
SQL errors - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: SQL errors (/showthread.php?tid=50104)



SQL errors - El Forum - 03-14-2012

[eluser]theknight[/eluser]
Here is my code:

$child = $this->getDetails($row['ParentOf_Id']);

which is in another function that calls a function called getdetails:

function getDetails($child_id=null,$limit=20){

// select all the fields in the children table
$this->db->select(castedColumns($this->children_table, $this->db));
//where the id is the child id
$q = $this->db->get_where($this->children_table, 'id='.$child_id);
//store results array in details
$details = $q->row_array();
I then get the following SQL error:

A Database Error Occurred Error Number:

Incorrect syntax near '='.

SELECT CAST(AdditionalNotes AS TEXT) as AdditionalNotes, CAST(DisabilitiesNotes AS TEXT) as DisabilitiesNotes, DOB, msrepl_tran_version FROM Children WHERE id=

Id does not get appended? why?

Been driving me nuts because, when I do echo $child_id; I get the child Id before passing it into the SQL.


SQL errors - El Forum - 03-14-2012

[eluser]douweegbertje[/eluser]
try this?

Code:
function getDetails($child_id=null,$limit=20){

  // select all the fields in the children table
  $this->db->select(castedColumns($this->children_table, $this->db));
  //where the id is the child id
  $q = $this->db->get_where($this->children_table, 'id=' . $child_id . ');
  //store results array in details
  $details = $q->row_array();



SQL errors - El Forum - 03-14-2012

[eluser]InsiteFX[/eluser]
26 posts and you still do not know how to use the code tags!