PHPize Online / SQLize Online

A A A
Share   Donate   Blog   Popular
Copy Format Clear
CREATE TABLE my ( id int, gorod text ); INSERT INTO my VALUES (1, 'Moscow,Kyev'), (2, 'Minsk,Moscow'), (3, 'Lviv,Odessa');
Copy
Copy Format Clear
<?php use Carbon\Carbon; $gorod = 'Moscow'; $query = "SELECT * FROM my WHERE gorod LIKE ?"; // get DB version using PDO $stmt = $pdo->prepare($query); $filter = "%$gorod%"; $stmt->execute([$filter]); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); print_r($rows);
Show:  
Copy