info:joomla:modellivress

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
info:joomla:modellivress [2014/02/19 15:19] – modification externe 127.0.0.1info:joomla:modellivress [2025/10/22 07:02] (Version actuelle) – supprimée radeff
Ligne 1: Ligne 1:
-====== Changements dans le model livress (liste) ====== 
-===== à la fin, ajouter ===== 
- 
-<code> 
-function getTotal() 
-  { 
-        // Load the content if it doesn't already exist 
-        if (empty($this->_total)) { 
-            $query = $this->_buildQuery(); 
-            $this->_total = $this->_getListCount($query);     
-        } 
-        return $this->_total; 
-  } 
-   function getPagination() 
-  { 
-        // Load the content if it doesn't already exist 
-        if (empty($this->_pagination)) { 
-            jimport('joomla.html.pagination'); 
- 
-         $total = $this->getTotal(); 
-        $limitstart = $this->getState('limitstart'); 
-        $limit = $this->getState('limit'); 
- 
-        // create the pagination object 
-        $this->_pagination = new JPagination($total, $limitstart, $limit); 
-        } 
-        return $this->_pagination; 
-  } 
-   
-  /** 
-   * Items total 
-   * @var integer 
-   */ 
-  var $_total = null; 
-  
-  /** 
-   * Pagination object 
-   * @var object 
-   */ 
-  var $_pagination = null; 
-    
-     function __construct() 
-  { 
-        parent::__construct(); 
-  
-        global $mainframe, $option; 
-  
-        // Get pagination request variables 
-        $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); 
-        $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); 
-  
-        // In case limit has been changed, adjust it 
-        $limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0); 
-  
-        $this->setState('limit', $limit); 
-        $this->setState('limitstart', $limitstart); 
-  } 
-   
-//end main model class 
-</code> 
- 
- 
-=====    function getData() ===== 
- 
-   function getData() 
-   { 
-      // Lets load the data if it doesn't already exist 
-      if (empty( $this->_data )) 
-      { 
-         $query = $this->_buildQuery(); 
-         $this->_data = $this->_getList( $query ); 
-      } 
-      return $this->_data; 
-   } 
- 
-===== corrections fines ===== 
-attention, ici c'est plus délicat: 
- 
-avant getData, changer 
-<code> 
-  function _buildQuery() 
-   { 
-      $query = ' SELECT * ' 
-         . ' FROM #__livres ' 
-      ; 
- 
-      return $query; 
-   } 
-</code> 
-pour 
-<code> 
- 
-   function _buildQuery() 
-   { 
-      #echo "filter: " .$this->filter_search; 
-       
-      $query = ' SELECT * ' 
-         . ' FROM #__livres '  
-   . $this->_buildQueryWhere() 
-         . ' ORDER BY auteur,titre' 
-      ; 
-      #echo "<hr>SQL: " .$query ."<hr>"; //tests 
-      return $query; 
-   } 
-    
-/** 
- * Builds the WHERE part of a query 
- * 
- * @return string Part of an SQL query 
- */ 
-function _buildQueryWhere() 
-{ 
-    global $mainframe, $option;  
- 
-    // get the filter values 
-     $filter_search = $mainframe->getUserStateFromRequest($option.'filter_search', 'filter_search');  
- 
-    // prepare the WHERE clause 
-    $where = array();  
-     // Determine search terms 
-    if ($filter_search = trim($filter_search)) 
-    { 
-        $filter_search = JString::strtolower($filter_search); 
-        $db =& $this->_db; 
-        $filter_search = $db->getEscaped($filter_search); 
-        #$where[] = 'NOM1 LIKE "%'.$filter_search.'%"'; 
- 
-    $where[] = ' 
-auteur LIKE "%'.$filter_search.'%" OR  
-titre LIKE "%'.$filter_search.'%" OR  
-support LIKE "%'.$filter_search.'%" OR  
-localisation LIKE "%'.$filter_search.'%" OR  
-groupe_carton LIKE "%'.$filter_search.'%" OR  
-type LIKE "%'.$filter_search.'%" OR  
-date LIKE "%'.$filter_search.'%" OR  
-remarques LIKE "%'.$filter_search.'%" OR  
-owner LIKE "%'.$filter_search.'%" OR  
-datein LIKE "%'.$filter_search.'%" OR  
-user_id LIKE "%'.$filter_search.'%" 
-    '; 
-    } 
- 
-    // return the WHERE clause 
-    return (count($where)) ? ' WHERE '.implode(' AND ', $where) : ''; 
-} 
-   /** 
-    * Retrieves the hello data 
-    * @return array Array of objects containing the data from the database 
-    */ 
-   function getData() 
-   { 
-      // Lets load the data if it doesn't already exist 
-      if (empty( $this->_data )) 
-      { 
-        $query = $this->_buildQuery(); 
-        $limitstart = $this->getState('limitstart'); 
-        $limit = $this->getState('limit'); 
-        $this->_data = $this->_getList($query, $limitstart, $limit); 
-      } 
- 
-      return $this->_data; 
-   } 
- 
-</code> 
- 
  
  • info/joomla/modellivress.1392819540.txt.gz
  • Dernière modification : 2016/02/15 09:35
  • (modification externe)