没有可用的版本信息,可能只有在Git中
说明
public mysql_xdevapi\CollectionModify::bind(array $placeholder_values): mysql_xdevapi\CollectionModify
将参数绑定到修改操作的搜索条件中的占位符。占位符的形式是:NAME,其中':'是一个通用前缀,必须始终存在于任何NAME之前,其中NAME是占位符的名称。如果在修改操作的搜索条件中必须替换多个实体,则bind方法接受占位符列表。
参数
placeholder_values
要在搜索条件中替换的占位符值。允许多个值,并且必须作为映射数组传递PLACEHOLDER_NAME->PLACEHOLDER_VALUE。
返回值
一个CollectionModify对象,可用于执行命令或添加其他操作。
示例
Example #1 mysql_xdevapi\CollectionModify::bind() example
<?php
$session = mysql_xdevapi\getSession("mysqlx://user:password@localhost");
$session->sql("DROP DATABASE IF EXISTS addressbook")->execute();
$session->sql("CREATE DATABASE addressbook")->execute();
$schema = $session->getSchema("addressbook");
$collection = $schema->createCollection("people");
$result = $collection
->add(
'{"name": "Bernie",
"traits": ["Friend", "Brother", "Human"]}')
->execute();
$collection
->modify("name = :name")
->bind(['name' => 'Bernie'])
->arrayAppend('traits', 'Happy')
->execute();
$result = $collection
->find()
->execute();
print_r($result->fetchAll());
?>
上面的例子将输出类似于:
Array
(
[0] => Array
(
[_id] => 00005b6b53610000000000000110
[name] => Bernie
[traits] => Array
(
[0] => Friend
[1] => Brother
[2] => Human
[3] => Happy
)
)
)