//書き込み缓存
$menu_query = exequery( $connection, " SELECT ct.id as tid, ct.type_name , mb.id, mb.cookname,
mb.price、mb.description、mb.pinyin FROM Cook_type ct LEFT JOIN メニューブック mb ON ct.id = mb.cook_type WHERE
mb.id = ".$cook_id);
$menu_result = mysql_fetch_array( $menu_query );
//echo "菜单id:".$cook_id.";分类id:".$menu_result[tid];exit;
//今回の菜单
$row[mid] = $cook_id;
$row[メニュー名] = $クック名;
$row[説明] = $説明;
$row[menu_price] = $cook_price;
$row[pinyin] = ChangeToPinyin(iconv("utf-8","gb2312",$cook_name),1);
if( file_exists( "./menubook.php") )
{
require_once( "./menubook.php" );
}
if( is_array( $menu_cache) && !empty( $menu_cache) )
{
$classnum = count( $menu_cache );
$unmatchnum = 0;
for ( $i=0; $i
{
if( $menu_result[tid] != $menu_cache[$i][tid] )
{
$unmatchnum++;
続けます;
}
else //找到分类 , 继续寻找菜品の存在有無
{
$cartenum = count( $menu_cache[$i][リスト]);
$unmarrynum = 0;
for ( $j=0; $j
{
if ( $menu_cache[$i][list][$j][mid] != $cook_id )
{
$unmarrynum++;
続けます;
}
else //修改菜单
{
$menu_cache[$i][list][$j][menu_name] = $cook_name;
$menu_cache[$i][リスト][$j][説明] = $説明;
$menu_cache[$i][list][$j][menu_price] = $cook_price;
$menu_cache[$i][リスト][$j][ピンイン] = $row[ピンイン];
}
}
//新追加菜单
if( $cartenum == $unmarrynum )
{
$menu_cache[$i][list][] = $row;
}
}
}
//未到達分类
if ( $unmatchnum == $classnum )
{
$type_row[tid] = $menu_result[tid];
$type_row[type_name] = $menu_result[type_name];
$type_row[リスト][0] = $row;
$menu_cache[] = $type_row;
}
}
else { //数集合の生成
$type_row[tid] = $menu_result[tid];
$type_row[type_name] = $menu_result[type_name];
$type_row[リスト][0] = $row;
$menu_cache[] = $type_row;
}
//print_r( $menu_cache );
//書き込み文章
ob_start();
var_export( $menu_cache );
$content = ob_get_contents( );
ob_end_clean();
$filename = "menubook.php";
$fp = fopen( $filename, "w" );
fwrite( $fp, "" );
fclose( $fp );
二、追加菜单、写入缓存
$str=ChangeToPinyin(iconv("utf-8","gb2312",$cook_name),1);
$query_cook_add="メニューブックに挿入(クック名,価格,クックタイプ,説明,ピンイン) 値(".$クック名.",".$クック価格.",".$クックタイプ.",".$説明.","。 $str.")";
$cursor_cook_add=exequery($connection,$query_cook_add);
$cook_id = mysql_insert_id();
$menutype_query = exequery( $connection, " SELECT type_name FROM Cook_type WHERE id = ".$cook_type);
$menutype_result = mysql_fetch_array( $menutype_query );
//今回の菜单
$row[mid] = $cook_id;
$row[メニュー名] = $クック名;
$row[説明] = $説明;
$row[menu_price] = $cook_price;
$row[ピンイン] = $str;
if( file_exists( "./menubook.php") )
{
require_once( "./menubook.php" );
}
if( is_array( $menu_cache) && !empty( $menu_cache) )
{
$classnum = count( $menu_cache );
$unmatchnum = 0;
for ( $i=0; $i
{
if( $cook_type != $menu_cache[$i][tid] )
{
$unmatchnum++;
続けます;
}
else //找到達分类、追加改品菜品の缓存
{
$menu_cache[$i][リスト][] = $row;
}
}
if( $classnum == $unmatchnum ) //未到達分类
{
$type_row[tid] = $cook_type;
$type_row[type_name] = $menutype_result[type_name];
$type_row[リスト][0] = $row;
$menu_cache[] = $type_row;
}
}
else { //数集合の生成
$type_row[tid] = $cook_type ;
$type_row[type_name] = $menutype_result[type_name];
$type_row[リスト][0] = $row;
$menu_c