Changeset 295
- Timestamp:
- 07/28/07 20:44:07 (1 year ago)
- Files:
-
- trunk/config/boot.php (modified) (1 diff)
- trunk/lib/AkActiveRecord.php (modified) (3 diffs)
- trunk/test/fixtures/app/installers/picture_installer.php (modified) (1 diff)
- trunk/test/fixtures/app/installers/tag_installer.php (modified) (1 diff)
- trunk/test/unit/lib/AkActiveRecord/AkBelongsTo.php (modified) (2 diffs)
- trunk/test/unit/lib/AkActiveRecord/_AkActiveRecord_type_casting.php (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/config/boot.php
r290 r295 126 126 127 127 defined('AK_PROTOCOL') ? null : define('AK_PROTOCOL',isset($_SERVER['HTTPS']) ? 'https://' : 'http://'); 128 defined('AK_HOST') ? null : define('AK_HOST', $_SERVER['SERVER_NAME'] == 'localhost' ? $_SERVER['SERVER_ADDR'] : $_SERVER['SERVER_NAME']); 128 defined('AK_HOST') ? null : define('AK_HOST', $_SERVER['SERVER_NAME'] == 'localhost' ? 129 // Will force to IP4 for localhost until IP6 is supported by helpers 130 ($_SERVER['SERVER_ADDR'] == '::1' ? '127.0.0.1' : $_SERVER['SERVER_ADDR']) : 131 $_SERVER['SERVER_NAME']); 129 132 defined('AK_REMOTE_IP') ? null : define('AK_REMOTE_IP',(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']); 130 133 trunk/lib/AkActiveRecord.php
r289 r295 3262 3262 case 'serial': 3263 3263 case 'integer': 3264 $value = is_null($value) ? null : (integer)$value; 3264 3265 case 'float': 3265 $result = (empty($value) && @$value !== 0) ? 'null' : (is_numeric($value) ? $value : $this->_db->qstr($value));3266 $result = (empty($value) && $value !== 0) ? 'null' : (is_numeric($value) ? $value : $this->_db->qstr($value)); 3266 3267 $result = !empty($this->_columns[$column_name]['notNull']) && $result == 'null' && $this->_getDatabaseType() == 'sqlite' ? '0' : $result; 3267 3268 break; … … 3280 3281 $column_type = $this->getColumnType($column_name); 3281 3282 if($column_type){ 3282 if(!empty($value) && 'date' == $column_type && strstr(trim($value),' ')){ 3283 if('integer' == $column_type){ 3284 return is_null($value) ? null : (integer)$value; 3285 }elseif('boolean' == $column_type){ 3286 return (integer)$value === 1 ? true : false; 3287 }elseif(!empty($value) && 'date' == $column_type && strstr(trim($value),' ')){ 3283 3288 return substr($value,0,10) == '0000-00-00' ? null : str_replace(substr($value,strpos($value,' ')), '', $value); 3284 3289 }elseif (!empty($value) && 'datetime' == $column_type && substr($value,0,10) == '0000-00-00'){ … … 3286 3291 }elseif ('binary' == $column_type && $this->_getDatabaseType() == 'postgre'){ 3287 3292 return $this->_db->BlobDecode($value); 3288 }elseif('boolean' == $column_type){3289 return (integer)$value === 1 ? true : false;3290 3293 } 3291 3294 } trunk/test/fixtures/app/installers/picture_installer.php
r2 r295 7 7 $this->createTable('pictures', ' 8 8 id integer max=10 auto increment primary, 9 property_id integer,9 property_id, 10 10 title string limit=200' 11 11 ); trunk/test/fixtures/app/installers/tag_installer.php
r55 r295 7 7 $this->createTable('tags', ' 8 8 id integer max=10 auto increment primary, 9 score int default 100, 9 10 name string 50' 10 11 ); trunk/test/unit/lib/AkActiveRecord/AkBelongsTo.php
r217 r295 77 77 $this->assertFalse($Picture->main_thumbnail->isNewRecord()); 78 78 79 $CeBitPic = $Picture->findFirstBy('title:has','CeBIT', array('include'=>'main_thumbnail'));79 $CeBitPic =& $Picture->findFirstBy('title:has','CeBIT', array('include'=>'main_thumbnail')); 80 80 81 81 $this->assertEqual($CeBitPic->title, 'The Akelos Media Team at CeBIT'); … … 162 162 $this->assertEqual($Thumbnail->picture->getType(), 'belongsTo'); 163 163 164 $Thumbnail = $Thumbnail->findFirstBy('caption:has','Lucky'); 165 166 // Its necesary to call loadAssociations after a finder in order to keep reference integrity 167 $Thumbnail->loadAssociations(); 168 169 $this->assertReference($Thumbnail->belongsTo->load('picture'), $Thumbnail->picture); 164 $Thumbnail =& $Thumbnail->findFirstBy('caption:has','Lucky', array('include'=>'picture')); 170 165 171 166 $this->assertEqual($Thumbnail->picture->getType(), 'Picture');
