PHP.mk документација

Collection::replaceOne

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

mysql-xdevapi-collection.replaceone.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека mysql-xdevapi-collection.replaceone.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
Collection::replaceOne

Референца за `mysql-xdevapi-collection.replaceone.php` со подобрена типографија и навигација.

mysql-xdevapi-collection.replaceone.php

Collection::replaceOne

(Нема достапни информации за верзијата, можеби е само во Git)

Collection::replaceOneReplace one collection document

= NULL

public mysql_xdevapi\Collection::replaceOne(string $id, string $doc): mysql_xdevapi\Result

Updates (or replaces) the document identified by ID, if it exists.

Параметри

id

ID of the document to replace or update. Typically this is the _id that was generated by MySQL Server when the record was added.

doc

Collection document to update or replace the document matching the id parameter.

This document can be either a document object or a valid JSON string describing the new document.

Вратени вредности

A Result object that can be used to query the number of affected items and the number warnings generated by the operation.

Примери

Пример #1 mysql_xdevapi\Collection::replaceOne() 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": "Alfred", "age": 18, "job": "Butler"}')->execute();

// Normally the _id is known by other means,
// but for this example let's fetch the generated id and use it
$ids = $result->getGeneratedIds();
$alfred_id = $ids[0];

// ...

$alfred = $collection->getOne($alfred_id);
$alfred['age'] = 81;
$alfred['job'] = 'Guru';

$collection->replaceOne($alfred_id, $alfred);

?>

Белешки од корисници

Нема белешки од корисници за оваа страница.
На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.