Changeset 27072 for trunk/src/wp-includes/wp-db.php
- Timestamp:
- 02/02/2014 09:38:34 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/wp-db.php
r27056 r27072 511 511 512 512 /** 513 * A list of incompatible SQL modes. 514 * 515 * @since 3.9.0 516 * @access protected 517 * @var array 518 */ 519 protected $incompatible_modes = array( 'NO_ZERO_DATE', 'ONLY_FULL_GROUP_BY', 520 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'TRADITIONAL' ); 521 522 /** 513 523 * Connects to the database server and selects a database 514 524 * … … 647 657 } 648 658 } 659 } 660 661 /** 662 * Change the current SQL mode, and ensure its WordPress compatibility. 663 * 664 * If no modes are passed, it will ensure the current MySQL server 665 * modes are compatible. 666 * 667 * @since 3.9.0 668 * 669 * @param array $modes Optional. A list of SQL modes to set. 670 */ 671 function set_sql_mode( $modes = array() ) { 672 if ( empty( $modes ) ) { 673 $res = mysql_query( 'SELECT @@SESSION.sql_mode;', $this->dbh ); 674 if ( empty( $res ) ) { 675 return; 676 } 677 678 $modes_str = mysql_result( $res, 0 ); 679 680 if ( empty( $modes_str ) ) { 681 return; 682 } 683 684 $modes = explode( ',', $modes_str ); 685 } 686 687 $modes = array_change_key_case( $modes, CASE_UPPER ); 688 689 /** 690 * Filter the list of incompatible SQL modes to exclude. 691 * 692 * @since 3.9.0 693 * 694 * @see wpdb::$incompatible_modes 695 * 696 * @param array $incompatible_modes An array of incompatible modes 697 */ 698 $incompatible_modes = (array) apply_filters( 'incompatible_sql_modes', $this->incompatible_modes ); 699 700 foreach( $modes as $i => $mode ) { 701 if ( in_array( $mode, $incompatible_modes ) ) { 702 unset( $modes[ $i ] ); 703 } 704 } 705 706 $modes_str = implode( ',', $modes ); 707 708 mysql_query( "SET SESSION sql_mode='$modes_str';", $this->dbh ); 649 709 } 650 710 … … 1177 1237 1178 1238 $this->set_charset( $this->dbh ); 1239 1240 $this->set_sql_mode(); 1179 1241 1180 1242 $this->ready = true;
Note: See TracChangeset
for help on using the changeset viewer.