i am working on a Cakephp 2.x.. i have two tables into my db name Images and Audios .. both have a userid field ... first what i want is i want to retrive the data and sort by date field which is in both the tables.. on my view page i want to show the images and videos by date...
for example image1,video2,video3,image2
right now i am doing this in Images model
function getImagesAndAudio($userid){
$this->bindModel(array(
'belongsTo' => array(
'Audio' => array(
'className' => 'Audio',
'foreignKey' => false,
'conditions' => array(
'Image.user_id = Audio.user_id',
),
'type' => 'LEFT',
'order'=>'Image.date',//error
)
)
), false);
return $this->find('all', array('conditions' => array('Image.User_id' => $userid),
'contain' => array('Audio' ),
));
the problem is right now it gives me error if i do this
'order'=>'date',
and the other thing i dont know how can i show the images and videos in mixup order... i mean when i do this
foreach ($datas as $data){
echo $data['Image']['filename'];
echo $data['Audio']['filename'];
}
the problem is i have to manually write the code that show image now and now show the audio... i want to show the file with respect to date .. so if there is an image after the two audios file show an image and then so on