正常工作,我有一些麻煩,我有$currentPages
變量,它存儲以下數據array_shift功能沒有在PHP
Array ([1] => CMS_Content_Item_Page Object ([id] => 1 [name] => Soft Snacks [headline] => Soft Snacks [image] => /ImageUploaded/4page-img1.png [description] => Cheese Burger.................................................................3500 Frw Beef Burger.....................................................................3000 Frw Eggs Burger.....................................................................3500 Frw [content] => Cheese Burger.................................................................3500 Frw Beef Burger.....................................................................3000 Frw Eggs Burger.....................................................................3500 Frw Meat Ball (3) ................................................................1500 Frw Chicken wings.................................................................4000 Frw Sambusa (3).................................................................1500 Frw Cheese Plate ..................................................................2500 Frw Cheese Sausage..............................................................3500 Frw [parent_id] => 0 [_namespace:protected] => restaurant [_restaurantModel:protected] => Application_Model_Restaurant Object ([_name:protected] => restaurants [_dependentTables:protected] => Array ([0] => Application_Model_ContentNode) [_referenceMap:protected] => Array ([Restaurant] => Array ([columns] => Array ([0] => parent_id) [refTableClass] => Application_Model_Restaurant [refColumns] => Array ([0] => id) [onDelete] => cascade [onUpdate] => restrict)) [_definition:protected] => [_definitionConfigName:protected] => [_db:protected] => Zend_Db_Adapter_Pdo_Mysql Object ([_pdoType:protected] => mysql [_numericDataTypes:protected] => Array ([0] => 0 [1] => 1 [2] => 2 [INT] => 0 [INTEGER] => 0 [MEDIUMINT] => 0 [SMALLINT] => 0 [TINYINT] => 0 [BIGINT] => 1 [SERIAL] => 1 [DEC] => 2 [DECIMAL] => 2 [DOUBLE] => 2 [DOUBLE PRECISION] => 2 [FIXED] => 2 [FLOAT] => 2) [_defaultStmtClass:protected] => Zend_Db_Statement_Pdo [_config:protected] => Array ([host] => localhost [username] => hotelrwanda [password] => password [dbname] => hotelrwanda_db [charset] => [persistent] => [options] => Array ([caseFolding] => 0 [autoQuoteIdentifiers] => 1 [fetchMode] => 2) [driver_options] => Array ()) [_fetchMode:protected] => 2 [_profiler:protected] => Zend_Db_Profiler Object ([_queryProfiles:protected] => Array () [_enabled:protected] => [_filterElapsedSecs:protected] => [_filterTypes:protected] =>) [_defaultProfilerClass:protected] => Zend_Db_Profiler [_connection:protected] => PDO Object () [_caseFolding:protected] => 0 [_autoQuoteIdentifiers:protected] => 1 [_allowSerialization:protected] => 1 [_autoReconnectOnUnserialize:protected] =>) [_schema:protected] => [_cols:protected] => Array ([0] => id [1] => parent_id [2] => namespace [3] => name [4] => date_created) [_primary:protected] => Array ([1] => id) [_identity:protected] => 1 [_sequence:protected] => 1 [_metadata:protected] => Array ([id] => Array ([SCHEMA_NAME] => [TABLE_NAME] => restaurants [COLUMN_NAME] => id [COLUMN_POSITION] => 1 [DATA_TYPE] => int [DEFAULT] => [NULLABLE] => [LENGTH] => [SCALE] => [PRECISION] => [UNSIGNED] => [PRIMARY] => 1 [PRIMARY_POSITION] => 1 [IDENTITY] => 1) [parent_id] => Array ([SCHEMA_NAME] => [TABLE_NAME] => restaurants [COLUMN_NAME] => parent_id [COLUMN_POSITION] => 2 [DATA_TYPE] => int [DEFAULT] => [NULLABLE] => 1 [LENGTH] => [SCALE] => [PRECISION] => [UNSIGNED] => [PRIMARY] => [PRIMARY_POSITION] => [IDENTITY] =>) [namespace] => Array ([SCHEMA_NAME] => [TABLE_NAME] => restaurants [COLUMN_NAME] => namespace [COLUMN_POSITION] => 3 [DATA_TYPE] => varchar [DEFAULT] => [NULLABLE] => 1 [LENGTH] => 50 [SCALE] => [PRECISION] => [UNSIGNED] => [PRIMARY] => [PRIMARY_POSITION] => [IDENTITY] =>) [name] => Array ([SCHEMA_NAME] => [TABLE_NAME] => restaurants [COLUMN_NAME] => name [COLUMN_POSITION] => 4 [DATA_TYPE] => varchar [DEFAULT] => [NULLABLE] => 1 [LENGTH] => 100 [SCALE] => [PRECISION] => [UNSIGNED] => [PRIMARY] => [PRIMARY_POSITION] => [IDENTITY] =>) [date_created] => Array ([SCHEMA_NAME] => [TABLE_NAME] => restaurants [COLUMN_NAME] => date_created [COLUMN_POSITION] => 5 [DATA_TYPE] => int [DEFAULT] => [NULLABLE] => 1 [LENGTH] => [SCALE] => [PRECISION] => [UNSIGNED] => [PRIMARY] => [PRIMARY_POSITION] => [IDENTITY] =>)) [_metadataCache:protected] => [_metadataCacheInClass:protected] => 1 [_rowClass:protected] => Zend_Db_Table_Row [_rowsetClass:protected] => Zend_Db_Table_Rowset [_defaultSource:protected] => defaultNone [_defaultValues:protected] => Array ())))
並經過使用array_shift這是什麼功能它給我只是陣列(),有任何其他可以幫助處理這些數據的選項。
[編輯]基本上,我使用這裏Zend框架是處理這一陣列()
public function indexAction()
{
$mdlPagepageModel = new Application_Model_Restaurant();
$recentPages = $mdlPagepageModel->getRecentRestaurants();
if (is_array($recentPages)) {
// the 3 most recent items are the featured items
for ($i = 1; $i <= 2; $i ++) {
if (count($recentPages) > 0) {
$featuredItems[] = array_shift($recentPages);
}
}
$this->view->featuredItems = $featuredItems;
if (count($recentPages) > 0) {
$this->view->recentPages = $recentPages;
} else {
$this->view->recentPages = $null;
}
} else{
throw new Zend_Exception("Currently, menu does't have any file!");
}
}
爲什麼一切都在一條線上?你到底要如何調試?或者你如何期待我們這樣做? – GolezTrol 2012-04-25 15:50:08
我真的希望這是一個localhost部署,因爲你剛剛發佈了你的數據庫名稱,數據庫用戶名和密碼。 [用戶名] =>盧旺達飯店[密碼] =>密碼[DBNAME] => hotelrwanda_db – Kzqai 2012-04-25 15:54:35
哈哈,是的,這僅僅是例子, – Akrambek 2012-04-25 15:56:52