Jump to content

syntax error in query


neginf

Recommended Posts

Very new to PHP.

 

A query made with the find() function has a syntax error - a column name is outside the backwards quotes.

 

LEFT JOIN `lyn` AS `DiscontinueMed` ON (`Enr`.`` discontinue_med = `DiscontinueMed`.`id`)

 

There are other similar alias lyn with left joins to ENR that look ok and don't cause errors

 

The code that makes the query is

 

function eventFormCreation($model, $fields, $currentPersonId, $limit='50'){
  //the only reason we have limit set is because the Upload Additional Information can have more
  // than 1 without being wrong. Where we need to se the problem with other forms
  $record = $this->$model->find('all', array(
   'conditions' => array($model.'.person_id' => $currentPersonId),
//   'fields' => $fields,
//   'recursive' => -1,
   'limit'=>$limit));

  //pass the field to be included in the search
  $isComplete = $this->isComplete($model, $fields, $record);

etc

 

1. What can cause this ?

2. What can fix it ?

3. Can a query be run in CakePHP without the find() function - writing the query out explicitly and avoiding find() ?

 

Link to comment
https://forums.phpfreaks.com/topic/279266-syntax-error-in-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.