PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE halls ( id INT PRIMARY KEY, hall_name VARCHAR(255), hall_adress VARCHAR(255), hall_details TEXT, price_hours VARCHAR(50), price_int VARCHAR(50) ); INSERT INTO halls (id, hall_name, hall_adress, hall_details, price_hours, price_int) VALUES (157, 'ali', 'st-50', NULL, '3000', '500'), (158, 'beta', 'st-51', NULL, '4000', '700'); CREATE TABLE imagas ( id INT PRIMARY KEY, id_Halls INT, image_path TEXT ); INSERT INTO imagas (id, id_Halls, image_path) VALUES (1, 157, '["1579635535.jpg", "1579635536.jpg", "1579635537.png", "1579635538.png"]'), (2, 158, '["1589635545.jpg", "1589635546.jpg", "1589635547.png"]');
Copy Clear
Copy Format Clear
<?php echo $db::table('halls') ->join('imagas', 'halls.id', '=', 'imagas.id_Halls') ->select( 'halls.id', 'halls.hall_name', 'halls.hall_adress', 'halls.hall_details', 'price_hours', 'price_int', 'halls.hall_name', 'imagas.image_path' ) ->where('halls.id', 157) ->get() ->map( fn($obj) => array_replace( (array) $obj, ['image_path' => substr_replace( json_decode($obj->image_path, true), 'http://127.0.0.1:8000/Imaga_halls/', 0, 0 )] ) ) ->toJson(JSON_PRETTY_PRINT);
Show:  
Copy Clear