2012-02-21 80 views
0

我使用的字符集UTF-8來獲得非對象的屬性在Zend框架,它是錯誤:錯誤通知:試圖

Notice: Trying to get property of non-object in C:\wamp\www\zend-search-lucene\indexing.php on line 27 

這是代碼的PHP:

<?php 
require_once 'Zend/Search/Lucene.php'; 
$arr_data = array(0 => array( "products"  => "Google suggest : pick right search keyword"), 
         1 => array("products"  => "zend framework tutorial | part 9 Zend Auth")); 

$lucene_index_path = 'data/'; 
$index = new Zend_Search_Lucene($lucene_index_path, true); 
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive()); 

foreach($arr_data as $test) { 
    //create an cache index doc 
    $doc = new Zend_Search_Lucene_Document(); 
    $doc->addField(Zend_Search_Lucene_Field::Text('products', $test->products, 'UTF-8')); **//LINE 27** 
    $index->addDocument($doc); 
} 
$index->commit(); 
$index->optimize(); 

回答

3
$doc->addField(Zend_Search_Lucene_Field::Text('products', $test['products'], 'UTF-8')); 

$test->products更改爲$test['products']