PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?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']);
Show:  
Copy Clear