尊龙凯时人生就是搏

laravelÅÌÎÊÒ»¸öÖµ

ÔÚ laravel ÖÐ £¬ÅÌÎÊÒ»¸öÖµ¿ÉÒÔʹÓà value() ÒªÁì¡£

¸ÃÒªÁ콫·µ»ØÅÌÎÊЧ¹ûµÄµÚÒ»ÐеÚÒ»ÁеÄÖµ £¬Ò²¾ÍÊÇÒ»¸ö¼òµ¥µÄÖµ¡£

¼ÙÉèÎÒÃÇÓÐÒ»¸öÃûΪ users µÄÊý¾Ý±í £¬ÆäÖаüÀ¨ÓÐÒÔÏÂ×ֶΣº id £¬name £¬email ºÍ birthday £¬ÏÖÔÚÏëÅÌÎʸÃÊý¾Ý±íÖÐ id Ϊ 1 µÄÓû§ÐÕÃû £¬ÔÚ Laravel ÖÐ £¬¿ÉÒÔʹÓÃÒÔÏÂÒªÁìʵÏÖ£º

$name = DB::table('users')->where('id', 1)->value('name');

µÇ¼ºó¸´ÖÆ

ÉÏÃæµÄ´úÂëʹÓÃÁËÅÌÎʹ¹½¨Æ÷µÄ where() ºÍ value() ÒªÁì £¬ÆäÖÐ £¬where() ÒªÁìÓÃÓÚɸѡÌõ¼þ £¬value() ÒªÁìÓÃÓÚ·µ»ØÅÌÎÊЧ¹ûµÄµÚÒ»ÐеÚÒ»ÁеÄÖµ¡£ÒÔÉÏ´úÂ뽫·µ»Ø id Ϊ 1 µÄÓû§µÄÐÕÃû¡£

±ðµÄ £¬¹ØÓÚÖ»ÐèÒªÅÌÎÊÒ»¸öÖµµÄÇéÐÎ £¬»¹¿ÉÒÔʹÓà pluck() ÒªÁì¡£

$name = DB::table('users')->where('id', 1)->pluck('name');

µÇ¼ºó¸´ÖÆ

pluck() ÒªÁìÓë value() ÒªÁìÏàËÆ £¬Ò²¿ÉÒÔ·µ»ØÅÌÎÊЧ¹ûµÄµÚÒ»ÐеÚÒ»ÁеÄÖµ £¬¿ÉÊÇ pluck() ÒªÁìµÄ·µ»ØÖµÊÇÒ»¸ö Collection ¹¤¾ß¡£ÈôÊÇÖ»ÐèÒª»ñÈ¡¼òµ¥µÄÖµ £¬»¹ÐèҪʹÓà Collection ¹¤¾ßµÄ first() ÒªÁì £¬ÀýÈ磺

$name = DB::table('users')->where('id', 1)->pluck('name')->first();

µÇ¼ºó¸´ÖÆ

ÒÔÉÏ´úÂëͬÑù¿ÉÒÔ·µ»Ø id Ϊ 1 µÄÓû§µÄÐÕÃû¡£

×ܽáһϠ£¬ÅÌÎÊÒ»¸öÖµÔÚ Laravel ÖкÜÊǼòÆÓ £¬Ö»ÐèҪʹÓÃÅÌÎʹ¹½¨Æ÷µÄ value() ÒªÁì»òÕß pluck() ÒªÁì¼´¿É¡£ÔÚʹÓõÄÀú³ÌÖÐ £¬ÐèҪƾ֤ÏÖʵÐèÇóÀ´Ñ¡ÔñºÏÊʵÄÒªÁì¡£

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

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

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

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

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

QR code
sitemap¡¢ÍøÕ¾µØͼ