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

sqlÖÐ$µÄ×÷ÓÃ

sql ÖÐ $ ·ûºÅµÄ×÷ÓÃÓÐÈý¸ö£ºÌåÏÖ²ÎÊýռλ·û£¬ÀýÈç select * from users where id = $1;תÒåÌØÊâ×Ö·û£¬ÀýÈç select * from users where name = ‘$name’;ÌåÏÖ±äÁ¿£¬ÀýÈçÔÚ postgresql ÖУ¬$$name$$ ÌåÏֻỰ±äÁ¿¡£

SQL ÖÐ $ ·ûºÅµÄ×÷ÓÃ

ÔÚ SQL ÖУ¬$ ·ûºÅ¾ßÓÐÒÔÏÂ×÷Óãº

ÓÃÓÚÌåÏÖ²ÎÊýռλ·û

$ ·ûºÅ×î³£ÓõÄÓÃ;ÊÇÌåÏÖ²ÎÊýռλ·û¡£ÔÚ×¼±¸Óï¾äÖУ¬Ê¹Óà $ ·ûºÅÀ´Ö¸¶¨²ÎÊýµÄλÖã¬È»ºóÔÚÖ´ÐÐÓï¾äʱÌṩÏÖʵ²ÎÊýÖµ¡£ÕâÓÐÖúÓÚ±ÜÃâ SQL ×¢Èë¹¥»÷£¬²¢Ìá¸ß³ÌÐòµÄЧÂʺͿÉά»¤ÐÔ¡£

ʾÀý£º

SELECT * FROM users WHERE id = $1;

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÀý×ÓÖУ¬$1 ռλ·ûÌåÏÖÒ»¸öÕûÐͲÎÊý£¬½«ÔÚÖ´ÐÐÓï¾äʱÌṩ¡£

ÓÃÓÚתÒåÌØÊâ×Ö·û

µ±ÐèÒªÔÚ×Ö·û´®ÖаüÀ¨ÌØÊâ×Ö·ûʱ£¬¿ÉÒÔʹÓà $ ·ûºÅÀ´×ªÒåÕâЩ×Ö·û£¬ÒÔ±ÜÃâÆÊÎöÆ÷½«ËüÃÇÊÓΪ SQL Óï¾äµÄÒ»²¿·Ö¡£

ʾÀý£º

SELECT * FROM users WHERE name = '$name';

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÀý×ÓÖУ¬$name ±äÁ¿°üÀ¨Ò»¸ö×Ö·û´®Öµ£¬¿ÉÄÜ°üÀ¨ÌØÊâ×Ö·û(ÀýÈçµ¥ÒýºÅ)¡£Ê¹Óà $ ·ûºÅתÒåµ¥ÒýºÅ¿ÉÒÔÈ·±£Ëü²»»á±»ÆÊÎöÆ÷Ú¹ÊÍΪÓï¾ä¿¢Ê·û¡£

ÓÃÓÚÌåÏÖ±äÁ¿

ÔÚijЩÇéÐÎÏ£¬$ ·ûºÅ¿ÉÒÔÓÃÓÚÌåÏÖ±äÁ¿¡£ÀýÈ磬ÔÚ PostgreSQL ÖУ¬$ ·ûºÅ¿ÉÒÔÌåÏֻỰ±äÁ¿¡£

ʾÀý£º

SELECT * FROM users WHERE name = $$name$$;

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÀý×ÓÖУ¬$$name$$ ÌåÏÖÒ»¸ö»á»°±äÁ¿£¬½«ÔÚÓï¾äÖ´ÐÐÇ°ÆÊÎö¡£

ÒÔÉϾÍÊÇsqlÖÐ$µÄ×÷ÓõÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

QR code
ÍøÕ¾µØͼ