Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php pdo bindvalue array

<?php
$ids     = array(1, 2, 3, 7, 8, 9);
$inQuery = implode(',', array_fill(0, count($ids), '?'));

$db = new PDO(...);
$stmt = $db->prepare(
    'SELECT *
     FROM table
     WHERE id IN(' . $inQuery . ')'
);

// bindvalue is 1-indexed, so $k+1
foreach ($ids as $k => $id)
    $stmt->bindValue(($k+1), $id);

$stmt->execute();
?>
Comment

PREVIOUS NEXT
Code Example
Php :: wordpress programmatically set acf taxonomy term 
Php :: object initialization 
Php :: carbon get difference between two dates in years and months 
Php :: undefined type excel 
Php :: multible many routes same controller 
Php :: When I try to run my code in chrome, i see the code that I have made in phpstorm and not the function that it has to do 
Php :: how to convert array into json php 
Php :: laravel DomPDF live preview 
Php :: with() multiple relationship 
Php :: Display HTML text from a variable in laravel 
Php :: crypt (PHP 4, PHP 5, PHP 7, PHP 8) crypt — One-way string hashing 
Php :: laravel many to many 
Php :: Yii2: Setting default values for all attributes of a model 
Php :: php header x-powered-by 
Php :: laravel how to call function in same controller 
Php :: same name selection in phpstorm mac 
Php :: Multiple trait declaration in PHP 
Php :: php prepared statement and conditional 
Php :: webiste url filter with pregx 
Php :: php artisan make:auth is not working in laravel 8 
Php :: laravel ailed: WebSocket opening handshake was canceled 
Php :: mysql.service: Start request repeated too quickly 
Php :: calculate average in eager loading laravel 
Php :: laravel How to query foreign relations data along with multiple main records 
Php :: php $_POST contains 
Php :: prevent cross site scripting php 
Php :: laravel migration softdelete 
Php :: how to get create table query preview in phpmyadmin 
Php :: cakephp 3 migrations foreign key 
Php :: php Display random custom content in WooCommerce shop archive loop 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =