我需要在mongoid.yml中设置选项。它在开发中工作,但heroku中的生产给出了忽略警告消息。 有人经历过以及如何解决这个问题吗?
header('Content-type: text/xml');
// INITIALIZE DOM OBJECT
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->formatOutput = true;
$dom->preserveWhiteSpace = false;
// CREATE ROOT AND APPEND TO DOCUMENT
$xmlRoot = $dom->createElement("persons");
$xmlRoot = $dom->appendChild($xmlRoot);
// QUERY DATABASE
$db = new PDO('mysql:host=localhost;dbname=xxx','root','');
$stmt = $db->prepare("select * from users");
$stmt->execute();
// FETCH ROWS ITERATIVELY
while($row = $stmt->fetch()){
// APPEND PERSON AS CHILD OF ROOT
$personNode = $xmlRoot->appendChild($dom->createElement('person'));
// APPEND CHILDREN TO PERSON
$personNode->appendChild($dom->createElement('id', $row['id']));
$personNode->appendChild($dom->createElement('username', $row['username']));
$personNode->appendChild($dom->createElement('password', $row['password']));
$personNode->appendChild($dom->createElement('realname', $row['realname']));
$personNode->appendChild($dom->createElement('surname', $row['surname']));
$personNode->appendChild($dom->createElement('email', $row['email']));
$personNode->appendChild($dom->createElement('created', $row['created']));
$personNode->appendChild($dom->createElement('admin', $row['admin']));
}
$stmt = null;
$db = null;
// OUTPUT TO SCREEN
echo $dom->saveXML();
在mongoid.yml
W, [2017-04-05T02:04:09.447207 #4] WARN -- : MONGODB | Unsupported client option 'raise_not_found_error'. It will be ignored.
W, [2017-04-05T02:04:09.449089 #4] WARN -- : MONGODB | Unsupported client option 'belongs_to_required_by_default'. It will be ignored.
W, [2017-04-05T02:04:09.449176 #4] WARN -- : MONGODB | Unsupported client option 'consistency'. It will be ignored.
答案 0 :(得分:0)
这是Mongo db在尝试查找任何记录时给出的错误,它在数据库中不匹配。为了解决这个问题
在生产配置中添加此行
raise_not_found_error:false
mongoid.yml
production:
clients:
default:
database: database_name
hosts:
- localhost:27017
options:
read:
mode: :primary
max_pool_size: 1
raise_not_found_error: false