$currentPages
以下のデータを格納する変数があります。
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フレームワークを使用しています。ここでは、このarray()を処理するスクリプトです。
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!");
}
}