thinkphpÔõôÅÌÎÊ´óÓÚij¸öÖµµÄÊý¾Ý
ÔÚweb¿ª·¢ÖУ¬Êý¾ÝÅÌÎÊÊǺÜÊÇÖ÷ÒªµÄÒ»²¿·Ö¡£ÈôÊÇÄúÕýÔÚʹÓÃphp¼Ü¹¹thinkphp¿ª·¢£¬²¢ÐèÒªÅÌÎÊ´óÓÚij¸öÖµµÄÊý¾Ý£¬ÄÇô±¾ÎĽ«ÎªÄúÌṩָÒýºÍ˼Ð÷¡£
Ê×ÏÈ£¬ÎÒÃÇÐèÒªÏàʶÔÚThinkPHPÖÐÔõÑù¾ÙÐÐÊý¾ÝÅÌÎÊ¡£ThinkPHPĬÈÏʹÓÃORM£¨¹¤¾ß¹ØϵӳÉ䣩·½·¨¾ÙÐÐÊý¾Ý¿â²Ù×÷¡£ÕâÒâζ×ÅÄú¿ÉÒÔʹÓÃÀû±ãµÄº¯ÊýÀ´¹¹½¨ÅÌÎÊ¡£ÀýÈ磬ÈôÊÇÒªÅÌÎÊÃûΪ¡°users¡±µÄ±í¸ñÖÐÄêËê´óÓÚ30µÄÓû§£¬Äú¿ÉÒÔʹÓÃÒÔÏ´úÂ룺
$users = Db::table('users')->where('age', '>', 30)->select();
µÇ¼ºó¸´ÖÆ
ÔÚÕâ¸öÅÌÎÊÖУ¬¡°Db::table(‘users’)¡±ÌåÏÖÎÒÃÇÒªÅÌÎʵıí¸ñÊÇ¡°users¡±¡£¶ø¡°where(‘age’, ‘>’, 30)¡±ÔòÌåÏÖÎÒÃÇÒªÅÌÎʵÄÊÇÄêËê´óÓÚ30µÄÓû§¡£
½ÓÏÂÀ´£¬ÈÃÎÒÃÇ¿´Ò»ÏÂÔõÑùÅÌÎÊÈÕÆÚÀàÐ͵ÄÊý¾Ý¡£ÔÚThinkPHPÖУ¬Ä¬ÈÏʹÓÃPHPµÄÈÕÆÚÃûÌþÙÐÐÈÕÆÚÅÌÎÊ¡£ÀýÈ磬ÈôÊÇÒªÅÌÎÊÃûΪ¡°events¡±µÄ±í¸ñÖÐÈÕÆÚ´óÓÚ2019-01-01µÄÊÂÎñ£¬Äú¿ÉÒÔʹÓÃÒÔÏ´úÂ룺
$events = Db::table('events')->where('date', '>', '2019-01-01')->select();
µÇ¼ºó¸´ÖÆ
ÔÚÕâ¸öÅÌÎÊÖУ¬¡°where(‘date’, ‘>’, ‘2019-01-01’)¡±ÔòÌåÏÖÎÒÃÇÒªÅÌÎʵÄÊÇÈÕÆÚ´óÓÚ2019-01-01µÄÊÂÎñ¡£
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
ÏÖÔÚ£¬ÈÃÎÒÃÇÀ´¿´Ò»ÏÂÔõÑùÅÌÎÊ´óÓÚij¸öÖµµÄÊý¾Ý¡£ÔÚSQLÓïÑÔÖУ¬ÎÒÃÇ¿ÉÒÔʹÓá°>¡±·ûºÅÀ´¾ÙÐдóÓÚÅÌÎÊ¡£ÔÚThinkPHPÖУ¬ÎÒÃÇ¿ÉÒÔʹÓá°where¡±º¯ÊýÖеĵڶþ¸ö²ÎÊýÀ´¾ÙÐдóÓÚÅÌÎÊ¡£ÀýÈ磬ÈôÊÇÒªÅÌÎÊÃûΪ¡°products¡±µÄ±í¸ñÖмÛÇ®´óÓÚ100µÄÉÌÆ·£¬Äú¿ÉÒÔʹÓÃÒÔÏ´úÂ룺
$products = Db::table('products')->where('price', '>', 100)->select();
µÇ¼ºó¸´ÖÆ
ÔÚÕâ¸öÅÌÎÊÖУ¬¡°where(‘price’, ‘>’, 100)¡±ÔòÌåÏÖÎÒÃÇÒªÅÌÎʵÄÊǼÛÇ®´óÓÚ100µÄÉÌÆ·¡£
ÔÚÏÖʵ¿ª·¢ÖУ¬Äú¿ÉÄÜÐèҪͬʱ¾ÙÐжà¸öÅÌÎÊÌõ¼þµÄ¹¹½¨¡£ÔÚThinkPHPÖУ¬Äú¿ÉÒÔʹÓöà¸ö¡°where¡±º¯ÊýÀ´¹¹½¨¶à¸öÅÌÎÊÌõ¼þ¡£ÀýÈ磬ÈôÊÇÒªÅÌÎÊÃûΪ¡°products¡±µÄ±í¸ñÖмÛÇ®´óÓÚ100ÇÒÊýÄ¿´óÓÚ10µÄÉÌÆ·£¬Äú¿ÉÒÔʹÓÃÒÔÏ´úÂ룺
$products = Db::table('products') ->where('price', '>', 100) ->where('quantity', '>', 10) ->select();
µÇ¼ºó¸´ÖÆ
ÔÚÕâ¸öÅÌÎÊÖУ¬¡°where(‘price’, ‘>’, 100)¡±ºÍ¡°where(‘quantity’, ‘>’, 10)¡±»®·ÖÌåÏÖÎÒÃÇÒªÅÌÎʵÄÊǼÛÇ®´óÓÚ100ºÍÊýÄ¿´óÓÚ10µÄÉÌÆ·¡£
×îºó£¬ÖµµÃ×¢ÖصÄÊÇ£¬ÅÌÎÊ´óÓÚij¸öÖµµÄÊý¾ÝÔÚÏÖʵ¿ª·¢ÖпÉÄÜ»á½ÏÁ¿³£¼û¡£ÒÔÊÇ£¬ÏàʶÔõÑù¾ÙÐÐÕâÖÖÀàÐ͵ÄÊý¾ÝÅÌÎʺÜÊÇÖ÷Òª¡£Ï£Íû±¾ÎÄÄÜΪÄúÌṩÓÐÓõÄÖ¸ÒýºÍ˼Ð÷¡£
ÒÔÉϾÍÊÇthinkphpÔõôÅÌÎÊ´óÓÚij¸öÖµµÄÊý¾ÝµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡