- Timestamp:
- 2013/08/02 13:22:57 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_13-dev/data/module/MDB2/Driver/Manager/Common.php
r20764 r23022 44 44 // +----------------------------------------------------------------------+ 45 45 // 46 // $Id: Common.php ,v 1.72 2009/01/14 15:00:40 quipo Exp$46 // $Id: Common.php 327310 2012-08-27 15:16:18Z danielc $ 47 47 // 48 48 … … 109 109 function getFieldDeclarationList($fields) 110 110 { 111 $db = &$this->getDBInstance();112 if ( PEAR::isError($db)) {111 $db = $this->getDBInstance(); 112 if (MDB2::isError($db)) { 113 113 return $db; 114 114 } … … 120 120 foreach ($fields as $field_name => $field) { 121 121 $query = $db->getDeclaration($field['type'], $field_name, $field); 122 if ( PEAR::isError($query)) {122 if (MDB2::isError($query)) { 123 123 return $query; 124 124 } … … 141 141 function _fixSequenceName($sqn, $check = false) 142 142 { 143 $db = &$this->getDBInstance();144 if ( PEAR::isError($db)) {143 $db = $this->getDBInstance(); 144 if (MDB2::isError($db)) { 145 145 return $db; 146 146 } … … 169 169 function _fixIndexName($idx) 170 170 { 171 $db = &$this->getDBInstance();172 if ( PEAR::isError($db)) {171 $db = $this->getDBInstance(); 172 if (MDB2::isError($db)) { 173 173 return $db; 174 174 } … … 196 196 function createDatabase($database, $options = array()) 197 197 { 198 $db = &$this->getDBInstance();199 if ( PEAR::isError($db)) {198 $db = $this->getDBInstance(); 199 if (MDB2::isError($db)) { 200 200 return $db; 201 201 } … … 219 219 function alterDatabase($database, $options = array()) 220 220 { 221 $db = &$this->getDBInstance();222 if ( PEAR::isError($db)) {221 $db = $this->getDBInstance(); 222 if (MDB2::isError($db)) { 223 223 return $db; 224 224 } … … 240 240 function dropDatabase($database) 241 241 { 242 $db = &$this->getDBInstance();243 if ( PEAR::isError($db)) {242 $db = $this->getDBInstance(); 243 if (MDB2::isError($db)) { 244 244 return $db; 245 245 } … … 264 264 function _getCreateTableQuery($name, $fields, $options = array()) 265 265 { 266 $db = &$this->getDBInstance();267 if ( PEAR::isError($db)) {266 $db = $this->getDBInstance(); 267 if (MDB2::isError($db)) { 268 268 return $db; 269 269 } … … 278 278 } 279 279 $query_fields = $this->getFieldDeclarationList($fields); 280 if ( PEAR::isError($query_fields)) {280 if (MDB2::isError($query_fields)) { 281 281 return $query_fields; 282 282 } … … 354 354 { 355 355 $query = $this->_getCreateTableQuery($name, $fields, $options); 356 if ( PEAR::isError($query)) {356 if (MDB2::isError($query)) { 357 357 return $query; 358 358 } 359 $db = &$this->getDBInstance();360 if ( PEAR::isError($db)) {359 $db = $this->getDBInstance(); 360 if (MDB2::isError($db)) { 361 361 return $db; 362 362 } 363 363 $result = $db->exec($query); 364 if ( PEAR::isError($result)) {364 if (MDB2::isError($result)) { 365 365 return $result; 366 366 } … … 380 380 function dropTable($name) 381 381 { 382 $db = &$this->getDBInstance();383 if ( PEAR::isError($db)) {382 $db = $this->getDBInstance(); 383 if (MDB2::isError($db)) { 384 384 return $db; 385 385 } 386 386 387 387 $name = $db->quoteIdentifier($name, true); 388 return $db->exec("DROP TABLE $name"); 388 $result = $db->exec("DROP TABLE $name"); 389 if (MDB2::isError($result)) { 390 return $result; 391 } 392 return MDB2_OK; 389 393 } 390 394 … … 402 406 function truncateTable($name) 403 407 { 404 $db = &$this->getDBInstance();405 if ( PEAR::isError($db)) {408 $db = $this->getDBInstance(); 409 if (MDB2::isError($db)) { 406 410 return $db; 407 411 } 408 412 409 413 $name = $db->quoteIdentifier($name, true); 410 return $db->exec("DELETE FROM $name"); 414 $result = $db->exec("DELETE FROM $name"); 415 if (MDB2::isError($result)) { 416 return $result; 417 } 418 return MDB2_OK; 411 419 } 412 420 … … 430 438 function vacuum($table = null, $options = array()) 431 439 { 432 $db = &$this->getDBInstance();433 if ( PEAR::isError($db)) {440 $db = $this->getDBInstance(); 441 if (MDB2::isError($db)) { 434 442 return $db; 435 443 } … … 534 542 function alterTable($name, $changes, $check) 535 543 { 536 $db = &$this->getDBInstance();537 if ( PEAR::isError($db)) {544 $db = $this->getDBInstance(); 545 if (MDB2::isError($db)) { 538 546 return $db; 539 547 } … … 554 562 function listDatabases() 555 563 { 556 $db = &$this->getDBInstance();557 if ( PEAR::isError($db)) {564 $db = $this->getDBInstance(); 565 if (MDB2::isError($db)) { 558 566 return $db; 559 567 } … … 574 582 function listUsers() 575 583 { 576 $db = &$this->getDBInstance();577 if ( PEAR::isError($db)) {584 $db = $this->getDBInstance(); 585 if (MDB2::isError($db)) { 578 586 return $db; 579 587 } … … 597 605 function listViews($database = null) 598 606 { 599 $db = &$this->getDBInstance();600 if ( PEAR::isError($db)) {607 $db = $this->getDBInstance(); 608 if (MDB2::isError($db)) { 601 609 return $db; 602 610 } … … 618 626 function listTableViews($table) 619 627 { 620 $db = &$this->getDBInstance();621 if ( PEAR::isError($db)) {628 $db = $this->getDBInstance(); 629 if (MDB2::isError($db)) { 622 630 return $db; 623 631 } … … 639 647 function listTableTriggers($table = null) 640 648 { 641 $db = &$this->getDBInstance();642 if ( PEAR::isError($db)) {649 $db = $this->getDBInstance(); 650 if (MDB2::isError($db)) { 643 651 return $db; 644 652 } … … 659 667 function listFunctions() 660 668 { 661 $db = &$this->getDBInstance();662 if ( PEAR::isError($db)) {669 $db = $this->getDBInstance(); 670 if (MDB2::isError($db)) { 663 671 return $db; 664 672 } … … 682 690 function listTables($database = null) 683 691 { 684 $db = &$this->getDBInstance();685 if ( PEAR::isError($db)) {692 $db = $this->getDBInstance(); 693 if (MDB2::isError($db)) { 686 694 return $db; 687 695 } … … 703 711 function listTableFields($table) 704 712 { 705 $db = &$this->getDBInstance();706 if ( PEAR::isError($db)) {713 $db = $this->getDBInstance(); 714 if (MDB2::isError($db)) { 707 715 return $db; 708 716 } … … 749 757 function createIndex($table, $name, $definition) 750 758 { 751 $db = &$this->getDBInstance();752 if ( PEAR::isError($db)) {759 $db = $this->getDBInstance(); 760 if (MDB2::isError($db)) { 753 761 return $db; 754 762 } … … 762 770 } 763 771 $query .= ' ('. implode(', ', $fields) . ')'; 764 return $db->exec($query); 772 $result = $db->exec($query); 773 if (MDB2::isError($result)) { 774 return $result; 775 } 776 return MDB2_OK; 765 777 } 766 778 … … 778 790 function dropIndex($table, $name) 779 791 { 780 $db = &$this->getDBInstance();781 if ( PEAR::isError($db)) {792 $db = $this->getDBInstance(); 793 if (MDB2::isError($db)) { 782 794 return $db; 783 795 } 784 796 785 797 $name = $db->quoteIdentifier($db->getIndexName($name), true); 786 return $db->exec("DROP INDEX $name"); 798 $result = $db->exec("DROP INDEX $name"); 799 if (MDB2::isError($result)) { 800 return $result; 801 } 802 return MDB2_OK; 787 803 } 788 804 … … 799 815 function listTableIndexes($table) 800 816 { 801 $db = &$this->getDBInstance();802 if ( PEAR::isError($db)) {817 $db = $this->getDBInstance(); 818 if (MDB2::isError($db)) { 803 819 return $db; 804 820 } … … 868 884 function createConstraint($table, $name, $definition) 869 885 { 870 $db = &$this->getDBInstance();871 if ( PEAR::isError($db)) {886 $db = $this->getDBInstance(); 887 if (MDB2::isError($db)) { 872 888 return $db; 873 889 } … … 896 912 $query .= $this->_getAdvancedFKOptions($definition); 897 913 } 898 return $db->exec($query); 914 $result = $db->exec($query); 915 if (MDB2::isError($result)) { 916 return $result; 917 } 918 return MDB2_OK; 899 919 } 900 920 … … 913 933 function dropConstraint($table, $name, $primary = false) 914 934 { 915 $db = &$this->getDBInstance();916 if ( PEAR::isError($db)) {935 $db = $this->getDBInstance(); 936 if (MDB2::isError($db)) { 917 937 return $db; 918 938 } … … 920 940 $table = $db->quoteIdentifier($table, true); 921 941 $name = $db->quoteIdentifier($db->getIndexName($name), true); 922 return $db->exec("ALTER TABLE $table DROP CONSTRAINT $name"); 942 $result = $db->exec("ALTER TABLE $table DROP CONSTRAINT $name"); 943 if (MDB2::isError($result)) { 944 return $result; 945 } 946 return MDB2_OK; 923 947 } 924 948 … … 935 959 function listTableConstraints($table) 936 960 { 937 $db = &$this->getDBInstance();938 if ( PEAR::isError($db)) {961 $db = $this->getDBInstance(); 962 if (MDB2::isError($db)) { 939 963 return $db; 940 964 } … … 957 981 function createSequence($seq_name, $start = 1) 958 982 { 959 $db = &$this->getDBInstance();960 if ( PEAR::isError($db)) {983 $db = $this->getDBInstance(); 984 if (MDB2::isError($db)) { 961 985 return $db; 962 986 } … … 978 1002 function dropSequence($name) 979 1003 { 980 $db = &$this->getDBInstance();981 if ( PEAR::isError($db)) {1004 $db = $this->getDBInstance(); 1005 if (MDB2::isError($db)) { 982 1006 return $db; 983 1007 } … … 1001 1025 function listSequences($database = null) 1002 1026 { 1003 $db = &$this->getDBInstance();1004 if ( PEAR::isError($db)) {1027 $db = $this->getDBInstance(); 1028 if (MDB2::isError($db)) { 1005 1029 return $db; 1006 1030 }
Note: See TracChangeset
for help on using the changeset viewer.
