The sql_create_view()
function creates a view for the selection query provided. The view can then be used by SPIP loops or by other selection commands.
It accepts 4 parameters:
-
$nom
is the name of the view created, -
$select_query
is the selection query, -
$serveur
, -
$option
.
It can be used in conjunction with the sql_get_select function to retrieve the desired selection:
$selection = sql_get_select('column', 'table');
sql_create_view('myview', $selection);
// utilisation
$result = sql_select('column', 'myview');
Note:
Whenever a selection column uses the 'name.column'
notation, you absolutely must declare an alias for the column, otherwise certain database ports (SQLite in particular) will not create the expected view, e.g. 'name.column AS column'
.