我在项目中使用了许多事务数据库操作,并且希望使用PHP version: 7.1.16
PHP CLI: /usr/local/Cellar/php@7.1/7.1.16/bin/php PHP CGI: /usr/local/Cellar/php@7.1/7.1.16/bin/php-cgi
Loaded Configuration File: /usr/local/etc/php/7.1/php.ini
Additional .ini files parsed: /usr/local/etc/php/7.1/conf.d/ext-imagick.ini /usr/local/etc/php/7.1/conf.d/ext-opcache.ini /usr/local/etc/php/7.1/conf.d/ext-xdebug.ini
Debugger extension: Xdebug 2.6.0
Loaded extensions: bcmath, bz2, calendar, Core, ctype, curl, date, dba, dom, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, imagick, intl, json, ldap, libxml, mbstring, mcrypt, mysqli, mysqlnd, odbc, openssl, pcntl, pcre, PDO, pdo_dblib, pdo_mysql, PDO_ODBC, pdo_pgsql, pdo_sqlite, pgsql, Phar, phpdbg_webhelper, posix, pspell, readline, Reflection, session, shmop, SimpleXML, soap, sockets, SPL, sqlite3, standard, sysvmsg, sysvsem, sysvshm, tokenizer, wddx, xdebug, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend OPcache, zip, zlib
Configuration options:
allow_url_fopen
1
allow_url_include
arg_separator.input
&
arg_separator.output
&
assert.active
1
assert.bail
0
assert.callback
assert.exception
0
assert.quiet_eval
0
assert.warning
1
auto_append_file
auto_detect_line_endings
0
auto_globals_jit
1
auto_prepend_file
bcmath.scale
0
browscap
cli.pager
cli.prompt
\b \>
curl.cainfo
date.default_latitude
31.7667
date.default_longitude
35.2333
date.sunrise_zenith
90.583333
date.sunset_zenith
90.583333
date.timezone
dba.default_handler
flatfile
default_charset
UTF-8
default_mimetype
text/html
default_socket_timeout
60
disable_classes
disable_functions
display_errors
1
display_startup_errors
1
doc_root
docref_ext
docref_root
enable_dl
enable_post_data_reading
1
error_append_string
error_log
error_prepend_string
error_reporting
32767
exif.decode_jis_intel
JIS
exif.decode_jis_motorola
JIS
exif.decode_unicode_intel
UCS-2LE
exif.decode_unicode_motorola
UCS-2BE
exif.encode_jis
exif.encode_unicode
ISO-8859-15
expose_php
1
extension_dir
/usr/local/Cellar/php@7.1/7.1.16/lib/php/20160303
file_uploads
1
filter.default
unsafe_raw
filter.default_flags
from
gd.jpeg_ignore_warning
1
hard_timeout
2
highlight.comment
#FF8000
highlight.default
#0000BB
highlight.html
#000000
highlight.keyword
#007700
highlight.string
#DD0000
html_errors
0
iconv.input_encoding
iconv.internal_encoding
iconv.output_encoding
ignore_repeated_errors
ignore_repeated_source
ignore_user_abort
0
imagick.locale_fix
0
imagick.progress_monitor
0
imagick.skip_version_check
0
implicit_flush
1
include_path
.:/usr/local/Cellar/php@7.1/7.1.16/share/pear
input_encoding
internal_encoding
intl.default_locale
intl.error_level
0
intl.use_exceptions
0
ldap.max_links
-1
log_errors
1
log_errors_max_len
1024
mail.add_x_header
1
mail.force_extra_parameters
mail.log
max_execution_time
0
max_file_uploads
20
max_input_nesting_level
64
max_input_time
-1
max_input_vars
1000
mbstring.detect_order
mbstring.encoding_translation
0
mbstring.func_overload
0
mbstring.http_input
mbstring.http_output
mbstring.http_output_conv_mimetypes
^(text/|application/xhtml\+xml)
mbstring.internal_encoding
mbstring.language
neutral
mbstring.strict_detection
0
mbstring.substitute_character
mcrypt.algorithms_dir
mcrypt.modes_dir
memory_limit
512M
mysqli.allow_local_infile
1
mysqli.allow_persistent
1
mysqli.default_host
mysqli.default_port
3306
mysqli.default_pw
mysqli.default_socket
/tmp/mysql.sock
mysqli.default_user
mysqli.max_links
-1
mysqli.max_persistent
-1
mysqli.reconnect
mysqli.rollback_on_cached_plink
0
mysqlnd.collect_memory_statistics
1
mysqlnd.collect_statistics
1
mysqlnd.debug
mysqlnd.fetch_data_copy
0
mysqlnd.log_mask
0
mysqlnd.mempool_default_size
16000
mysqlnd.net_cmd_buffer_size
4096
mysqlnd.net_read_buffer_size
32768
mysqlnd.net_read_timeout
31536000
mysqlnd.sha256_server_public_key
mysqlnd.trace_alloc
odbc.allow_persistent
1
odbc.check_persistent
1
odbc.default_cursortype
3
odbc.default_db
odbc.default_pw
odbc.default_user
odbc.defaultbinmode
1
odbc.defaultlrl
4096
odbc.max_links
-1
odbc.max_persistent
-1
opcache.blacklist_filename
opcache.consistency_checks
0
opcache.dups_fix
0
opcache.enable
1
opcache.enable_cli
0
opcache.enable_file_override
0
opcache.error_log
opcache.fast_shutdown
0
opcache.file_cache
opcache.file_cache_consistency_checks
1
opcache.file_cache_only
0
opcache.file_update_protection
2
opcache.force_restart_timeout
180
opcache.huge_code_pages
0
opcache.inherited_hack
1
opcache.interned_strings_buffer
8
opcache.lockfile_path
/tmp
opcache.log_verbosity_level
1
opcache.max_accelerated_files
10000
opcache.max_file_size
0
opcache.max_wasted_percentage
5
opcache.memory_consumption
128
opcache.opt_debug_level
0
opcache.optimization_level
0x7FFFBFFF
opcache.preferred_memory_model
opcache.protect_memory
0
opcache.restrict_api
opcache.revalidate_freq
2
opcache.revalidate_path
0
opcache.save_comments
1
opcache.use_cwd
1
opcache.validate_permission
0
opcache.validate_root
0
opcache.validate_timestamps
1
open_basedir
openssl.cafile
openssl.capath
output_buffering
0
output_encoding
output_handler
pcre.backtrack_limit
1000000
pcre.jit
1
pcre.recursion_limit
100000
pdo_mysql.default_socket
/tmp/mysql.sock
pgsql.allow_persistent
1
pgsql.auto_reset_persistent
pgsql.ignore_notice
0
pgsql.log_notice
0
pgsql.max_links
-1
pgsql.max_persistent
-1
phar.cache_list
phar.readonly
1
phar.require_hash
1
phpdbg.auth
phpdbg.path
post_max_size
8M
precision
14
realpath_cache_size
4096K
realpath_cache_ttl
120
register_argc_argv
1
report_memleaks
1
report_zend_debug
0
request_order
GP
sendmail_from
sendmail_path
/usr/sbin/sendmail -t -i
serialize_precision
-1
session.auto_start
0
session.cache_expire
180
session.cache_limiter
nocache
session.cookie_domain
session.cookie_httponly
session.cookie_lifetime
0
session.cookie_path
/
session.cookie_secure
session.gc_divisor
1000
session.gc_maxlifetime
1440
session.gc_probability
1
session.lazy_write
1
session.name
PHPSESSID
session.referer_check
session.save_handler
files
session.save_path
session.serialize_handler
php
session.sid_bits_per_character
5
session.sid_length
26
session.trans_sid_hosts
session.trans_sid_tags
a=href,area=href,frame=src,form=
session.upload_progress.cleanup
1
session.upload_progress.enabled
1
session.upload_progress.freq
1%
session.upload_progress.min_freq
1
session.upload_progress.name
PHP_SESSION_UPLOAD_PROGRESS
session.upload_progress.prefix
upload_progress_
session.use_cookies
1
session.use_only_cookies
1
session.use_strict_mode
0
session.use_trans_sid
0
short_open_tag
SMTP
localhost
smtp_port
25
soap.wsdl_cache
1
soap.wsdl_cache_dir
/tmp
soap.wsdl_cache_enabled
1
soap.wsdl_cache_limit
5
soap.wsdl_cache_ttl
86400
sql.safe_mode
sqlite3.extension_dir
sys_temp_dir
track_errors
1
unserialize_callback_func
upload_max_filesize
2M
upload_tmp_dir
url_rewriter.hosts
url_rewriter.tags
form=
user_agent
user_dir
user_ini.cache_ttl
300
user_ini.filename
.user.ini
variables_order
GPCS
xdebug.auto_trace
0
xdebug.cli_color
0
xdebug.collect_assignments
0
xdebug.collect_includes
1
xdebug.collect_params
0
xdebug.collect_return
0
xdebug.collect_vars
0
xdebug.coverage_enable
1
xdebug.default_enable
1
xdebug.dump.COOKIE
xdebug.dump.ENV
xdebug.dump.FILES
xdebug.dump.GET
xdebug.dump.POST
xdebug.dump.REQUEST
xdebug.dump.SERVER
xdebug.dump.SESSION
xdebug.dump_globals
1
xdebug.dump_once
1
xdebug.dump_undefined
0
xdebug.extended_info
1
xdebug.file_link_format
xdebug.filename_format
xdebug.force_display_errors
0
xdebug.force_error_reporting
0
xdebug.gc_stats_enable
0
xdebug.gc_stats_output_dir
/var/tmp/
xdebug.gc_stats_output_name
gcstats.%p
xdebug.halt_level
0
xdebug.idekey
xdebug.max_nesting_level
256
xdebug.max_stack_frames
-1
xdebug.overload_var_dump
2
xdebug.profiler_aggregate
0
xdebug.profiler_append
0
xdebug.profiler_enable
0
xdebug.profiler_enable_trigger
0
xdebug.profiler_enable_trigger_value
xdebug.profiler_output_dir
/var/tmp/
xdebug.profiler_output_name
cachegrind.out.%p
xdebug.remote_addr_header
xdebug.remote_autostart
0
xdebug.remote_connect_back
0
xdebug.remote_cookie_expire_time
3600
xdebug.remote_enable
0
xdebug.remote_handler
dbgp
xdebug.remote_host
localhost
xdebug.remote_log
xdebug.remote_mode
req
xdebug.remote_port
9000
xdebug.remote_timeout
200
xdebug.scream
0
xdebug.show_error_trace
0
xdebug.show_exception_trace
0
xdebug.show_local_vars
0
xdebug.show_mem_delta
0
xdebug.trace_enable_trigger
0
xdebug.trace_enable_trigger_value
xdebug.trace_format
0
xdebug.trace_options
0
xdebug.trace_output_dir
/var/tmp/
xdebug.trace_output_name
trace.%c
xdebug.var_display_max_children
128
xdebug.var_display_max_data
512
xdebug.var_display_max_depth
3
xmlrpc_error_number
0
xmlrpc_errors
0
zend.assertions
1
zend.detect_unicode
1
zend.enable_gc
1
zend.multibyte
0
zend.script_encoding
zend.signal_check
0
zlib.output_compression
zlib.output_compression_level
-1
zlib.output_handler
将它们组合在一起,以便可以轻松地回滚整个事物。
为了清楚起见,我想将每个操作封装在一个单独的方法中。
使用Log closed at 2018-04-05 15:47:08
Log opened at 2018-04-05 15:49:27
I: Connecting to configured address/port: localhost:9000.
W: Creating socket for 'localhost:9000', poll success, but error: Operation now in progress (19).
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///Users/namehere/PhpstormProjects/arc/web/index.php" language="PHP" xdebug:language_version="7.1.13" protocol_version="1.0" appid="17035" idekey="17743"><engine version="2.6.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2018 by Derick Rethans]]></copyright></init>
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
Log closed at 2018-04-05 15:49:29
Log opened at 2018-04-05 15:49:31
I: Connecting to configured address/port: localhost:9000.
W: Creating socket for 'localhost:9000', poll success, but error: Operation now in progress (19).
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///Users/namehere/PhpstormProjects/arc/web/index.php" language="PHP" xdebug:language_version="7.1.13" protocol_version="1.0" appid="17035" idekey="17743"><engine version="2.6.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2018 by Derick Rethans]]></copyright></init>
Log opened at 2018-04-05 15:49:31
I: Connecting to configured address/port: localhost:9000.
W: Creating socket for 'localhost:9000', poll success, but error: Operation now in progress (19).
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///Users/namehere/PhpstormProjects/arc/web/index.php" language="PHP" xdebug:language_version="7.1.13" protocol_version="1.0" appid="17036" idekey="17743"><engine version="2.6.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2018 by Derick Rethans]]></copyright></init>
Log opened at 2018-04-05 15:49:32
I: Connecting to configured address/port: localhost:9000.
W: Creating socket for 'localhost:9000', poll success, but error: Operation now in progress (19).
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///Users/namehere/PhpstormProjects/arc/web/index.php" language="PHP" xdebug:language_version="7.1.13" protocol_version="1.0" appid="17040" idekey="17743"><engine version="2.6.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2018 by Derick Rethans]]></copyright></init>
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
Log closed at 2018-04-05 15:49:33
Log opened at 2018-04-05 15:49:33
I: Connecting to configured address/port: localhost:9000.
W: Creating socket for 'localhost:9000', poll success, but error: Operation now in progress (19).
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///Users/namehere/PhpstormProjects/arc/web/index.php" language="PHP" xdebug:language_version="7.1.13" protocol_version="1.0" appid="17035" idekey="17743"><engine version="2.6.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2018 by Derick Rethans]]></copyright></init>
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
Log closed at 2018-04-05 15:49:33
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
Log closed at 2018-04-05 15:49:33
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
Log closed at 2018-04-05 15:49:34
Log opened at 2018-04-05 15:49:34
Log opened at 2018-04-05 15:49:34
I: Connecting to configured address/port: localhost:9000.
W: Creating socket for 'localhost:9000', poll success, but error: Operation now in progress (19).
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///Users/namehere/PhpstormProjects/arc/web/index.php" language="PHP" xdebug:language_version="7.1.13" protocol_version="1.0" appid="17036" idekey="17743"><engine version="2.6.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2018 by Derick Rethans]]></copyright></init>
I: Connecting to configured address/port: localhost:9000.
W: Creating socket for 'localhost:9000', poll success, but error: Operation now in progress (19).
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///Users/namehere/PhpstormProjects/arc/web/index.php" language="PHP" xdebug:language_version="7.1.13" protocol_version="1.0" appid="17035" idekey="17743"><engine version="2.6.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2018 by Derick Rethans]]></copyright></init>
Log opened at 2018-04-05 15:49:34
I: Connecting to configured address/port: localhost:9000.
W: Creating socket for 'localhost:9000', poll success, but error: Operation now in progress (19).
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///Users/namehere/PhpstormProjects/arc/web/index.php" language="PHP" xdebug:language_version="7.1.13" protocol_version="1.0" appid="17040" idekey="17743"><engine version="2.6.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2018 by Derick Rethans]]></copyright></init>
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
Log closed at 2018-04-05 15:49:34
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
Log closed at 2018-04-05 15:49:34
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
Log closed at 2018-04-05 15:49:34
Log opened at 2018-04-05 15:49:48
I: Connecting to configured address/port: 127.0.0.1:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///Users/namehere/PhpstormProjects/arc/bin/console" language="PHP" xdebug:language_version="7.1.13" protocol_version="1.0" appid="17042" idekey="16246"><engine version="2.6.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2018 by Derick Rethans]]></copyright></init>
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
Log closed at 2018-04-05 15:49:49
Log opened at 2018-04-05 15:54:32
I: Connecting to configured address/port: localhost:9000.
W: Creating socket for 'localhost:9000', poll success, but error: Operation now in progress (19).
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///Users/namehere/PhpstormProjects/arc/web/index.php" language="PHP" xdebug:language_version="7.1.13" protocol_version="1.0" appid="17035" idekey="17743"><engine version="2.6.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2018 by Derick Rethans]]></copyright></init>
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
Log closed at 2018-04-05 15:54:32
时,从中调用的方法会创建一个数据库连接,作为范围的一部分,如下所示。
TransactionScope