Forum Index > FlashYourWeb OS Support > Gallery New Topic Post Reply
 Gallery2 development help
 |  Printable Version
davidarnoult
 April 03 2018 13:57 PM (Read 775 times)  
Forum Newbie
Newbie

Status: offline

Registered: 06/17/13
Posts: 9

Hello guys,

I am trying to develop a function to increment view for a lightbox in G2. The objective is to run a php file on an event (image displayed in lightbox) to increment the view using gallery2 api.

I have developped my file counter.php :

PHP Formatted Code

<?php
// +---------------------------------------------------------------------------+
// | counter.php     [v.1.0]                                                   |
// +---------------------------------------------------------------------------+
// | Copyright (C) 2018 David ARNOULT []                      |
// +---------------------------------------------------------------------------+
// |                                                                           |
// | This program is free software; you can redistribute it and/or             |
// | modify it under the terms of the GNU General Public License               |
// | as published by the Free Software Foundation; either version 2            |
// | of the License, or (at your option) any later version.                    |
// |                                                                           |
// | This program is distributed in the hope that it will be useful,           |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
// | GNU General Public License for more details.                              |
// |                                                                           |
// | You should have received a copy of the GNU General Public License         |
// | along with this program; if not, write to the Free Software Foundation,   |
// | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           |
// |                                                                           |
// +---------------------------------------------------------------------------+
//

global $gallery,$userId,$count,$g2_itemId,$rssIds,$item;

/* Connect to gallery */
        require_once ('embed.php');
        $ret = GalleryEmbed::init(array('fullInit'=>true, 'embedUri'=>'/', 'g2Uri'=>'/gallery2/'));
        if ($ret) {
                print 'GalleryEmbed::init failed, here is the error message: '.$ret->getAsHtml();
                exit;
        }
        GalleryEmbed::done();

        if (!$userId) {
                $userId = $gallery->getActiveUserId();
        }

        //print "userid=" . $userId;


        GalleryCoreApi::requireOnce('modules/core/classes/helpers/GalleryItemAttributesHelper_simple.class');


        if(isset($_REQUEST['itemId'])) {
                $itemId = $_REQUEST['itemId'];
                //print 'itemId=' . $itemId;
        }


        /* Increment the view count */
        $ret = GalleryCoreApi::incrementItemViewCount($itemId);

        //$ret = GalleryItemAttributesHelper_simple::fetchViewCount($itemId);
        //$ret = GalleryItemAttributesHelper_simple::incrementViewCount($itemId,1);
        //$ret = GalleryTestCase::testIncrementItemViewCount();
        if ($ret) {
                return array($ret, null);
        }

        return null;

?>
 


When I debug it, I have the SQL statement but with the ROLLBACK and the transaction is not commited:
PHP Formatted Code

(mysqli): UPDATE g2_ItemAttributesMap SET g_viewCount = g2_ItemAttributesMap.g_viewCount + 1 WHERE g_itemId=140355 
(mysqli): ROLLBACK 
 


I can't find a way to commit it...where is my error? Is there a missing part related to the database connection?

Thank you

Best,

David


 
Profile Email
Quote
Content generated in: 0.07 seconds
New Topic Post Reply



 All times are PST. The time is now 08:40 AM.
Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Anonymous users can post 
HTML Allowed 
Censored Content