Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
function test(?string $a_code = null, ?string $a_type = null, ?array $a_order = null): array
{
$a_where_sql = [];
if(is_string($a_code )) $a_where_sql[] = "code='$a_code'";
if(is_string($a_type )) $a_where_sql[] = "type='$a_type'";
$where_sql = sizeof($a_where_sql) ? 'WHERE (' . implode(') AND (',$a_where_sql). ')' : '';
$order_sql = is_array($a_order)? 'ORDER BY '.array_key_first($a_order).' '.$a_order[array_key_first($a_order)] : '';
echo 'SELECT * FROM game_lesson_attachment '.$where_sql . ' ' .$order_sql;
return [];
}
test('page_id_att','doc',['date_orig' => 'DESC']);