//写入缓存
$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
{
if( $menu_result[tid] != $menu_cache[$i][tid] )
{
$unmatchnum++;
continue;
}
else //找到分类 , 继续寻找菜品的缓存是否存在
{
$cartenum = count( $menu_cache[$i][list]);
$unmarrynum = 0;
for ( $j=0; $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;
}
}
}
//未找到分类
if ( $unmatchnum == $classnum )
{
$type_row[tid] = $menu_result[tid];
$type_row[type_name] = $menu_result[type_name];
$type_row[list][0] = $row;
$menu_cache[] = $type_row;
}
}
else { //数组的生成
$type_row[tid] = $menu_result[tid];
$type_row[type_name] = $menu_result[type_name];
$type_row[list][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="insert into menubook(cookname,price,cook_type,description,pinyin) values(".$cook_name.",".$cook_price.",".$cook_type.",".$description.",".$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[menu_name] = $cook_name;
$row[description] = $description;
$row[menu_price] = $cook_price;
$row[pinyin] = $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++;
continue;
}
else //找到分类 ,添加改产品菜品的缓存
{
$menu_cache[$i][list][] = $row;
}
}
if( $classnum == $unmatchnum ) //未找到分类
{
$type_row[tid] = $cook_type;
$type_row[type_name] = $menutype_result[type_name];
$type_row[list][0] = $row;
$menu_cache[] = $type_row;
}
}
else { //数组的生成
$type_row[tid] = $cook_type ;
$type_row[type_name] = $menutype_result[type_name];
$type_row[list][0] = $row;
$menu_c

DependencyInjection (DI) inphpenhancescodeflexabilityandtestabilitybydecouplingDependencyCreationFromusage.toImplementDieffectively: 1) UseIcontainersjudiciousytoavoavoidover-engineering.2) mengelakkan constructoLoadbylimitingdendenchreeorfour.3)

Toimproveyourphpwebsite'sperformance, usetheseStrategies: 1) pelaksanaanPodeCachingWithopcachetospeedupscriptinterpretation.2) OptimisedataBasequeriesqueriesSelectingOnlyNessaryFields.3)

Ya, itispossibletosendmassemailswithphp.1) uselibrarieshpmailerorswiftmailoreforefficientemailsending.2)

DependencyInjection (DI) inphpisadesignpatternTheevesinversionofControl (IOC) ByallowingdependencyestobeNectedIntoClasses, Enhancingmodularity, Testability, danFlexibility.DideDecouplassClassSesesesesSesesSesesSesesSesesSesesSesesspeciflementations, MakeCodemorAglementations, MakeCodemorAglementations, MakeCodemorAglementations, MakeCodemorAglementations, MakeCodemorAglementations, MakeCodemorAglementations, MakeCodemorAglementations, MakeCodemorAglementations, MakeCodemorAglemors, Maklumat

Cara terbaik untuk menghantar e -mel menggunakan PHP termasuk: 1. Gunakan fungsi mel () php untuk penghantaran asas; 2. Gunakan perpustakaan phpmailer untuk menghantar mel lebih kompleks HTML; 3. Gunakan perkhidmatan mel transaksional seperti SendGrid untuk meningkatkan keupayaan kebolehpercayaan dan analisis. Dengan kaedah ini, anda boleh memastikan bahawa e -mel bukan sahaja mencapai peti masuk, tetapi juga menarik penerima.

Mengira jumlah elemen dalam array multidimensi PHP boleh dilakukan dengan menggunakan kaedah rekursif atau berulang. 1. Kaedah rekursif dikira dengan melintasi array dan rekursif memproses susunan bersarang. 2. Kaedah berulang menggunakan timbunan untuk mensimulasikan rekursi untuk mengelakkan masalah kedalaman. 3. Fungsi Array_Walk_Recursive juga boleh dilaksanakan, tetapi ia memerlukan pengiraan manual.

Dalam PHP, ciri-ciri gelung do-sementara adalah untuk memastikan bahawa badan gelung dilaksanakan sekurang-kurangnya sekali, dan kemudian memutuskan sama ada untuk meneruskan gelung berdasarkan syarat-syarat. 1) Ia melaksanakan badan gelung sebelum pemeriksaan bersyarat, sesuai untuk senario di mana operasi perlu dilakukan sekurang -kurangnya sekali, seperti pengesahan input pengguna dan sistem menu. 2) Walau bagaimanapun, sintaks gelung do-sementara boleh menyebabkan kekeliruan di kalangan pemula dan boleh menambah overhead prestasi yang tidak perlu.

String hashing yang cekap dalam PHP boleh menggunakan kaedah berikut: 1. Gunakan fungsi MD5 untuk hashing cepat, tetapi tidak sesuai untuk penyimpanan kata laluan. 2. Gunakan fungsi SHA256 untuk meningkatkan keselamatan. 3. Gunakan fungsi password_hash untuk memproses kata laluan untuk menyediakan keselamatan dan kemudahan tertinggi.


Alat AI Hot

Undresser.AI Undress
Apl berkuasa AI untuk mencipta foto bogel yang realistik

AI Clothes Remover
Alat AI dalam talian untuk mengeluarkan pakaian daripada foto.

Undress AI Tool
Gambar buka pakaian secara percuma

Clothoff.io
Penyingkiran pakaian AI

Video Face Swap
Tukar muka dalam mana-mana video dengan mudah menggunakan alat tukar muka AI percuma kami!

Artikel Panas

Alat panas

Hantar Studio 13.0.1
Persekitaran pembangunan bersepadu PHP yang berkuasa

SublimeText3 versi Cina
Versi Cina, sangat mudah digunakan

Dreamweaver CS6
Alat pembangunan web visual

VSCode Windows 64-bit Muat Turun
Editor IDE percuma dan berkuasa yang dilancarkan oleh Microsoft

ZendStudio 13.5.1 Mac
Persekitaran pembangunan bersepadu PHP yang berkuasa
