developer.jelix.org is not used any more and exists only for history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Ticket #838: 838-jDaoConditions-enclose-field-names-followup.diff

File 838-jDaoConditions-enclose-field-names-followup.diff, 3.3 KB (added by Julien, 12 years ago)
  • build/manifests/testapp.mn

     
    168168  jdb.0_profiles.html_cli.php
    169169  jdb.1_queries.html_cli.php
    170170  jdb.2_queries_with_pdo.html_cli.php
     171  jdb.mysql.html_cli.php
    171172  jdb.pgsql.html_cli.php
    172173  jdb.sqlite.html_cli.php
    173174  jdbtools.mysql.html_cli.php
  • testapp/modules/jelix_tests/tests/jdb.mysql.html_cli.php

     
     1<?php
     2/**
     3* @package     testapp
     4* @subpackage  jelix_tests module
     5* @author      Julien Issler
     6* @contributor
     7* @copyright   2009 Julien Issler
     8* @link        http://www.jelix.org
     9* @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
     10*/
     11
     12class UTjDbMysql extends jUnitTestCaseDb {
     13
     14    function testFieldNameEnclosure(){
     15        $this->assertEqualOrDiff(jDb::getConnection()->encloseFieldName('toto'),'`toto`');
     16    }
     17
     18}
     19 No newline at end of file
  • testapp/modules/jelix_tests/tests/jdb.pgsql.html_cli.php

     
    184184
    185185    }
    186186
     187    function testFieldNameEnclosure(){
     188        $this->assertEqualOrDiff(jDb::getConnection($this->dbProfile)->encloseFieldName('toto'),'"toto"');
     189    }
     190
    187191}
    188192
    189193?>
     194 No newline at end of file
  • lib/jelix/db/jDbPDOConnection.class.php

     
    9898        // et que l'on utilise cet attribut...
    9999        if($this->dbms == 'mysql')
    100100            $this->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
    101    
     101
    102102        // Oracle renvoie les noms de colonnes en majuscules, il faut donc forcer la casse en minuscules
    103103        if ($this->dbms == 'oci')
    104             $this->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);           
    105            
     104            $this->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
     105
    106106        if(isset($prof['force_encoding']) && $prof['force_encoding']==true){
    107107            if($this->dbms == 'mysql' && isset($this->_mysqlCharsets[$GLOBALS['gJConfig']->charset])){
    108108                $this->exec("SET CHARACTER SET '".$this->_mysqlCharsets[$GLOBALS['gJConfig']->charset]."'");
     
    189189    public function hasTablePrefix(){
    190190        return (isset($this->profile['table_prefix']) && $this->profile['table_prefix']!='');
    191191    }
     192
     193    /**
     194     * enclose the field name
     195     * @param string $fieldName the field name
     196     * @return string the enclosed field name
     197     * @since 1.1.2
     198     */
     199    public function encloseFieldName($fieldName){
     200        switch($this->dbms){
     201            case 'mysql': return '`'.$fieldName.'`';
     202            case 'pgsql': return '"'.$fieldName.'"';
     203            default: return $fieldName;
     204        }
     205    }
    192206}