|
 |
|
running แล้วตัวเลขมันกระโดดอะครับ insert ครั้งแรก จะเป็น 01 แต่ครั้งต่อไปมันเป็น 21, 22, 23 |
|
 |
|
|
 |
 |
|
insert ครั้งแรก จะเป็น 01 แต่ครั้งต่อไปมันเป็น 21, 22, 23 รบกวนทีนะครับ
Code (PHP)
$c_year = date('Ymd');
$r = mysql_query("SELECT max_date FROM `file_cnreport` WHERE report_id=(SELECT MAX(report_id) FROM `file_cnreport` WHERE max_date LIKE '$c_year%')");
$n_number = mysql_num_rows($r) ? substr(mysql_result($r,0),5) : 0;
//run query insert ไปเรื่อยๆ จนกว่าจะไม่ error 1062 (error key ซ้ำ)
do {
$n_id = $c_year.sprintf("%02d", ++$n_number);
$c_year = date('Ymd');
$r = mysql_query("SELECT max_date FROM `file_cnreport` WHERE report_id=(SELECT MAX(report_id) FROM `file_cnreport` WHERE max_date LIKE '$c_year%')");
$n_number = mysql_num_rows($r) ? substr(mysql_result($r,0),5) : 0;
//run query insert ไปเรื่อยๆ จนกว่าจะไม่ error 1062 (error key ซ้ำ)
do {
$n_id = $c_year.sprintf("%02d", ++$n_number);
$FileName = block_sql("ORS_OOO_".$n_id.".text");
$FileName_pgp = block_sql("ORS_OOO_".$n_id);
$FileName_sha1 = block_sql("ORS_OOO_".$n_id.".sha1");
$FileName_ctrl = block_sql("ORS_OOO_".$$n_id.".ctrl");
$sql = "INSERT INTO file_cnreport set
re_id = '$re_id',
max_date = '$n_id',
file_text = '$FileName',
file_sha1 = '$FileName_sha1',
file_ctrl = '$FileName_ctrl',
file_pgp = '$FileName_pgp',
file_create = '$mixdatetime'";
mysql_query($sql);
}
while (mysql_errno() == 1062);
echo $sql;
$sql = "INSERT INTO file_cnreport set
re_id = '$re_id',
max_date = '$n_id',
file_text = '$FileName',
file_sha1 = '$FileName_sha1',
file_ctrl = '$FileName_ctrl',
file_pgp = '$FileName_pgp',
file_create = '$mixdatetime'";
mysql_query($sql);
$update = "UPDATE request_header set status_file_re = '1' where re_id = '$re_id'";
//mysql_query($update);
/*exit("<script>alert('Add Name File Complete');window.location='../cn_file_report.php';</script>"); */
}
while (mysql_errno() == 1062);
echo $sql;
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-12-08 09:19:17 |
By :
vv |
View :
912 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตั้งแต่บรรทั ด 49 ไม่เกี่ยวนะครับ มันมาได้ไงมะรู้
|
 |
 |
 |
 |
Date :
2009-12-08 09:20:44 |
By :
vv |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|