Missing Something FORM - PHP Plugin (Solved)

Status
Not open for further replies.

eugenecjr

Member
For the life of me can't figure out what is wrong with the following code. Running the following with either $query separate works fine. I am using similar code on other forms running three queries that work just fine. Only different here is that one of the queries contains a join. But just don't see anything wrong.

PHP:
$linkInterview = '<a href="/linked/interviews/form/46/'.'{fab_interviews___id}' . '"' . '>Interview</a>';
$link = '<a href="/linked/interviews/form/46/'.'{fab_interviews___id}' . '"' . '>Open</a>';
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query
  ->update($db->quoteName('fab_applications', 'a'))
  ->join('INNER', $db->quoteName('fab_interviews', 'b') . 'ON ' . $db->quoteName('a.id') . ' = ' . $db->quoteName('b.applicant'))
  ->set($db->quoteName('a.link_interview') .' = ' . $db->quote($linkInterview))
  ->where($db->quoteName('a.id') . ' = ' . '{fab_interviews___applicant}');
$db->setQuery($query);
$db->execute();
$query
  ->update($db->quoteName('fab_interviews', 'c'))
  ->set($db->quoteName('c.link') . ' = ' . $db->quote($link))
  ->where($db->quoteName('c.id') . ' = ' . '{fab_interviews___id}');
$db->setQuery($query);
$db->execute();

When I run the above I get an error:

Error

Unknown column 'a.id' in 'where clause'


Even though I get the error the first statement executed, which also contains the a.id, works and I see the updated results in the table. The second statement does not contain a.id as I switched them all to 'c' as a test and has no results in the table.

-Eugene
 
You have same name for both query objects
Try to rename second query to somethnig like:

PHP:
$db_2 = JFactory::getDbo();
$query = $db_2->getQuery(true);
$query
  ->update($db_2->quoteName('fab_interviews', 'c'))
  ->set($db_2->quoteName('c.link') . ' = ' . $db_2->quote($link))
  ->where($db_2->quoteName('c.id') . ' = ' . '{fab_interviews___id}');
$db_2->setQuery($query);
$db_2->execute();

and check again field names.
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top