- Timestamp:
- 10/30/08 01:43:41 (2 years ago)
- Files:
-
- fActiveRecord.php (modified) (1 diff)
- fNoRowsException.php (moved) (moved from fNoResultsException.php) (2 diffs, 1 prop)
- fORMColumn.php (modified) (1 diff)
- fORMRelated.php (modified) (1 diff)
- fORMValidation.php (modified) (5 diffs)
- fResult.php (modified) (12 diffs)
- fSchema.php (modified) (2 diffs)
- fUnbufferedResult.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
fActiveRecord.php
r334 r348 Hide Line Numbers 934 934 935 935 $result = fORMDatabase::retrieve()->translatedQuery($sql); 936 $result->tossIfNoR esults();936 $result->tossIfNoRows(); 937 937 938 938 } catch (fExpectedException $e) { fNoRowsException.php
- Property svn:mergeinfo set
r214 r348 Hide Line Numbers 1 1 <?php 2 2 /** 3 * An exception when no r esults are returned3 * An exception when no rows are returned from a SQL query 4 4 * 5 5 * @copyright Copyright (c) 2007-2008 William Bond … … 8 8 * 9 9 * @package Flourish 10 * @link http://flourishlib.com/fNoR esultsException10 * @link http://flourishlib.com/fNoRowsException 11 11 * 12 12 * @version 1.0.0b 13 13 * @changes 1.0.0b The initial implementation [wb, 2007-06-14] 14 14 */ 15 class fNoR esultsException extends fExpectedException15 class fNoRowsException extends fExpectedException 16 16 { 17 17 } fORMColumn.php
r331 r348 Hide Line Numbers 649 649 $sql = "SELECT " . $column . " FROM " . $table . " WHERE " . $column . " = " . fORMDatabase::retrieve()->escape('string', $value); 650 650 651 } while (fORMDatabase::retrieve()->query($sql)-> getReturnedRows());651 } while (fORMDatabase::retrieve()->query($sql)->countReturnedRows()); 652 652 } 653 653 } fORMRelated.php
r316 r348 Hide Line Numbers 172 172 $result = fORMDatabase::retrieve()->translatedQuery($sql); 173 173 174 $count = ($result-> getReturnedRows()) ? (int) $result->fetchScalar() : 0;174 $count = ($result->valid()) ? (int) $result->fetchScalar() : 0; 175 175 } 176 176 fORMValidation.php
r332 r348 Hide Line Numbers 398 398 399 399 $result = fORMDatabase::retrieve()->translatedQuery($sql); 400 $result->tossIfNoR esults();401 } catch (fNoR esultsException $e) {400 $result->tossIfNoRows(); 401 } catch (fNoRowsException $e) { 402 402 return fGrammar::compose( 403 403 '%s: The value specified is invalid', … … 534 534 535 535 $result = fORMDatabase::retrieve()->translatedQuery($sql); 536 $result->tossIfNoR esults();536 $result->tossIfNoRows(); 537 537 538 538 return fGrammar::compose( … … 542 542 ); 543 543 544 } catch (fNoR esultsException $e) { }544 } catch (fNoRowsException $e) { } 545 545 } 546 546 … … 622 622 try { 623 623 $result = fORMDatabase::retrieve()->translatedQuery($sql); 624 $result->tossIfNoR esults();624 $result->tossIfNoRows(); 625 625 626 626 // If an exception was not throw, we have existing values … … 641 641 } 642 642 643 } catch (fNoR esultsException $e) { }643 } catch (fNoRowsException $e) { } 644 644 } 645 645 } fResult.php
r347 r348 Hide Line Numbers 226 226 227 227 /** 228 * Returns the number of rows affected by the query 229 * 230 * @return integer The number of rows affected by the query 231 */ 232 public function countAffectedRows() 233 { 234 return $this->affected_rows; 235 } 236 237 238 /** 239 * Returns the number of rows returned by the query 240 * 241 * @return integer The number of rows returned by the query 242 */ 243 public function countReturnedRows() 244 { 245 return $this->returned_rows; 246 } 247 248 249 /** 228 250 * Returns the current row in the result set (required by iterator interface) 229 251 * 230 * @throws fNoR esultsException252 * @throws fNoRowsException 231 253 * @throws fNoRemainingException 232 254 * @internal … … 238 260 if(!$this->returned_rows) { 239 261 fCore::toss( 240 'fNoR esultsException',262 'fNoRowsException', 241 263 fGrammar::compose('The query did not return any rows') 242 264 ); … … 309 331 * Returns the row next row in the result set (where the pointer is currently assigned to) 310 332 * 311 * @throws fNoR esultsException333 * @throws fNoRowsException 312 334 * @throws fNoRemainingException 313 335 * … … 325 347 * Wraps around ::fetchRow() and returns the first field from the row instead of the whole row 326 348 * 327 * @throws fNoR esultsException349 * @throws fNoRowsException 328 350 * @throws fNoRemainingException 329 351 * … … 404 426 405 427 /** 406 * Returns the number of rows affected by the query407 *408 * @return integer The number of rows affected by the query409 */410 public function getAffectedRows()411 {412 return $this->affected_rows;413 }414 415 416 /**417 428 * Returns the last auto incremented value for this database connection. This may or may not be from the current query. 418 429 * … … 439 450 440 451 /** 441 * Returns the number of rows returned by the query442 *443 * @return integer The number of rows returned by the query444 */445 public function getReturnedRows()446 {447 return $this->returned_rows;448 }449 450 451 /**452 452 * Returns the SQL used in the query 453 453 * … … 474 474 * Returns the current row number (required by iterator interface) 475 475 * 476 * @throws fNoR esultsException476 * @throws fNoRowsException 477 477 * @internal 478 478 * … … 492 492 * Advances to the next row in the result (required by iterator interface) 493 493 * 494 * @throws fNoR esultsException494 * @throws fNoRowsException 495 495 * @internal 496 496 * … … 531 531 * Seeks to the specified zero-based row for the specified SQL query 532 532 * 533 * @throws fNoR esultsException533 * @throws fNoRowsException 534 534 * 535 535 * @param integer $row The row number to seek to (zero-based) … … 540 540 if(!$this->returned_rows) { 541 541 fCore::toss( 542 'fNoR esultsException',542 'fNoRowsException', 543 543 fGrammar::compose('The query did not return any rows') 544 544 ); … … 673 673 * Throws an fNoResultException if the query did not return any rows 674 674 * 675 * @throws fNoR esultsException675 * @throws fNoRowsException 676 676 * 677 677 * @param string $message The message to use for the exception if there are no rows in this result set 678 678 * @return void 679 679 */ 680 public function tossIfNoR esults($message=NULL)680 public function tossIfNoRows($message=NULL) 681 681 { 682 682 if (!$this->returned_rows && !$this->affected_rows) { … … 684 684 $message = fGrammar::compose('No rows were returned or affected by the query'); 685 685 } 686 fCore::toss('fNoR esultsException', $message);686 fCore::toss('fNoRowsException', $message); 687 687 } 688 688 } fSchema.php
r339 r348 Hide Line Numbers 543 543 $row = $result->fetchRow(); 544 544 $create_sql = $row['Create Table']; 545 } catch (fNoR esultsException $e) {545 } catch (fNoRowsException $e) { 546 546 return array(); 547 547 } … … 1014 1014 $row = $result->fetchRow(); 1015 1015 $create_sql = $row['sql']; 1016 } catch (fNoR esultsException $e) {1016 } catch (fNoRowsException $e) { 1017 1017 return array(); 1018 1018 } fUnbufferedResult.php
r347 r348 Hide Line Numbers 218 218 * Returns the current row in the result set (required by iterator interface) 219 219 * 220 * @throws fNoR esultsException220 * @throws fNoRowsException 221 221 * @throws fNoRemainingException 222 222 * @internal … … 234 234 if(!$this->current_row && $this->pointer == 0) { 235 235 fCore::toss( 236 'fNoR esultsException',236 'fNoRowsException', 237 237 fGrammar::compose('The query did not return any rows') 238 238 ); … … 281 281 * Returns the row next row in the result set (where the pointer is currently assigned to) 282 282 * 283 * @throws fNoR esultsException283 * @throws fNoRowsException 284 284 * @throws fNoRemainingException 285 285 * … … 398 398 * Returns the current row number (required by iterator interface) 399 399 * 400 * @throws fNoR esultsException400 * @throws fNoRowsException 401 401 * @internal 402 402 * … … 416 416 * Advances to the next row in the result (required by iterator interface) 417 417 * 418 * @throws fNoR esultsException418 * @throws fNoRowsException 419 419 * @internal 420 420 * … … 497 497 * Throws an fNoResultException if the query did not return any rows 498 498 * 499 * @throws fNoR esultsException499 * @throws fNoRowsException 500 500 * 501 501 * @param string $message The message to use for the exception if there are no rows in this result set 502 502 * @return void 503 503 */ 504 public function tossIfNoR esults($message=NULL)504 public function tossIfNoRows($message=NULL) 505 505 { 506 506 try { 507 507 $this->current(); 508 } catch (fNoR esultsException $e) {508 } catch (fNoRowsException $e) { 509 509 if ($message !== NULL) { 510 510 $e->getMessage($message);
