Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular

PHPize.online is a free online environment for quickly running, experimenting with and sharing PHP (including Carbon extension for DateTime) and SQL code. You can run your SQL code with PHP code that can use the same DB. For database manipulations you can use pre-defined instances of PDO ($pdo), mysqli ($mysqli) & Laravel query builder ($db)

Copy Format Clear
create table clients (id int); insert into clients values (1),(2); create table client_2_data (id int); create table client_1_data (id int, `updated` datetime DEFAULT NULL);
Copy Clear
Copy Format Clear
<?php $ca=$mysqli->query('SELECT * FROM `clients`'); $c=$ca->fetch_assoc(); try { $mysqli->query('ALTER TABLE `client_'.$c['id'].'_data` ADD COLUMN `updated` datetime DEFAULT NULL'); }catch (Exception $e) { echo "Caught for {$c['id']}\n $e"."\n"; } try { $c=$ca->fetch_assoc(); }catch (Exception $e) { echo $e."\n"; }
Show:  
Copy Clear