9951 explained code solutions for 126 technologies


php-pdoView prepared PHP PDO statement


$st = $pdo->prepare('SELECT * FROM test WHERE age = :52');
$st->execute([':age' => 52]);
$st->debugDumpParams();ctrl + c
$pdo->prepare

prepare given query to execute

$st->execute(

run query on the server

debugDumpParams

prints (instead or return) prepared query statement and list of bind values


Usage example

<?php

$pdo = new PDO('mysql:host=localhost;dbname=test', 'usr', 'pwd');

$st = $pdo->prepare('SELECT * FROM test WHERE age = :52');
$st->execute([':age' => 52]);
$st->debugDumpParams();
output
SQL: [34] SELECT * FROM test WHERE age = :52
Params:  1
Key: Name: [4] :age
paramno=-1
name=[4] ":age"
is_param=1
param_type=2