How does one get the raw " ->sql " to work in editor
How does one get the raw " ->sql " to work in editor
Maybe I am tired, but I have beat on this thing too long. Not that I am great sql writer, but an example would be nice. Everything I try throws errors like "php error - unexpected variable $sql". I think if I could get my head around this function, I would like to have a set of buttons that could send custom queries on a click. If I ever get the date range thing to work, I would like to add a select box that picks the date column and then send it. I keep searching but everything has the note that it is legacy and pre 1.10. I have chased the rabbit anyways a few times, but success is not happening with this one.
This question has an accepted answers - jump to answer
Answers
Using the
sql()
method is as simple as doing:Where of course the SQL string is updated to be whatever you need.
Allan
I get "PHP Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR)" Referring to the ->fetchAll();
=
there.$data
not the$db
connection.Allan
if(( $_POST['min'] != '')AND ($_POST['max']!='')){
$min = $_POST['min'];
$max = $_POST['max'];
$data = $db->$sql("select * from vert_test left outer join notes on vert_test.uid = notes.uid where un25_test between \'$min\' AND \'$max\'")->fetchAll();
echo json_encode($data);
exit();
}
returns : <b>Notice</b>: Undefined variable: sql in <b>/home/rex/www/cathouse2/php/table.vert_test.php</b> on line <b>42</b><br />
<br />
<b>Fatal error</b>: Method name must be a string in <b>/home/rex/www/cathouse2/php/table.vert_test.php</b> on line <b>42</b><br />
I tried to clean that up but not sure how. I use VIM. Is there a setting anyone knows of that will not choke up markup so bad when using paste?
You still have $db->$sql where you should have $db->sql.
Thanks for that, I guess using other old libraries for so long, made me absolutely blind to that. Working much better now. Still getting a TypeError: c is undefined error from jquery. But at least the data is coming back.