×ðÁú¿­Ê±¹ÙÍøµÇ¼

laravel ÅÌÎÊ×î´óµÄ

laravelÅÌÎÊ×î´óµÄÊý¾Ý

LaravelÊÇÒ»¸öΪwebÒÕÊõ¼ÒÉè¼ÆµÄPHP Web¿ò¼Ü£¬Ëü²»µ«ÓÐÐí¶àÓÅÒìµÄ¹¦Ð§£¬²¢ÇÒËüµÄÓïÑÔÇкÏÒÕÊõ¼ÒÃǵÄÍ·ÄÔ·½·¨¡£ÔÚLaravelÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃEloquent ORMÀ´Ó³ÉäÊý¾Ý¿â¡£EloquentÊÇÒ»ÖÖÓÅÑŵġ¢Á÷ͨµÄ¡¢ÓÃÓÚÔÚLaravelÖнç˵ºÍÖ´ÐÐÊý¾Ý¿â²Ù×÷µÄÓïÑÔ¡£

ÔÚ±¾ÎÄÖУ¬ÎÒÃǽ«ÏÈÈÝÔõÑùÔÚLaravelÖÐÅÌÎÊ×î´óµÄÊý¾Ý¡£ÔÚ±¾ÀýÖУ¬ÎÒÃǽ«Ê¹ÓÃÒ»¸öproducts±í¡£Õâ¸ö±íÓÐÒ»¸öÃûΪ¡°price¡±µÄÁУ¬ÎÒÃǽ«ÔÚÕâÁÐÖвéÕÒ×î´óµÄ¼ÛÇ®¡£

Ê×ÏÈ£¬ÎÒÃÇÐèҪȷ¶¨Äĸö°æ±¾µÄLaravel¿ò¼ÜÎÒÃǽ«Ê¹Óá£ÔÚÕâ¸öÀý×ÓÖУ¬ÎÒÃǽ«Ê¹ÓÃLaravel 8¡£ÔÚLaravel 8ÖУ¬ÎÒÃÇ¿ÉÒÔͨ¹ýÁ½ÖÖ·½·¨ÅÌÎÊ×î´óÖµ£ºÊ¹ÓÃԭʼÅÌÎÊ»òʹÓÃEloquent ORM¡£

ʹÓÃԭʼÅÌÎÊ

ʹÓÃԭʼÅÌÎÊ£¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏ´úÂëÀ´ÅÌÎÊ×î´óÖµ£º

$maxPrice = DB::table('products')->max('price');

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄ´úÂëÖУ¬ÎÒÃÇʹÓÃDBÃÅÃæÀ´»á¼ûÊý¾Ý¿â¡£È»ºó£¬Ê¹ÓÃtable()ÒªÁìÖ¸¶¨ÎÒÃÇÒªÅÌÎʵıí¸ñ¡£×îºó£¬ÎÒÃÇŲÓÃmax()ÒªÁìÀ´»ñÈ¡ÁеÄ×î´óÖµ¡£

ÎÒÃÇ»¹¿ÉÒÔÔÚÅÌÎÊÖÐʹÓÃwhere()ÒªÁìÀ´Ìí¼ÓɸѡÌõ¼þ¡£ÀýÈ磬ÎÒÃÇ¿ÉÒÔÅÌÎʼÛÇ®´óÓÚ100µÄÉÌÆ·µÄ×î¸ß¼ÛÇ®£º

$maxPrice = DB::table('products')->where('price', '>', 100)->max('price');

µÇ¼ºó¸´ÖÆ

¿ÉÒÔ¿´µ½£¬ÔÚÉÏÃæµÄ´úÂëÖУ¬ÎÒÃÇÔÚwhere()ÒªÁìÖÐÌí¼ÓÁËÒ»¸öÓë²Ù×÷·ûºÍÒ»¸öÖµÀ´Ö¸¶¨É¸Ñ¡Ìõ¼þ¡£

ʹÓÃEloquent ORM

ÈôÊÇÄúÏëͨ¹ýEloquent ORMÅÌÎÊ×î´óÖµ£¬¿ÉÒÔʹÓÃÒÔÏ´úÂ룺

$maxPrice = Product::max('price');

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄ´úÂëÖУ¬ÎÒÃÇʹÓÃProductÄ£×ÓÀ´²Ù×÷products±í¡£È»ºó£¬ÎÒÃÇŲÓÃmax()ÒªÁìÀ´»ñÈ¡ÁеÄ×î´óÖµ¡£

ÓëԭʼÅÌÎÊÀàËÆ£¬ÎÒÃÇ¿ÉÒÔʹÓÃwhere()ÒªÁìÀ´Ìí¼ÓɸѡÌõ¼þ£º

$maxPrice = Product::where('price', '>', 100)->max('price');

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄÀý×ÓÖУ¬ÎÒÃÇʹÓÃÁËwhere()ÒªÁìÌí¼ÓÁËÒ»¸öÓë²Ù×÷·ûºÍÒ»¸öÖµÀ´Ö¸¶¨É¸Ñ¡Ìõ¼þ¡£

×ܽá

ÒÔÉϾÍÊÇÔÚLaravelÖÐÅÌÎÊ×î´óÖµµÄÁ½ÖÖ²î±ðÒªÁì¡£ÈôÊÇÄúϲ»¶¸ü¶àԭʼµÄ²Ù×÷ºÍ¸üºÃµÄÐÔÄÜ£¬ÄÇôʹÓÃԭʼÅÌÎÊ¿ÉÄÜÊÇÒ»¸ö²»´íµÄÑ¡Ôñ¡£¿ÉÊÇ£¬ÈôÊÇÄú¸üϲ»¶Ê¹ÓÃÄ£×Ӻ͸ü×ÔÈ»µÄÓï·¨£¬ÄÇôʹÓÃEloquent ORM¿ÉÄܸüÊʺÏÄú¡£ÔÚÏÖʵӦÓÃÖУ¬Äú¿ÉÒÔƾ֤×Ô¼ºµÄÐèÇóºÍʹÓÃÏ°¹ßÀ´Ñ¡ÔñÄÄÖÖÒªÁì¡£

ÒÔÉϾÍÊÇlaravel ÅÌÎÊ×î´óµÄµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ