Twitter Delicious Facebook Digg Stumbleupon Favorites More

Sabtu, 21 Maret 2009

Tutorial Cake Php

PHP doc blcok

This function can be thought of as a hybrid between PHP's array_merge and
array_merge_recursive. The difference to the two is that if an array key
contains another array then the function behaves recursive (unlike array_merge)
but does not do if for keys containing strings (unlike array_merge_recursive).
See the unit test for more information.

Note: This function will work with an unlimited amount of arguments and
typecasts non-array parameters into arrays.

A bit like array_merge_recursive. Merge joins two arrays on their keys.
If we want to add the $extraData array into the $dat most people would probably think, hey, lets merge them using Set::merge… but.. no, dont, unless you know what your doing.



test data
$data = array(
1 => array('Post' => array(
'id' => 1, 'post_comment_count' => 2,
'name' => 'My first title', 'body' => 'My first body'
),
'PostComment' => array(
array(
'id' => 1, 'post_id' => 1, 'is_active' => 1,
'name' => 'My first comment', 'body' => 'My first comment'),
array(
'id' => 2, 'post_id' => 2, 'is_active' => 1,
'name' => 'My second comment', 'body' => 'My second comment'),
array(
'id' => 3, 'post_id' => 2, 'is_active' => 1,
'name' => 'My third comment', 'body' => 'My third comment')
)
),
2 => array('Post' => array(
'id' => 2, 'post_comment_count' => 1,
'name' => 'My second title', 'body' => 'My second title'
),
'PostComment' => array(
array(
'id' => 4, 'post_id' => 2, 'is_active' =>
1, 'name' => 'My fourth comment', 'body' => 'My fourth comment'
)
)
),
3 => array('Post' => array(
'id' => 3, 'post_comment_count' => 0,
'name' => 'My third title', 'body' => 'My third title'
),
'PostComment' => array(

)
)
);

$dataExtra = array(
4 => array('Post' => array(
'id' => 4, 'post_comment_count' => 1,
'name' => 'My fourth title', 'body' => 'My fourth title'
),
'PostComment' => array(
array(
'id' => 5, 'post_id' => 4, 'is_active' => 1,
'name' => 'My fifth comment', 'bdoy' => 'My fifth comment'
)
)
)
);

0 komentar:

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Blogger Templates