LoginSignup
0
0

More than 5 years have passed since last update.

"'Safe' option is deprecated, please use 'w' instead"の解消方法

Last updated at Posted at 2015-02-19

CakePHPでMongoDBを利用しているのですが、使用しているライブラリが古いせいかログに、

"'Safe' option is deprecated, please use 'w' instead"

というnoticeメッセージが大量発生していました。

公式ドキュメントをみると、メッセージ通り、safeモードのオプション指定は非推奨になっているので、write concernを使えとのこと。

before.php
$collection->insert($data, array('safe' => true));
$collection->save($data, array('safe' => true));
$collection->update($conditions, $data, array("multiple" => false, 'safe' => true));

となっているのを、

after.php
$collection->insert($data, array('w' => 1));
$collection->save($data, array('w' => 1));
$collection->update($conditions, $data, array("multiple" => false, 'w' => 1));

に修正したところ解消しました。

めでたしめでたし。

困ったときは公式ドキュメントをみるに限りますね。
http://php.net/manual/ja/mongocollection.insert.php
http://php.net/manual/ja/mongocollection.save.php
http://php.net/manual/ja/mongocollection.update.php

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0