Get Thumb webservice Using PHP codeigniter

php web-services codeigniter

37 просмотра

1 ответ

I created webservice for gallery as category.

Each image gallery should have count and main cover photo.

I need help creating the main photo from each gallery and I believe that is should last image should be main.

My webservice for image gallery category as below :

    /* Get galleries*/

public function get_galleries($db) {
    $operation = new Operations($db);
    $galleries = $operation->GetResultsWebServiceGallery("Select galID as 'id', galTitle, galLocation,galDescription from  " . $db . ".hotshoe_gallery");
    foreach ($galleries as $key => $value) {
       if(!empty($galleries[$key]['id'])) {
        $id = $galleries[$key]['id'];
           $galleries[$key]['count'] = $operation->GetResults("Select COUNT(*) as total from  " . $db . ".hotshoe_images where galID=$id");
       }
    }
    return $galleries;
}
Автор: Ahmadoo Alkharouf Источник Размещён: 08.11.2019 11:16

Ответы (1)


0 плюса

Решение

Fetch one image from each gallery and use it as cover.

 /* Get gallries*/

public function get_galleries($db) {
    $operation = new Operations($db);
    $galleries = $operation->GetResultsWebServiceGallery("Select galID as 'id', galTitle, galLocation,galDescription from  " . $db . ".hotshoe_gallery");
    foreach ($galleries as $key => $value) {
       if(!empty($galleries[$key]['id'])) {
        $id = $galleries[$key]['id'];
           $galleries[$key]['count'] = $operation->GetResults("Select COUNT(*) as total from  " . $db . ".hotshoe_images where galID=$id");
           //my code start here
           $galleries[$key]['cover'] = $operation->GetResults("Select image  from  " . $db . ".hotshoe_images where galID=$id order by id desc limit 1");
          //my code ends here

       }
    }
    return $galleries;
}
Автор: codemirror Размещён: 20.08.2016 02:54
Вопросы из категории :
32x32