| 1 | <?php |
| 2 | /** |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License along |
| 14 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 16 | * http://www.gnu.org/copyleft/gpl.html |
| 17 | * |
| 18 | * @file |
| 19 | */ |
| 20 | namespace Wikimedia\Rdbms\Database; |
| 21 | |
| 22 | /** |
| 23 | * @ingroup Database |
| 24 | */ |
| 25 | interface IDatabaseFlags { |
| 26 | |
| 27 | /** Do not remember the prior flags */ |
| 28 | public const REMEMBER_NOTHING = ''; |
| 29 | /** Remember the prior flags */ |
| 30 | public const REMEMBER_PRIOR = 'remember'; |
| 31 | /** Restore to the prior flag state */ |
| 32 | public const RESTORE_PRIOR = 'prior'; |
| 33 | /** Restore to the initial flag state */ |
| 34 | public const RESTORE_INITIAL = 'initial'; |
| 35 | |
| 36 | /** Enable debug logging of all SQL queries */ |
| 37 | public const DBO_DEBUG = 1; |
| 38 | /** Unused since 1.34 */ |
| 39 | public const DBO_NOBUFFER = 2; |
| 40 | /** Unused since 1.31 */ |
| 41 | public const DBO_IGNORE = 4; |
| 42 | /** Automatically start a transaction before running a query if none is active */ |
| 43 | public const DBO_TRX = 8; |
| 44 | /** Join load balancer transaction rounds (which control DBO_TRX) in non-CLI mode */ |
| 45 | public const DBO_DEFAULT = 16; |
| 46 | /** Use DB persistent connections if possible */ |
| 47 | public const DBO_PERSISTENT = 32; |
| 48 | /** DBA session mode; was used by Oracle */ |
| 49 | public const DBO_SYSDBA = 64; |
| 50 | /** Schema file mode; was used by Oracle */ |
| 51 | public const DBO_DDLMODE = 128; |
| 52 | /** |
| 53 | * Enable SSL/TLS in connection protocol |
| 54 | * @deprecated since 1.39 use 'ssl' parameter |
| 55 | */ |
| 56 | public const DBO_SSL = 256; |
| 57 | /** Enable compression in connection protocol */ |
| 58 | public const DBO_COMPRESS = 512; |
| 59 | /** Optimize connection for guaging server state (e.g. ILoadBalancer::CONN_UNTRACKED_GAUGE) */ |
| 60 | public const DBO_GAUGE = 1024; |
| 61 | |
| 62 | /** |
| 63 | * Set a flag for this connection |
| 64 | * |
| 65 | * @param int $flag One of (IDatabase::DBO_DEBUG, IDatabase::DBO_TRX) |
| 66 | * @param string $remember IDatabase::REMEMBER_* constant [default: REMEMBER_NOTHING] |
| 67 | */ |
| 68 | public function setFlag( $flag, $remember = self::REMEMBER_NOTHING ); |
| 69 | |
| 70 | /** |
| 71 | * Clear a flag for this connection |
| 72 | * |
| 73 | * @param int $flag One of (IDatabase::DBO_DEBUG, IDatabase::DBO_TRX) |
| 74 | * @param string $remember IDatabase::REMEMBER_* constant [default: REMEMBER_NOTHING] |
| 75 | */ |
| 76 | public function clearFlag( $flag, $remember = self::REMEMBER_NOTHING ); |
| 77 | |
| 78 | /** |
| 79 | * Restore the flags to their prior state before the last setFlag/clearFlag call |
| 80 | * |
| 81 | * @param string $state IDatabase::RESTORE_* constant. [default: RESTORE_PRIOR] |
| 82 | * @since 1.28 |
| 83 | */ |
| 84 | public function restoreFlags( $state = self::RESTORE_PRIOR ); |
| 85 | |
| 86 | /** |
| 87 | * Returns a boolean whether the flag $flag is set for this connection |
| 88 | * |
| 89 | * @param int $flag One of the class IDatabase::DBO_* constants |
| 90 | * @return bool |
| 91 | */ |
| 92 | public function getFlag( $flag ); |
| 93 | } |