[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/components/com_poll/models/ -> poll.php (source)

   1  <?php
   2  /**
   3  * @version        $Id: poll.php 14401 2010-01-26 14:10:00Z louis $
   4  * @package        Joomla
   5  * @subpackage    Polls
   6  * @copyright    Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
   7  * @license        GNU/GPL, see LICENSE.php
   8  * Joomla! is free software. This version may have been modified pursuant
   9  * to the GNU General Public License, and as distributed it includes or
  10  * is derivative of works licensed under the GNU General Public License or
  11  * other free or open source software licenses.
  12  * See COPYRIGHT.php for copyright notices and details.
  13  */
  14  
  15  // Check to ensure this file is included in Joomla!
  16  defined('_JEXEC') or die( 'Restricted access' );
  17  
  18  jimport( 'joomla.application.component.model' );
  19  
  20  /**
  21  * @package        Joomla
  22  * @subpackage    Polls
  23  */
  24  class PollModelPoll extends JModel
  25  {
  26      /**
  27       * Add vote
  28       * @param int The id of the poll
  29       * @param int The id of the option selected
  30       */
  31  	function vote( $poll_id, $option_id )
  32      {
  33          $db = $this->getDBO();
  34          $poll_id    = (int) $poll_id;
  35          $option_id    = (int) $option_id;
  36  
  37          $query = 'UPDATE #__poll_data'
  38              . ' SET hits = hits + 1'
  39              . ' WHERE pollid = ' . (int) $poll_id
  40              . ' AND id = ' . (int) $option_id
  41              ;
  42          $db->setQuery( $query );
  43          $db->query();
  44  
  45          $query = 'UPDATE #__polls'
  46              . ' SET voters = voters + 1'
  47              . ' WHERE id = ' . (int) $poll_id
  48              ;
  49          $db->setQuery( $query );
  50          $db->query();
  51  
  52          $date =& JFactory::getDate();
  53  
  54          $query = 'INSERT INTO #__poll_date'
  55              . ' SET date = ' . $db->Quote($date->toMySQL())
  56              . ', vote_id = ' . (int) $option_id
  57              . ', poll_id = ' . (int) $poll_id
  58          ;
  59          $db->setQuery( $query );
  60          $db->query();
  61      }
  62  }


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1