PHP generates MySQL trigger definition statements in batches

Source: Internet
Author: User

Introduction: This is a detailed page for PHP to generate MySQL trigger definition statements in batches. It introduces PHP, related knowledge, skills, experience, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 333669 'rolling = 'no'>

<? Phpdefine ('triggers _ after_insert_ SQL ', "delimiter | drop trigger if exists % s; Create trigger % safter insert on % SFOR each row begin set @ result_set = (select clear_cache ()); end | delimiter; \ r \ n "); define ('triggers _ after_update_ SQL '," delimiter | drop trigger if exists % s; create trigger % safter update on % SFOR each row begin set @ result_set = (select clear_cache (); End | delimiter; \ r \ n "); define ('tr Igger_after_delete_ SQL ', "delimiter | drop trigger if exists % s; Create trigger % safter delete on % SFOR each row begin set @ result_set = (select clear_cache (); End | delimiter; \ r \ n "); mysql_connect ('2017. 0.0.1: 3307 ', 'root', '') or die (mysql_error (); mysql_select_db ('db'); mysql_query ('set names utf8 '); $ triggerddl = ''; $ rs = mysql_query ('show tables '); While ($ ROW = mysql_fetch_array ($ RS) {$ tblname = $ R Ow ['tables _ in_db ']; $ triggerddl. = "\ r \ n -- table trigger '". $ tblname. "'\ r \ n -- \ r \ n"; $ triggername = $ tblname. '_ insert'; $ triggerddl. = sprintf (trigger_after_insert_ SQL, $ triggername, $ triggername, $ tblname); $ triggername = $ tblname. '_ Update'; $ triggerddl. = sprintf (trigger_after_update_ SQL, $ triggername, $ triggername, $ tblname); $ triggername = $ tblname. '_ delete'; $ triggerddl. = sprintf (trigger_after_delete_ SQL, $ t Riggername, $ triggername, $ tblname);} file_put_contents ('db _ trigger. SQL ', $ triggerddl);?>

More articles about "batch generate MySQL trigger definition statements in PHP"

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/333669.html pageno: 11.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.