//写入缓存
$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 menubook 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[''menu_name''] = $cook_name;
$row[''description''] = $description;
$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<$classnum; $i++ )
{
if( $menu_result[''tid''] != $menu_cache[$i][''tid''] )
{
$unmatchnum++;
continue;
}
else //找到分类 , 继续寻找菜品的缓存是否存在
{
$cartenum = count( $menu_cache[$i][''list'']);
$unmarrynum = 0;
for ( $j=0; $j<$cartenum; $j++ )
{
if ( $menu_cache[$i][''list''][$j][''mid''] != $cook_id )
{
$unmarrynum++;
continue;
}
else //修改菜单
{
$menu_cache[$i][''list''][$j][''menu_name''] = $cook_name;
$menu_cache[$i][''list''][$j][''description''] = $description;
$menu_cache[$i][''list''][$j][''menu_price''] = $cook_price;
$menu_cache[$i][''list''][$j][''pinyin''] = $row[''pinyin''];
}
}
//新添加的菜单
if( $cartenum == $unmarrynum )
{
$menu_cache[$i][''list''][] = $row;
}
}
} |