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

laravelÅÌÎÊÌõ¼þ

laravel ÊÇÒ»¸ö»ùÓÚphpÓïÑÔ¿ª·¢µÄ¿ªÔ´ web Ó¦ÓóÌÐò¿ò¼Ü £¬ËüÓµÓмòÆÓ¡¢ÓÅÑŵÄÓï·¨ºÍÇ¿Ê¢µÄ¹¦Ð§ £¬ÊÇÏÖ´ú web Ó¦ÓóÌÐò¿ª·¢µÄÏȽøÖ¸ÄÏ ¡£ÆäÖÐÓÈΪÖ÷ÒªµÄÊÇËüÇ¿Ê¢µÄÅÌÎʹ¹½¨Æ÷ £¬Ê¹µÃÎÒÃÇ¿ÉÒÔÇáËɵع¹½¨³öÖØ´óµÄ sql ÅÌÎÊÓï¾ä £¬¶ø²»ÐèÒªÖ±½Ó²Ù×÷ sql Óï¾ä ¡£

ͨ¹ý±¾ÎĵÄѧϰ £¬Äã¿ÉÒÔÏàʶµ½ Laravel Öг£¼ûµÄÅÌÎÊÌõ¼þ¼°ÆäÓ÷¨ ¡£

»ù±¾µÄÅÌÎÊÒªÁì

Laravel ÌṩÁË select() ÒªÁìÀ´Ñ¡ÔñÐèÒªÅÌÎʵÄÁÐ £¬¿ÉÒÔÖ±½Óת´ïÁÐÃûµ½¸ÃÒªÁì»òÕßʹÓÃÊý×éÀ´×ª´ïÁÐÃû ¡£from() ·½¹æÔòÖ¸¶¨±íÃû ¡£ÀýÈç £¬ÒÔÏ´úÂë¿ÉÒÔÅÌÎÊ users ±íÖÐµÄ id ºÍ name ÁУº

$users = DB::table('users')
            ->select('id', 'name')
            ->get();

µÇ¼ºó¸´ÖÆ

³ýÁË select() ÒªÁìÖ®Íâ £¬Laravel »¹ÌṩÁË where() ÒªÁìÀ´Ìí¼Ó WHERE Ô¼ÊøÌõ¼þ ¡£ÀýÈç £¬ÒÔÏ´úÂëÅÌÎÊ users ±íÖÐËùÓÐÐÕ “Smith” µÄÈË£º

$users = DB::table('users')
            ->where('name', 'Smith')
            ->get();

µÇ¼ºó¸´ÖÆ

OR Ìõ¼þÅÌÎÊ

ÓÐʱ¼ä £¬ÔÚÅÌÎÊÊý¾ÝʱÎÒÃÇÐèҪʹÓà OR ÔËËã·ûÀ´ÅþÁ¬¶à¸öÌõ¼þ £¬ÅÌÎʶà¸öÌõ¼þÖÐÊʺϵÄÐÐ ¡£Laravel ÖпÉÒÔʹÓà orWhere() ÒªÁìÀ´ÊµÏÖ £¬Ê¾ÀýÈçÏ£º

$users = DB::table('users')
            ->where('name', 'Smith')
            ->orWhere('name', 'Johnson')
            ->get();

µÇ¼ºó¸´ÖÆ

ÉÏÊöÓï¾ä½«»áÏÈÅÌÎÊÐÕ “Smith” µÄËùÓÐÈË £¬È»ºóÅÌÎÊÐÕ “Johnson” µÄËùÓÐÈË £¬²¢½«ÕâÁ½¸öÅÌÎÊЧ¹ûÈ¡²¢¼¯ºó·µ»Ø ¡£

IN Ìõ¼þÅÌÎÊ

ÔÚ Laravel ÖÐ £¬¿ÉÒÔʹÓà whereIn() ÒªÁìʵÏÖ IN Ìõ¼þÅÌÎÊ ¡£ÒÔÏÂÊÇÒ»¸öʾÀý £¬Ëü½«ÅÌÎÊ users ±íÖÐËùÓÐÒÔ w¡¢x¡¢y¡¢z ×Öĸ´òÍ·µÄÃû×Ö£º

$users = DB::table('users')
            ->whereIn('name', ['W%', 'X%', 'Y%', 'Z%'])
            ->get();

µÇ¼ºó¸´ÖÆ

BETWEEN Ìõ¼þÅÌÎÊ

Laravel »¹ÌṩÁË whereBetween() ÒªÁì £¬¸ÃÒªÁìÓÃÓÚÅÌÎÊij¸ö×ֶεÄÊýÖµÊÇ·ñÔÚÖ¸¶¨µÄ¹æÄ£ÄÚ ¡£

ÒÔÏ´úÂ뽫ÅÌÎÊ users ±íÖÐ age ÁÐÔÚ 18 µ½ 30 Ö®¼äµÄÈË£º

$users = DB::table('users')
            ->whereBetween('age', [18, 30])
            ->get();

µÇ¼ºó¸´ÖÆ

³ýÁËÉÏÊöʾÆÆÀý £¬Laravel »¹ÌṩÁËÆäËûһЩÅÌÎÊÒªÁì £¬ÀýÈç whereNotBetween(), groupBy(), orderBy() µÈµÈ £¬ÕâЩҪÁì¿ÉÒÔ×ÊÖúÎÒÃÇÔ½·¢ÇáËɵع¹½¨ÖØ´óµÄ SQL ÅÌÎÊÓï¾ä ¡£

×ÜÖ® £¬Laravel ÌṩÁËÐí¶àÅÌÎÊÌõ¼þ £¬Àû±ã¿ª·¢Õß¹¹½¨Æ¾Ö¤ÐèÇóÅÌÎÊÊý¾ÝµÄ¹¦Ð§ ¡£ÎÒÃÇÖ»ÐèÒªÊìÁ·ÕÆÎÕÕâЩҪÁ첢׼ȷʹÓà £¬¾ÍÄܹ»¿ìËٵع¹½¨³öÖª×ãÐèÇóµÄÓ¦ÓóÌÐò ¡£

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

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

QR code
ÍøÕ¾µØͼ