我不知道爲什麼,但我收到此錯誤PHP的MongoDB沒有更新陣列
Fatal error: Call to a member function update() on a non-object in /home/XXXXXXXXXXXXXXXXX/classes/core.php on line 22
在該網頁上我有這個
public function updatemongo($from,$data)
{
$this->db = $m->exchange_rates;
$collection = $this->db->exchangeDB;
$collection->update(array("from" => $from), $data);
}
這是怎麼了調用該函數
foreach ($currencies as $to)
{
if($from != $to)
{
$url = 'http://finance.yahoo.com/d/quotes.csv?f=l1d1t1&s='.$from.$to.'=X';
$handle = fopen($url, 'r');
if ($handle) {
$result = fgetcsv($handle);
fclose($handle);
}
$newdata = array('$set' => array("exchangehistory.{$result[1]}.{$result[2]}" => array("to" => $to, "rate" => $result[0], "updated" => $result[2])));
$fetch->updatemongo($from,$newdata);
$newdata = array('$set' => array("currentexchange" => array("to" => $to, "rate" => $result[0], "updated" => $result[2])));
$fetch->updatemongo($from,$newdata);
}
}
是的,需要訪問該文件的文件也有require_once("core.php");
請讓我知道爲什麼這不起作用。