是否可以在触发器内循环遍历所有列名称?
场景:记录已修改的表的所有列.如果某些值没有改变,请不要记录那些值.
DROP TRIGGER IF EXISTS t_before_update_test;
DELIMITER $$
CREATE TRIGGER t_before_update_test
BEFORE UPDATE ON test
FOR EACH ROW
BEGIN
-- Loop here for all columns, not just col1
IF OLD.col1 <> NEW.col1 THEN
INSERT INTO change_logs(
log_on, user_id,
table_name, colum_name,
old_data, new_data
) VALUES (
UNIX_TIMESTAMP(NOW()), '0',
'test', 'col1',
OLD.col1, NEW.col1
);
END IF;
-- process looping all columns
-- col1, col2, ... should be dynamic per loop
END $$
Run Code Online (Sandbox Code Playgroud)
这是工作副本示例,我现在需要遍历OLD或NEW中可用的所有列.
如何防止AngularJS点击具有"禁用"属性的HTML按钮标记?
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<button type="button" disabled ng-click="something()">No Click Please!</button>Run Code Online (Sandbox Code Playgroud)
在这种情况下,不应该调用something().
我只是想知道,如果你绘制5位数字,mt_rand()数是多么独特?在这个例子中,我试图用这个函数得到500个随机数的列表,其中一些是重复的.
http://www.php.net/manual/en/function.mt-rand.php
<?php
header('Content-Type: text/plain');
$errors = array();
$uniques = array();
for($i = 0; $i < 500; ++$i)
{
$random_code = mt_rand(10000, 99999);
if(!in_array($random_code, $uniques))
{
$uniques[] = $random_code;
}
else
{
$errors[] = $random_code;
}
}
/**
* If you get any data in this array, it is not exactly unique
* Run this script for few times and you may see some repeats
*/
print_r($errors);
?>
Run Code Online (Sandbox Code Playgroud)
可能需要多少位数才能确保循环中绘制的前500个随机数是唯一的?
如何获取HTML代码段中使用的所有类名的列表?
例如,下面的HTML代码段,
<div class="name">
<div class="first"></div>
<div class="last"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
将有输出name,first,last或name,name > first,name > last。在这里,我担心首先找到所有的类选择器。嵌套可以是可选的。
我希望使用Javascript或正则表达式。
Windows下哪里可以设置~/.my.cnf文件?正在运行自动备份脚本。它正在生成一条屏幕消息:
Warning: Using a password on the command line interface can be insecure.
Run Code Online (Sandbox Code Playgroud)