尊龙凯时人生就是搏

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
sitemap¡¢ÍøÕ¾µØͼ