Left Join a Select List in Editor
Left Join a Select List in Editor
davepmoll
Posts: 9Questions: 2Answers: 0
Hello, I am trying to do a leftJoin() on my select list in Editor. I keep getting this:
Fatal error: Call to undefined method DataTables\Database::leftJoin() in . . .
Here is the php:
if ( ! isset($_POST['action']) ) {
// Get a list of sites for the `select` list
$data['rringredient'] = $db
->leftJoin( 'rringredient', 'rringredient.ingredientID', '=', 'rringredientunit.IngredientID' )
->selectDistinct( 'rringredient', 'ingredientID as value, IngredientUnit as label' )
->fetchAll();
}
Thanks!
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I think you need to select before you use a join.
I added the select statement but I get the same error
Oh I see what you're doing. You have to use the leftjoin in the original field instances, not in your $_POST['action']
Use my example and follow the logic here...
Sure, sure got it. But . . .
Let's assume the column 'LID' was in a different table. How would we write it?
Your code:
In this line here:
If the column 'LID' was in a different table, how would we write it?
There are two options:
sql
method directly and just write your SQL query rather than using the PHP API that the libraries present.I've obviously made up some field names there, but that is how you can create a complex query using the API.
Allan
Thank you!