Changeset 444
- Timestamp:
- 05/28/07 14:33:08 (2 years ago)
- Files:
-
- trunk/build/manifests/testapp.mn (modified) (2 diffs)
- trunk/build/manifests/testapp.mn (modified) (2 diffs)
- trunk/lib/jelix/core/jConfigCompiler.class.php (modified) (2 diffs)
- trunk/lib/jelix/core/jConfigCompiler.class.php (modified) (2 diffs)
- trunk/lib/jelix/core/jSelector.class.php (modified) (2 diffs)
- trunk/lib/jelix/core/jSelector.class.php (modified) (2 diffs)
- trunk/lib/jelix/dao/jDaoCompiler.class.php (modified) (2 diffs)
- trunk/lib/jelix/dao/jDaoCompiler.class.php (modified) (2 diffs)
- trunk/lib/jelix/dao/jDaoGenerator.class.php (modified) (10 diffs)
- trunk/lib/jelix/dao/jDaoGenerator.class.php (modified) (10 diffs)
- trunk/lib/jelix/dao/jDaoParser.class.php (modified) (2 diffs)
- trunk/lib/jelix/dao/jDaoParser.class.php (modified) (2 diffs)
- trunk/lib/jelix/db/jDbPDOConnection.class.php (modified) (2 diffs)
- trunk/lib/jelix/db/jDbPDOConnection.class.php (modified) (2 diffs)
- trunk/lib/simpletest/compatibility.php (modified) (1 diff)
- trunk/lib/simpletest/compatibility.php (modified) (1 diff)
- trunk/testapp/modules/testapp/install/base.mysql.sql (modified) (1 diff)
- trunk/testapp/modules/testapp/install/base.mysql.sql (modified) (1 diff)
- trunk/testapp/modules/unittest/classes/junittestcase.class.php (modified) (1 diff)
- trunk/testapp/modules/unittest/classes/junittestcase.class.php (modified) (1 diff)
- trunk/testapp/modules/unittest/classes/junittestcasedb.class.php (modified) (5 diffs)
- trunk/testapp/modules/unittest/classes/junittestcasedb.class.php (modified) (5 diffs)
- trunk/testapp/modules/unittest/classes/unittestservice.class.php (modified) (3 diffs)
- trunk/testapp/modules/unittest/classes/unittestservice.class.php (modified) (3 diffs)
- trunk/testapp/modules/unittest/classes/utdao.class.php (modified) (1 diff)
- trunk/testapp/modules/unittest/classes/utdao.class.php (modified) (1 diff)
- trunk/testapp/modules/unittest/classes/utdaopdo.class.php (added)
- trunk/testapp/modules/unittest/classes/utdaopdo.class.php (added)
- trunk/testapp/modules/unittest/classes/utdao_parser.class.php (added)
- trunk/testapp/modules/unittest/classes/utdao_parser.class.php (added)
- trunk/testapp/modules/unittest/classes/utdao_parser2.class.php (moved) (moved from trunk/testapp/modules/unittest/classes/utdao2.class.php) (1 diff)
- trunk/testapp/modules/unittest/classes/utdao_parser2.class.php (moved) (moved from trunk/testapp/modules/unittest/classes/utdao2.class.php) (1 diff)
- trunk/testapp/modules/unittest/classes/utjaclusergroup.class.php (modified) (1 diff)
- trunk/testapp/modules/unittest/classes/utjaclusergroup.class.php (modified) (1 diff)
- trunk/testapp/modules/unittest/classes/utjdb.class.php (added)
- trunk/testapp/modules/unittest/classes/utjdb.class.php (added)
- trunk/testapp/modules/unittest/classes/utjdb_pdo.class.php (added)
- trunk/testapp/modules/unittest/classes/utjdb_pdo.class.php (added)
- trunk/testapp/modules/unittest/classes/utjdb_profile.class.php (added)
- trunk/testapp/modules/unittest/classes/utjdb_profile.class.php (added)
- trunk/testapp/modules/unittest/controllers/dao.classic.php (modified) (2 diffs)
- trunk/testapp/modules/unittest/controllers/dao.classic.php (modified) (2 diffs)
- trunk/testapp/modules/unittest/controllers/db.classic.php (added)
- trunk/testapp/modules/unittest/controllers/db.classic.php (added)
- trunk/testapp/modules/unittest/daos (added)
- trunk/testapp/modules/unittest/daos (added)
- trunk/testapp/modules/unittest/daos/products.dao.xml (added)
- trunk/testapp/modules/unittest/daos/products.dao.xml (added)
- trunk/testapp/modules/unittest/templates/menu.tpl (modified) (2 diffs)
- trunk/testapp/modules/unittest/templates/menu.tpl (modified) (2 diffs)
- trunk/testapp/var/config/dbprofils.ini.php.dist (modified) (2 diffs)
- trunk/testapp/var/config/dbprofils.ini.php.dist (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/build/manifests/testapp.mn
r423 r444 75 75 utselectormod.class.php 76 76 utsimpletest.class.php 77 utjdb.class.php 78 utjdb_pdo.class.php 79 utjdb_profile.class.php 77 80 utdao.class.php 78 utdao2.class.php 81 utdaopdo.class.php 82 utdao_parser.class.php 83 utdao_parser2.class.php 79 84 utdao_conditions.class.php 80 85 utfilter.class.php … … 109 114 tpl.classic.php 110 115 acl.classic.php 116 db.classic.php 117 cd testapp/modules/unittest/daos 118 products.dao.xml 111 119 112 120 cd testapp/var trunk/build/manifests/testapp.mn
r423 r444 75 75 utselectormod.class.php 76 76 utsimpletest.class.php 77 utjdb.class.php 78 utjdb_pdo.class.php 79 utjdb_profile.class.php 77 80 utdao.class.php 78 utdao2.class.php 81 utdaopdo.class.php 82 utdao_parser.class.php 83 utdao_parser2.class.php 79 84 utdao_conditions.class.php 80 85 utfilter.class.php … … 109 114 tpl.classic.php 110 115 acl.classic.php 116 db.classic.php 117 cd testapp/modules/unittest/daos 118 products.dao.xml 111 119 112 120 cd testapp/var trunk/lib/jelix/core/jConfigCompiler.class.php
r375 r444 62 62 $config->urlengine['basePath'] = $path; 63 63 } 64 65 /*if(preg_match("/^([a-zA-Z]{2})(?:_([a-zA-Z]{2}))?$/",$config->defaultLocale,$m)){ 66 if(!isset($m[2])){ 67 $m[2] = $m[1]; 68 } 69 $config->defaultLang = strtolower($m[1]); 70 $config->defaultCountry = strtoupper($m[2]); 71 $config->defaultLocale = $config->defaultLang.'_'.$config->defaultCountry; 72 }else{ 73 die("Syntax error in the defaultLocale parameter in Jelix config file $configFile !"); 74 }*/ 64 75 #else 65 76 $config = jIniFile::read(JELIX_LIB_CORE_PATH.'defaultconfig.ini.php'); … … 97 108 $config['urlengine']['basePath'] = $path; 98 109 } 110 111 /*if(preg_match("/^([a-zA-Z]{2})(?:_([a-zA-Z]{2}))?$/",$config['defaultLocale'],$m)){ 112 if(!isset($m[2])){ 113 $m[2] = $m[1]; 114 } 115 $config['defaultLang'] = strtolower($m[1]); 116 $config['defaultCountry'] = strtoupper($m[2]); 117 $config['defaultLocale'] = $config['defaultLang'].'_'.$config['defaultCountry']; 118 }else{ 119 die("Syntax error in the defaultLocale parameter in Jelix config file $configFile !"); 120 }*/ 99 121 #endif 100 122 trunk/lib/jelix/core/jConfigCompiler.class.php
r375 r444 62 62 $config->urlengine['basePath'] = $path; 63 63 } 64 65 /*if(preg_match("/^([a-zA-Z]{2})(?:_([a-zA-Z]{2}))?$/",$config->defaultLocale,$m)){ 66 if(!isset($m[2])){ 67 $m[2] = $m[1]; 68 } 69 $config->defaultLang = strtolower($m[1]); 70 $config->defaultCountry = strtoupper($m[2]); 71 $config->defaultLocale = $config->defaultLang.'_'.$config->defaultCountry; 72 }else{ 73 die("Syntax error in the defaultLocale parameter in Jelix config file $configFile !"); 74 }*/ 64 75 #else 65 76 $config = jIniFile::read(JELIX_LIB_CORE_PATH.'defaultconfig.ini.php'); … … 97 108 $config['urlengine']['basePath'] = $path; 98 109 } 110 111 /*if(preg_match("/^([a-zA-Z]{2})(?:_([a-zA-Z]{2}))?$/",$config['defaultLocale'],$m)){ 112 if(!isset($m[2])){ 113 $m[2] = $m[1]; 114 } 115 $config['defaultLang'] = strtolower($m[1]); 116 $config['defaultCountry'] = strtoupper($m[2]); 117 $config['defaultLocale'] = $config['defaultLang'].'_'.$config['defaultCountry']; 118 }else{ 119 die("Syntax error in the defaultLocale parameter in Jelix config file $configFile !"); 120 }*/ 99 121 #endif 100 122 trunk/lib/jelix/core/jSelector.class.php
r431 r444 474 474 if($isprofil){ 475 475 $p = jDb::getProfil($driver); 476 $this->driver= $p['driver']; 476 if($p['driver'] == 'pdo'){ 477 $this->driver=substr($p['dsn'],0,strpos($p['dsn'],':')); 478 }else{ 479 $this->driver= $p['driver']; 480 } 481 if($this->driver=='pgsql') 482 $this->driver='postgresql'; 477 483 }else{ 478 484 $this->driver=$driver; … … 537 543 /** 538 544 * @param string $sel the template selector 539 * @param string $outputtype the type of output (html, text..) By default, it take the response type545 * @param string $outputtype the type of output (html, text..) By default, it takes the response type 540 546 */ 541 547 function __construct($sel, $outputtype=''){ trunk/lib/jelix/core/jSelector.class.php
r431 r444 474 474 if($isprofil){ 475 475 $p = jDb::getProfil($driver); 476 $this->driver= $p['driver']; 476 if($p['driver'] == 'pdo'){ 477 $this->driver=substr($p['dsn'],0,strpos($p['dsn'],':')); 478 }else{ 479 $this->driver= $p['driver']; 480 } 481 if($this->driver=='pgsql') 482 $this->driver='postgresql'; 477 483 }else{ 478 484 $this->driver=$driver; … … 537 543 /** 538 544 * @param string $sel the template selector 539 * @param string $outputtype the type of output (html, text..) By default, it take the response type545 * @param string $outputtype the type of output (html, text..) By default, it takes the response type 540 546 */ 541 547 function __construct($sel, $outputtype=''){ trunk/lib/jelix/dao/jDaoCompiler.class.php
r386 r444 55 55 56 56 /** 57 * The d b driver name57 * The database type 58 58 * @var string 59 59 */ 60 static public $db Driver='';60 static public $dbType=''; 61 61 62 62 /** … … 67 67 jDaoCompiler::$daoId = $selector->toString(); 68 68 jDaoCompiler::$daoPath = $selector->getPath(); 69 jDaoCompiler::$db Driver= $selector->driver;69 jDaoCompiler::$dbType = $selector->driver; 70 70 71 71 // chargement du fichier XML trunk/lib/jelix/dao/jDaoCompiler.class.php
r386 r444 55 55 56 56 /** 57 * The d b driver name57 * The database type 58 58 * @var string 59 59 */ 60 static public $db Driver='';60 static public $dbType=''; 61 61 62 62 /** … … 67 67 jDaoCompiler::$daoId = $selector->toString(); 68 68 jDaoCompiler::$daoPath = $selector->getPath(); 69 jDaoCompiler::$db Driver= $selector->driver;69 jDaoCompiler::$dbType = $selector->driver; 70 70 71 71 // chargement du fichier XML trunk/lib/jelix/dao/jDaoGenerator.class.php
r404 r444 90 90 $pkFields = $this->_getPropertiesBy('PkFields'); 91 91 $pTableRealName = $tables[$this->_datasParser->getPrimaryTable()]['realname']; 92 $d riverName = jDaoCompiler::$dbDriver;92 $database = jDaoCompiler::$dbType; 93 93 $pkai = $this->_getAutoIncrementField(); 94 94 $sqlPkCondition = $this->_buildSimpleConditions($pkFields); … … 137 137 $src[] = '}else{'; 138 138 139 if (($d riverName=='mysql') || ($driverName=='sqlserver') || ($driverName=='postgresql')) {139 if (($database=='mysql') || ($database=='sqlserver') || ($database=='postgresql')) { 140 140 $fields = $this->_getPropertiesBy('PrimaryFieldsExcludeAutoIncrement'); 141 141 /*}elseif ($pkai->sequenceName != ''){ … … 166 166 if($pkai !== null){ 167 167 $src[] = ' if($result){'; 168 if ($driverName=='mysql') { 168 if ($database=='sqlserver') { 169 $src[] = ' if($record->'.$pkai->name.' < 1 ) $record->'.$pkai->name.'= $this->_conn->lastIdInTable(\''.$pkai->fieldName.'\',\''.$pTableRealName.'\');'; 170 }else if ($database=='postgresql') { 171 $src[] = ' if($record->'.$pkai->name.' < 1 ) $record->'.$pkai->name.'= $this->_conn->lastInsertId(\''.$pkai->sequenceName.'\');'; 172 }else{ 169 173 $src[] = ' if($record->'.$pkai->name.' < 1 ) $record->'.$pkai->name.'= $this->_conn->lastInsertId();'; 170 }else if ($driverName=='sqlserver') {171 $src[] = ' if($record->'.$pkai->name.' < 1 ) $record->'.$pkai->name.'= $this->_conn->lastIdInTable(\''.$pkai->fieldName.'\',\''.$pTableRealName.'\');';172 }else if ($driverName=='postgresql') {173 $src[] = ' if($record->'.$pkai->name.' < 1 ) $record->'.$pkai->name.'= $this->_conn->lastInsertId(\''.$pkai->sequenceName.'\');';174 174 } 175 175 $src[] = ' return $result;'; … … 346 346 private function _getFromClause(){ 347 347 348 $d riverName = jDaoCompiler::$dbDriver;349 $aliaslink = ($d riverName == 'oci8'?' ':' AS ');348 $database = jDaoCompiler::$dbType; 349 $aliaslink = ($database == 'oci8'?' ':' AS '); 350 350 351 351 $sqlWhere = ''; … … 367 367 368 368 $fieldjoin=''; 369 if ($d riverName == 'oci8') {369 if ($database == 'oci8') { 370 370 if($tablejoin[1] == 0){ 371 371 $operand='='; $opafter='(+)'; … … 416 416 $result = array(); 417 417 418 $d riverName = jDaoCompiler::$dbDriver;418 $database = jDaoCompiler::$dbType; 419 419 420 420 $tables = $this->_datasParser->getTables(); … … 425 425 if ($prop->selectMotif !=''){ 426 426 if ($prop->selectMotif =='%s'){ 427 if ($prop->fieldName != $prop->name || $d riverName == 'sqlite'){427 if ($prop->fieldName != $prop->name || $database == 'sqlite'){ 428 428 //in oracle we must escape name 429 if ($d riverName == 'oci8') {429 if ($database == 'oci8') { 430 430 $field = $table.$prop->fieldName.' "'.$prop->name.'"'; 431 431 }else{ … … 437 437 }else{ 438 438 //in oracle we must escape name 439 if ($d riverName == 'oci8') {439 if ($database == 'oci8') { 440 440 $field = sprintf ($prop->selectMotif, $table.$prop->fieldName).' "'.$prop->name.'"'; 441 441 }else{ … … 529 529 } 530 530 531 $d riverName = jDaoCompiler::$dbDriver;531 $database = jDaoCompiler::$dbType; 532 532 $tb = $this->_datasParser->getTables(); 533 533 $tb = $tb[$this->_datasParser->getPrimaryTable()]['realname']; … … 535 535 foreach ($using as $id=>$field) { 536 536 if ($field->datatype == 'autoincrement' || $field->datatype == 'bigautoincrement') { 537 if($d riverName=="postgresql" && !strlen($field->sequenceName)){537 if($database=="postgresql" && !strlen($field->sequenceName)){ 538 538 $field->sequenceName = $tb.'_'.$field->name.'_seq'; 539 539 } trunk/lib/jelix/dao/jDaoGenerator.class.php
r404 r444 90 90 $pkFields = $this->_getPropertiesBy('PkFields'); 91 91 $pTableRealName = $tables[$this->_datasParser->getPrimaryTable()]['realname']; 92 $d riverName = jDaoCompiler::$dbDriver;92 $database = jDaoCompiler::$dbType; 93 93 $pkai = $this->_getAutoIncrementField(); 94 94 $sqlPkCondition = $this->_buildSimpleConditions($pkFields); … … 137 137 $src[] = '}else{'; 138 138 139 if (($d riverName=='mysql') || ($driverName=='sqlserver') || ($driverName=='postgresql')) {139 if (($database=='mysql') || ($database=='sqlserver') || ($database=='postgresql')) { 140 140 $fields = $this->_getPropertiesBy('PrimaryFieldsExcludeAutoIncrement'); 141 141 /*}elseif ($pkai->sequenceName != ''){ … … 166 166 if($pkai !== null){ 167 167 $src[] = ' if($result){'; 168 if ($driverName=='mysql') { 168 if ($database=='sqlserver') { 169 $src[] = ' if($record->'.$pkai->name.' < 1 ) $record->'.$pkai->name.'= $this->_conn->lastIdInTable(\''.$pkai->fieldName.'\',\''.$pTableRealName.'\');'; 170 }else if ($database=='postgresql') { 171 $src[] = ' if($record->'.$pkai->name.' < 1 ) $record->'.$pkai->name.'= $this->_conn->lastInsertId(\''.$pkai->sequenceName.'\');'; 172 }else{ 169 173 $src[] = ' if($record->'.$pkai->name.' < 1 ) $record->'.$pkai->name.'= $this->_conn->lastInsertId();'; 170 }else if ($driverName=='sqlserver') {171 $src[] = ' if($record->'.$pkai->name.' < 1 ) $record->'.$pkai->name.'= $this->_conn->lastIdInTable(\''.$pkai->fieldName.'\',\''.$pTableRealName.'\');';172 }else if ($driverName=='postgresql') {173 $src[] = ' if($record->'.$pkai->name.' < 1 ) $record->'.$pkai->name.'= $this->_conn->lastInsertId(\''.$pkai->sequenceName.'\');';174 174 } 175 175 $src[] = ' return $result;'; … … 346 346 private function _getFromClause(){ 347 347 348 $d riverName = jDaoCompiler::$dbDriver;349 $aliaslink = ($d riverName == 'oci8'?' ':' AS ');348 $database = jDaoCompiler::$dbType; 349 $aliaslink = ($database == 'oci8'?' ':' AS '); 350 350 351 351 $sqlWhere = ''; … … 367 367 368 368 $fieldjoin=''; 369 if ($d riverName == 'oci8') {369 if ($database == 'oci8') { 370 370 if($tablejoin[1] == 0){ 371 371 $operand='='; $opafter='(+)'; … … 416 416 $result = array(); 417 417 418 $d riverName = jDaoCompiler::$dbDriver;418 $database = jDaoCompiler::$dbType; 419 419 420 420 $tables = $this->_datasParser->getTables(); … … 425 425 if ($prop->selectMotif !=''){ 426 426 if ($prop->selectMotif =='%s'){ 427 if ($prop->fieldName != $prop->name || $d riverName == 'sqlite'){427 if ($prop->fieldName != $prop->name || $database == 'sqlite'){ 428 428 //in oracle we must escape name 429 if ($d riverName == 'oci8') {429 if ($database == 'oci8') { 430 430 $field = $table.$prop->fieldName.' "'.$prop->name.'"'; 431 431 }else{ … … 437 437 }else{ 438 438 //in oracle we must escape name 439 if ($d riverName == 'oci8') {439 if ($database == 'oci8') { 440 440 $field = sprintf ($prop->selectMotif, $table.$prop->fieldName).' "'.$prop->name.'"'; 441 441 }else{ … … 529 529 } 530 530 531 $d riverName = jDaoCompiler::$dbDriver;531 $database = jDaoCompiler::$dbType; 532 532 $tb = $this->_datasParser->getTables(); 533 533 $tb = $tb[$this->_datasParser->getPrimaryTable()]['realname']; … … 535 535 foreach ($using as $id=>$field) { 536 536 if ($field->datatype == 'autoincrement' || $field->datatype == 'bigautoincrement') { 537 if($d riverName=="postgresql" && !strlen($field->sequenceName)){537 if($database=="postgresql" && !strlen($field->sequenceName)){ 538 538 $field->sequenceName = $tb.'_'.$field->name.'_seq'; 539 539 } trunk/lib/jelix/dao/jDaoParser.class.php
r404 r444 529 529 } 530 530 if (isset($attr['driver']) && !empty($attr['driver'])) { 531 if (jDaoCompiler::$db Driver!= $attr['driver']) {531 if (jDaoCompiler::$dbType != $attr['driver']) { 532 532 throw new jDaoXmlException ('method.condition.driver.notallowed', array($this->name, $op,$field_id)); 533 533 } … … 548 548 } 549 549 if (isset($attr['driver']) && !empty($attr['driver'])) { 550 if (jDaoCompiler::$db Driver!= $attr['driver']) {550 if (jDaoCompiler::$dbType != $attr['driver']) { 551 551 throw new jDaoXmlException ('method.condition.driver.notallowed', array($this->name, $op,$field_id)); 552 552 } trunk/lib/jelix/dao/jDaoParser.class.php
r404 r444 529 529 } 530 530 if (isset($attr['driver']) && !empty($attr['driver'])) { 531 if (jDaoCompiler::$db Driver!= $attr['driver']) {531 if (jDaoCompiler::$dbType != $attr['driver']) { 532 532 throw new jDaoXmlException ('method.condition.driver.notallowed', array($this->name, $op,$field_id)); 533 533 } … … 548 548 } 549 549 if (isset($attr['driver']) && !empty($attr['driver'])) { 550 if (jDaoCompiler::$db Driver!= $attr['driver']) {550 if (jDaoCompiler::$dbType != $attr['driver']) { 551 551 throw new jDaoXmlException ('method.condition.driver.notallowed', array($this->name, $op,$field_id)); 552 552 } trunk/lib/jelix/db/jDbPDOConnection.class.php
r386 r444 54 54 }else{ 55 55 return parent::fetchAll( JPDO_FETCH_OBJ); 56 }57 }58 59 /**60 * return next result in the resultset.61 * Arguments are ignored. JDb don't care about it (fetch always as classes or objects)62 * But there are here because of the compatibility of internal methods of PDOStatement63 * @param integer $fetch_style ignored64 * @param integer $cur_or ignored65 * @param integer $cur_offset ignored66 * @return array an object which contains datas of a row67 */68 public function fetch( $fetch_style= null, $cur_or=JPDO_FETCH_ORI_NEXT, $cur_offset=0 ){69 if($this->_fetchMode){70 return parent::fetch($this->_fetchMode, $cur_or, $cur_offset);71 }else{72 return parent::fetch(JPDO_FETCH_OBJ,$cur_or,$cur_offset);73 56 } 74 57 } … … 140 123 } 141 124 125 /** 126 * @internal the implementation of Iterator on PDOStatement doesn't call fetch method of classes which inherit of PDOStatement 127 * so, we cannot indicate to fetch object directly in jDbPDOResultSet::fetch(). So we overload query() to do it. 128 */ 129 public function query(){ 130 $args=func_get_args(); 131 switch(count($args)){ 132 case 1: 133 $rs = parent::query($args[0]); 134 $rs->setFetchMode(JPDO_FETCH_OBJ); 135 return $rs; 136 break; 137 case 2: 138 return parent::query($args[0], $args[1]); 139 break; 140 case 3: 141 return parent::query($args[0], $args[1]); 142 break; 143 default: 144 trigger_error('bad argument number in query',E_USER_ERROR); 145 } 146 147 } 148 149 142 150 public function limitQuery ($queryString, $limitOffset = null, $limitCount = null){ 143 151 if ($limitOffset !== null && $limitCount !== null){ trunk/lib/jelix/db/jDbPDOConnection.class.php
r386 r444 54 54 }else{ 55 55 return parent::fetchAll( JPDO_FETCH_OBJ); 56 }57 }58 59 /**60 * return next result in the resultset.61 * Arguments are ignored. JDb don't care about it (fetch always as classes or objects)62 * But there are here because of the compatibility of internal methods of PDOStatement63 * @param integer $fetch_style ignored64 * @param integer $cur_or ignored65 * @param integer $cur_offset ignored66 * @return array an object which contains datas of a row67 */68 public function fetch( $fetch_style= null, $cur_or=JPDO_FETCH_ORI_NEXT, $cur_offset=0 ){69 if($this->_fetchMode){70 return parent::fetch($this->_fetchMode, $cur_or, $cur_offset);71 }else{72 return parent::fetch(JPDO_FETCH_OBJ,$cur_or,$cur_offset);73 56 } 74 57 } … … 140 123 } 141 124 125 /** 126 * @internal the implementation of Iterator on PDOStatement doesn't call fetch method of classes which inherit of PDOStatement 127 * so, we cannot indicate to fetch object directly in jDbPDOResultSet::fetch(). So we overload query() to do it. 128 */ 129 public function query(){ 130 $args=func_get_args(); 131 switch(count($args)){ 132 case 1: 133 $rs = parent::query($args[0]); 134 $rs->setFetchMode(JPDO_FETCH_OBJ); 135 return $rs; 136 break; 137 case 2: 138 return parent::query($args[0], $args[1]); 139 break; 140 case 3: 141 return parent::query($args[0], $args[1]); 142 break; 143 default: 144 trigger_error('bad argument number in query',E_USER_ERROR); 145 } 146 147 } 148 149 142 150 public function limitQuery ($queryString, $limitOffset = null, $limitCount = null){ 143 151 if ($limitOffset !== null && $limitCount !== null){ trunk/lib/simpletest/compatibility.php
r289 r444 175 175 * @static 176 176 */ 177 function getStackTrace() {177 static function getStackTrace() { 178 178 if (function_exists('debug_backtrace')) { 179 179 return array_reverse(debug_backtrace()); trunk/lib/simpletest/compatibility.php
r289 r444 175 175 * @static 176 176 */ 177 function getStackTrace() {177 static function getStackTrace() { 178 178 if (function_exists('debug_backtrace')) { 179 179 return array_reverse(debug_backtrace()); trunk/testapp/modules/testapp/install/base.mysql.sql
r132 r444 12 12 INSERT INTO myconfig VALUES ('engine', 'jelix'); 13 13 INSERT INTO myconfig VALUES ('browser', 'firefox'); 14 15 16 CREATE TABLE `product_test` ( 17 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , 18 `name` VARCHAR( 150 ) NOT NULL , 19 `price` FLOAT NOT NULL 20 ) TYPE = MYISAM ; trunk/testapp/modules/testapp/install/base.mysql.sql
r132 r444 12 12 INSERT INTO myconfig VALUES ('engine', 'jelix'); 13 13 INSERT INTO myconfig VALUES ('browser', 'firefox'); 14 15 16 CREATE TABLE `product_test` ( 17 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , 18 `name` VARCHAR( 150 ) NOT NULL , 19 `price` FLOAT NOT NULL 20 ) TYPE = MYISAM ; trunk/testapp/modules/unittest/classes/junittestcase.class.php
r399 r444 11 11 12 12 class jUnitTestCase extends UnitTestCase { 13 14 // for database management 15 16 protected $dbProfil =''; 17 protected $needPDO = false; 18 19 function run(&$reporter) { 20 SimpleTest::setCurrent($this); 21 $this->_reporter = &$reporter; 22 $this->_reporter->paintCaseStart($this->getLabel()); 23 if($this->needPDO){ 24 $this->_reporter->makeDry(!$this->assertTrue(class_exists('PDO',false), 'PDO does not exists ! Test cannot run')); 25 } 26 foreach ($this->getTests() as $method) { 27 if ($this->_reporter->shouldInvoke($this->getLabel(), $method)) { 28 $invoker = &$this->_reporter->createInvoker($this->createInvoker()); 29 $invoker->before($method); 30 $invoker->invoke($method); 31 $invoker->after($method); 32 } 33 } 34 $this->_reporter->paintCaseEnd($this->getLabel()); 35 unset($this->_reporter); 36 return $reporter->getStatus(); 37 } 38 13 39 14 40 /** trunk/testapp/modules/unittest/classes/junittestcase.class.php
r399 r444 11 11 12 12 class jUnitTestCase extends UnitTestCase { 13 14 // for database management 15 16 protected $dbProfil =''; 17 protected $needPDO = false; 18 19 function run(&$reporter) { 20 SimpleTest::setCurrent($this); 21 $this->_reporter = &$reporter; 22 $this->_reporter->paintCaseStart($this->getLabel()); 23 if($this->needPDO){ 24 $this->_reporter->makeDry(!$this->assertTrue(class_exists('PDO',false), 'PDO does not exists ! Test cannot run')); 25 } 26 foreach ($this->getTests() as $method) { 27 if ($this->_reporter->shouldInvoke($this->getLabel(), $method)) { 28 $invoker = &$this->_reporter->createInvoker($this->createInvoker()); 29 $invoker->before($method); 30 $invoker->invoke($method); 31 $invoker->after($method); 32 } 33 } 34 $this->_reporter->paintCaseEnd($this->getLabel()); 35 unset($this->_reporter); 36 return $reporter->getStatus(); 37 } 38 13 39 14 40 /** trunk/testapp/modules/unittest/classes/junittestcasedb.class.php
r412 r444 12 12 13 13 class jUnitTestCaseDb extends jUnitTestCase { 14 15 // for database management16 17 protected $dbProfil ='';18 14 19 15 /** … … 84 80 } 85 81 86 82 /** 83 * check if a table has a specific number of records 84 */ 87 85 function assertTableHasNRecords($table, $n, $message="%s"){ 88 86 $db = jDb::getConnection($this->dbProfil); … … 102 100 } 103 101 } 104 105 106 102 107 103 /** … … 123 119 $results[]=get_object_vars($r); 124 120 } 125 $dumper = new SimpleDumper(); 121 126 122 $globalok=true; 127 123 $resultsSaved = $results; … … 137 133 if(!$ok){ 138 134 $globalok = false; 139 $this->fail($message.'. No t found record : '. var_export($rec,true));135 $this->fail($message.'. No record found : '. var_export($rec,true)); 140 136 } 141 137 } trunk/testapp/modules/unittest/classes/junittestcasedb.class.php
r412 r444 12 12 13 13 class jUnitTestCaseDb extends jUnitTestCase { 14 15 // for database management16 17 protected $dbProfil ='';18 14 19 15 /** … … 84 80 } 85 81 86 82 /** 83 * check if a table has a specific number of records 84 */ 87 85 function assertTableHasNRecords($table, $n, $message="%s"){ 88 86 $db = jDb::getConnection($this->dbProfil); … … 102 100 } 103 101 } 104 105 106 102 107 103 /** … … 123 119 $results[]=get_object_vars($r); 124 120 } 125 $dumper = new SimpleDumper(); 121 126 122 $globalok=true; 127 123 $resultsSaved = $results; … … 137 133 if(!$ok){ 138 134 $globalok = false; 139 $this->fail($message.'. No t found record : '. var_export($rec,true));135 $this->fail($message.'. No record found : '. var_export($rec,true)); 140 136 } 141 137 } trunk/testapp/modules/unittest/classes/unittestservice.class.php
r409 r444 12 12 require_once(LIB_PATH.'/simpletest/unit_tester.php'); 13 13 require_once(dirname(__FILE__).'/jhtmlrespreporter.class.php'); 14 15 16 14 17 15 class UnitTestService { … … 56 54 57 55 function daoParserTest(){ 58 $test = jClasses::create("utdao ");56 $test = jClasses::create("utdao_parser"); 59 57 $test->run(new jHtmlRespReporter($this->_rep)); 60 58 } 61 59 62 60 function daoParser2Test(){ 63  
