Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
select * from payment;
<?php
function evaluateValidResult(string $input): string
{
$regex = '@<\?php[^?]+\?>@';
return preg_replace_callback($regex, function($code) { eval("\$evaluated = $code;"); return $evaluated; }, $input);
}
$input = '[
{
"headers": [
{
"header": "tomorrow",
"pdo_type": 2
}
],
"data": [
[
"<?php $evaluated = date("Y-m-d", strtotime("tomorrow")); ?>"
]
]
}
]';
echo evaluateValidResult($input);
$query = "
select date_add(current_date, interval 1 day) tomorrow;
";
// get DB version using PDO
$stmt = $pdo->prepare($query);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_NUM);
$columns = [];
for ($i = 0; $i < $stmt->columnCount(); $i++) {
$col = $stmt->getColumnMeta($i);
$columns[] = [
'header'=>$col['name'],
'pdo_type'=>$col['pdo_type']
];
}
echo json_encode([[
'headers' => $columns,
'data' => $rows
]],
JSON_PRETTY_PRINT
);