Cml\Db\MongoDB\MongoDB::set PHP Метод

set() публичный Метод

根据key 新增 一条数据
public set ( string $table, array $data, mixed $tablePrefix = null ) : boolean | integer
$table string
$data array eg: ['username'=>'admin', 'email'=>'[email protected]']
$tablePrefix mixed 表前缀 不传则获取配置中配置的前缀
Результат boolean | integer
    public function set($table, $data, $tablePrefix = null)
    {
        if (is_array($data)) {
            is_null($tablePrefix) && ($tablePrefix = $this->tablePrefix);
            $bulk = new BulkWrite();
            $insertId = $bulk->insert($data);
            $result = $this->runMongoBulkWrite($tablePrefix . $table, $bulk);
            Cml::$debug && $this->debugLogSql('BulkWrite INSERT', $tablePrefix . $table, [], $data);
            if ($result->getInsertedCount() > 0) {
                $this->lastInsertId = sprintf('%s', $insertId);
            }
            return $this->insertId();
        } else {
            return false;
        }
    }