Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Controllers;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\DB;
- class UserController extends Controller
- {
- public function index(Request $request) {
- $xml = simplexml_load_file($request->file);
- $select = trim($xml->SELECT);
- $from = strtolower(trim($xml->FROM));
- $wheres = $xml->WHERE;
- $where = '';
- $params = [
- 'class' => 2,
- 'gender' => 0,
- 'birthday' => '2019-10-10'
- ];
- foreach ($wheres as $key => $value) {
- $a = strtolower(trim($value));
- $b = explode(' ', $a);
- if (in_array($b[0], array_keys($params))) {
- if ($where == '') {
- $where .= strtolower(trim($value));
- } else {
- $where .= ' AND ' . strtolower(trim($value));
- }
- }
- }
- $query = 'SELECT ' . $select . ' FROM ' . $from . ' WHERE ' . $where;
- $result = DB::select($query, $params);
- dd($result);
- dd($xml);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement