Is it possible to use a sql query instead of a table in a server script?

Is it possible to use a sql query instead of a table in a server script?

Hildeb67Hildeb67 Posts: 65Questions: 19Answers: 1

Is this possible?

$sql_query = 'SELECT * USER WHERE NAME LIKE 'Pe%' ';

Editor::inst( $db, $sql_query,Index)
->fields( .............................

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Answer ✓

    It isn't. At least not like that. If you just want a condition for NAME LIKE 'Pe%' then use the where method:

    ->where(function ($q) {
      $q->where('NAME', 'Pe%', 'LIKE');
    })
    

    In a more general sense though, if you wanted 100% custom SQL statements to drive the table, that isn't possible with the Editor PHP libraries, since for that to work, they would need to have the ability to parse SQL! Instead, the API is used to build up the SQL statements for all four CRUD actions.

    You can of course query the db directly and populate a table that way. You can also handle the submit data if you wanted to go 100% custom at the server-side. But the Editor API cannot accept just any SQL statement.

    Allan

  • Hildeb67Hildeb67 Posts: 65Questions: 19Answers: 1

    Thank you for this Answer

Sign In or Register to comment.