php8.5
Home/ Manual/ mysql_xdevapi / tableselect/ TableSelect::bind

TableSelect::bind

PHP function Edit on GitHub ✎

Bind select query parameters

Description

mysql_xdevapi\TableSelect::bind(array $placeholder_values): mysql_xdevapi\TableSelect

Binds a value to a specific placeholder.

Parameters

placeholder_values

The name of the placeholder, and the value to bind.

Return Values

A TableSelect object.

Examples

mysql_xdevapi\TableSelect::bind() example

php
<?php
$session = mysql_xdevapi\getSession("mysqlx://user:password@localhost");

$schema = $session->getSchema("addressbook");
$table  = $schema->getTable("names");

$result = $table->select('name','age')
  ->where('name like :name and age > :age')
  ->bind(['name' => 'John', 'age' => 42])
  ->execute();

$row = $result->fetchAll();
print_r($row);
?>

The above example will output something similar to:

output
Array
(
    [0] => Array
        (
            [name] => John
            [age] => 42
        )
)

Source: reference/mysql_xdevapi/mysql_xdevapi/tableselect/bind.xml · from the official PHP manual (php/doc-en)