尊龙凯时人生就是博

thinkphp¿ò¼ÜÔõÑùÅÌÎÊÊý¾Ý

Ò»¡¢»ù±¾ÅÌÎÊ

ÔÚThinkPHP¿ò¼ÜÖУ¬¿ÉÒÔʹÓÃÄ£×ÓÀàµÄfind¡¢select¡¢where¡¢orderµÈÒªÁì¾ÙÐлù±¾µÄÅÌÎʲÙ×÷¡£

£¨1£©findÒªÁì

findÒªÁìÓÃÓÚÅÌÎÊÒ»ÌõÊý¾Ý¼Í¼£¬¿ÉÒÔÖ±½Óƾ֤Ö÷¼ü¾ÙÐÐÅÌÎÊ¡£ÀýÈ磺

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡± £»

$user = UserModel::find(1);

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂ뽫´ÓUserModelÄ£×ÓÀàÖÐÅÌÎÊIDΪ1µÄÓû§¼Í¼¡£

£¨2£©selectÒªÁì

selectÒªÁì¿ÉÓÃÓÚ¼ìË÷¶àÌõÊý¾Ý¼Í¼£¬²¢¿ÉʹÓÃwhereºÍorderµÈÒªÁì¶ÔÆä¾ÙÐÐÏÞÖƺÍÅÅÐò¡£ÀýÈ磺

$list = UserModel::where('age', '>', 18)->order('id desc')->select();

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂ뽫´ÓUserModelÄ£×ÓÀàÖÐÅÌÎÊÄêËê´óÓÚ18ËêµÄËùÓÐÓû§¼Í¼£¬²¢Æ¾Ö¤IDµ¹ÐòÅÅÐò¡£

£¨3£©whereÒªÁì

whereÒªÁìÓÃÓÚÉèÖÃÌõ¼þ£¬¿ÉÒÔÓÃÓÚ»ù±¾ÅÌÎʺÍͳ¼ÆÅÌÎÊ¡£ÀýÈ磺

$count = UserModel::where('gender', 1)->count();

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂ뽫ͳ¼ÆUserModelÄ£×ÓÀàÖÐÐÔ±ðΪÄеÄÓû§¸öÊý¡£

£¨4£©orderÒªÁì

orderÒªÁìÓÃÓÚÉèÖÃÅÅÐò¡£ÀýÈ磺

$list = UserModel::order('id desc')->select();

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂ뽫´ÓUserModelÄ£×ÓÀàÖÐÅÌÎÊËùÓÐÓû§¼Í¼£¬²¢Æ¾Ö¤IDµ¹ÐòÅÅÐò¡£

¶þ¡¢¸ß¼¶ÅÌÎÊ

³ýÁË»ù±¾µÄÅÌÎʲÙ×÷£¬ThinkPHP¿ò¼Ü»¹ÌṩÁËÇ¿Ê¢µÄ¸ß¼¶ÅÌÎʹ¦Ð§£¬°üÀ¨¶à±íÅÌÎÊ¡¢Á¬±íÅÌÎÊ¡¢Í³¼ÆÅÌÎʵÈ¡£

£¨1£©¶à±íÅÌÎÊ

ÔÚ¶à±íÅÌÎÊʱ£¬ÐèҪʹÓöà¸öÄ£×ÓÀà¡£ÀýÈ磺

$list = UserModel::alias('u')->join('order o', 'u.id = o.user_id')->where('u.age', '>', 18)->select();

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂ뽫´ÓUserModelºÍOrderModelÄ£×ÓÀàÖÐÅÌÎÊÄêËê´óÓÚ18ËêµÄËùÓÐÓû§ºÍËûÃǵĶ©µ¥¼Í¼¡£

£¨2£©Á¬±íÅÌÎÊ

Á¬±íÅÌÎÊÊǶà±íÅÌÎʵÄÆäÖÐÒ»ÖÖÐÎʽ£¬Ê¹ÓÃThinkPHPµÄjoinÒªÁì²Ù×÷£º

$list = UserModel::join('order o', 'user.id = o.user_id')->select();

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂ뽫´ÓUserModelºÍOrderModelÄ£×ÓÀàÖÐÅÌÎÊËùÓÐÓû§ºÍËûÃǵĶ©µ¥¼Í¼¡£

£¨3£©Í³¼ÆÅÌÎÊ

ÔÚͳ¼ÆÅÌÎÊʱ£¬¿ÉÒÔʹÓÃÄ£×ÓÀàµÄcountÒªÁì¾ÙÐвÙ×÷£¬ÀýÈ磺

$count = UserModel::where('age', '>', 18)->count();

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂ뽫ͳ¼ÆUserModelÄ£×ÓÀàÖÐÄêËê´óÓÚ18ËêµÄÓû§ÊýÄ¿¡£

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

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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