Самый быстрый и простой способ создания уведомлений (электронных писем и т. Д.) О вставках / модификациях / удалениях базы данных - это выполнение сценария, выполняющего изменения в базе данных.
<?php
$res = mysql_query( 'INSERT INTO `table` ( `field1` ) VALUES ( "One" )' );
if( $res ){
# Send Notification
}
?>
В противном случае, если вы не выполняете манипуляции с базой данных самостоятельно (по какой-либо причине) или хотите иметь возможность выполнять синхронизированные сводки (ежечасно, ежедневно, еженедельно), вам потребуется использовать что-то вроде Cron Job для опроса базы данных и проверки изменений.
<?php
# A file containing an integer which is the Highest ID in the table
$indexFile = 'lastIndexID.txt';
# Get that Highest ID from the file, if it exists
$lastIndex = 0;
if( file_exists( $indexFile )
$lastIndex = (int) file_get_contents( $indexFile );
# Check the Database
$res = mysql_query( 'SELECT `id` FROM `table` ORDER BY `id` DESC LIMIT 1' );
if( $res && mysql_num_rows( $res )==1 ){
$row = mysql_fetch_assoc( $res );
# Check if the ID has increased (ie new rows added)
if( $row['id']>$lastIndex ){
# Send Notification
# The number of New Rows will be the difference between $row['id'] and $lastIndex
# Update the Index File
file_put_contents( $indexFile , $row['id'] );
}
}else{
# An Error Occurred
}
?>