MongoCollection::createDBRef

(PECL mongo >=0.9.0)

MongoCollection::createDBRef����һ�����ݿ�����

˵��

public MongoCollection::createDBRef ( mixed $document_or_id ) : array

����

document_or_id

If an array or object is given, its _id field will be used as the reference ID. If a MongoId or scalar is given, it will be used as the reference ID.

����ֵ

����һ�����ݿ���������顣

����ṩ�˲����� _id �ֶε����鵱�� document_or_id ���������᷵�� NULL��

����

Example #1 MongoCollection::createDBRef() ����

<?php

$songs 
$db->songs;
$playlists $db->playlists;

// Ϊ song ��������
$manamana $songs->findOne(array('title' => 'Ma na ma na'));
$refToSong $songs->createDBRef($manamana);

// ������õ��ҵIJ����б�
$playlists->update(array('username' => 'me'), array('$push' => array('songlist' => $refToSong)));

?>

�μ�