Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÔÚPHPÖÐÈ«Ãæ×èÖ¹SQL×¢Èëʽ¹¥»÷Ö®Èý

Ò»¡¢ ½¨Á¢Ò»¸ö°²È«³éÏó²ã
¡¡¡¡ÎÒÃDz¢²»½¨ÒéÄãÊÖ¹¤µØ°ÑÇ°Ãæ½éÉܵļ¼ÊõÓ¦ÓÃÓÚÿһ¸öÓû§ÊäÈëµÄʵÀýÖУ¬¶øÊÇÇ¿ÁÒÍƼöÄãΪ´Ë´´½¨Ò»¸ö³éÏó²ã¡£Ò»¸ö¼òµ¥µÄ³éÏóÊÇ°ÑÄãµÄУÑé·½°¸¼ÓÈëµ½Ò»¸öº¯ÊýÖУ¬²¢ÇÒÕë¶ÔÓû§ÊäÈëµÄÿһÏîµ÷ÓÃÕâ¸öº¯Êý¡£µ±È»£¬ÎÒÃÇ»¹¿ÉÒÔ´´½¨Ò»ÖÖ¸ü¸´Ôӵĸü¸ßÒ»¼¶µÄ³éÏó-°ÑÒ»¸ö°²È«µÄ²éѯ·â×°µ½Ò»¸öÀàÖУ¬´Ó¶øÓ¦ÓÃÓÚÕû¸öÓ¦ÓóÌÐò¡£ÔÚÍøÉÏÒѾ­´æÔÚÐí¶àÕâÖÖÏֳɵÄÃâ·ÑµÄÀࣻÔÚ±¾ÆªÖУ¬ÎÒÃÇÕýÒªÌÖÂÛÆäÖеÄһЩ¡£
¡¡¡¡½øÐÐÕâÖÖ³éÏóÖÁÉÙ´æÔÚÈý¸öÓŵ㣨¶øÇÒÿһ¸ö¶¼»á¸Ä½ø°²È«¼¶±ð£©£º
¡¡¡¡1. ±¾µØ»¯´úÂë¡£
¡¡¡¡2. ʹ²éѯµÄ¹¹Ôì¸ü¿ìÇÒ¸üΪ¿É¿¿-ÒòΪÕâ¿ÉÒ԰Ѳ¿·Ö¹¤×÷½»ÓɳéÏó´úÂëÀ´ÊµÏÖ¡£
¡¡¡¡3. µ±»ùÓÚ°²È«ÌØÕ÷½øÐй¹½¨²¢ÇÒÇ¡µ±Ê¹ÓÃʱ£¬Õ⽫»áÓÐЧµØ·ÀÖ¹ÎÒÃÇÇ°ÃæËùÌÖÂ۵ĸ÷ÖÖ¸÷ÑùµÄ×¢Èëʽ¹¥»÷¡£
¡¡¡¡¶þ¡¢ ¸Ä½øÏÖÓеÄÓ¦ÓóÌÐò
¡¡¡¡Èç¹ûÄãÏë¸Ä½øÒ»¸öÏÖÓеÄÓ¦ÓóÌÐò£¬ÔòʹÓÃÒ»¸ö¼òµ¥µÄ³éÏó²ãÊÇ×îÊʵ±µÄ¡£Ò»¸öÄܹ»¼òµ¥µØ"ÇåÀí"ÄãËùÊÕ¼¯µÄÈκÎÓû§ÊäÈëÄÚÈݵĺ¯Êý¿ÉÄÜ¿´ÆðÀ´ÈçÏÂËùʾ£º
function safe( $string ) {
¡¡return "'" . mysql_real_escape_string( $string ) . "'"
}
¡¡¡¡¡¾×¢Òâ¡¿ÎÒÃÇÒѾ­¹¹½¨ÁËÏàÓ¦ÓÚÖµÒªÇóµÄµ¥ÒýºÅÒÔ¼°mysql_real_escape_string()º¯Êý¡£½ÓÏÂÀ´£¬¾Í¿ÉÒÔʹÓÃÕâ¸öº¯ÊýÀ´¹¹ÔìÒ»¸ö$query±äÁ¿£¬ÈçÏÂËùʾ£º
$variety = safe( $_POST['variety'] );
$query = " SELECT * from wines WHERE variety=" . $variety;
¡¡¡¡ÏÖÔÚ£¬ÄãµÄÓû§ÊÔͼ½øÐÐÒ»¸ö×¢Èëʽ¹¥»÷-ͨ¹ýÊäÈëÏÂÁÐÄÚÈÝ×÷Ϊ±äÁ¿$varietyµÄÖµ£º
lagrein' or 1=1;
¡¡¡¡×¢Ò⣬Èç¹û²»½øÐÐÉÏÃæµÄ"ÇåÀí"£¬Ôò×îºóµÄ²éѯ½«ÈçÏÂËùʾ£¨Õ⽫µ¼ÖÂÎÞ·¨Ô¤ÁϵĽá¹û£©£º
SELECT * from wines WHERE variety = 'lagrein' or 1=1;'
¡¡¡¡È»¶øÏÖÔÚ£¬¼ÈÈ»Óû§µÄÊäÈëÒѾ­±»ÇåÀí£¬ÄÇô²éѯÓï¾ä¾Í³ÉΪÏÂÃæÕâÑùÒ»ÖÖÎÞΣº¦µÄÐÎʽ£º
SELECT * from wines WHERE variety = 'lagrein\' or 1=1\;'
¡¡¡¡¼ÈÈ»Êý¾Ý¿âÖв»´æÔÚÓëÖ¸¶¨µÄÖµÏàÓ¦µÄvarietyÓò(ÕâÕýÊǶñÒâÓû§ËùÊäÈëµÄÄÚÈÝ-lagrein' or 1=1;)£¬ÄÇô£¬Õâ¸ö²éѯ½«²»ÄÜ·µ»ØÈκνá¹û£¬²¢ÇÒ×¢È뽫»áʧ°Ü¡£
Èý¡¢ ±£»¤Ò»¸öеÄÓ¦ÓóÌÐò
¡¡¡¡Èç¹ûÄãÕýÔÚ´´½¨Ò»¸öеÄÓ¦ÓóÌÐò£¬ÄÇô£¬Äã¿ÉÒÔ´ÓÍ·¿ªÊ¼´´½¨Ò»¸ö°²È«³éÏó²ã¡£Èç½ñ£¬PHP 5иĽøµÄ¶ÔÓÚMySQLµÄÖ§³Ö£¨ÕâÖ÷ÒªÌåÏÖÔÚеÄmysqliÀ©Õ¹ÖУ©ÎªÕâÖÖ°²È«ÌØÕ÷ÌṩÁËÇ¿ÓÐÁ¦µÄÖ§³Ö£¨¼ÈÓйý³ÌÐԵģ¬Ò²ÓÐÃæÏò¶ÔÏóÌØÕ÷µÄ£©¡£Äã¿ÉÒÔ´ÓÕ¾µãhttp://php.net/mysqliÉÏ»ñÈ¡ÓйØmysqliµÄÐÅÏ¢¡£×¢Ò⣬ֻÓе


Ïà¹ØÎĵµ£º

SQL*Plus FAQ

 What is SQL*Plus and where does it come from?
SQL*Plus is a command line SQL and PL/SQL language interface and reporting tool that ships with the Oracle Database Client and Server software. It can be used interactively or driven from scripts. SQL*Plus is frequently used by DBAs and Developers ......

ʹÓÃset statistics on À´¼ì²ésql tuningµÄ½á¹û


ÔÚSQL Server2005/2008ÖпÉÒÔʹÓÃÒ»ÏÂËĸöÃüÁîÀ´µ÷ÓÅsqlÓï¾äÒÔ¼°¼ì²éµ÷ÓŵĽá¹û
set
 statistics time on

set
 statistics IO on

set
 statistics profile on

set
 statistics xml on

......

SQLÓï¾äÓÅ»¯Êµ¼ùÖ®Ò»SQL_TRACE

SQLÓï¾äÓÅ»¯Êµ¼ùÖ®Ò»SQL_TRACE
 
»·¾³£ºÔÚPL/sqlÉϵ÷ÊÔÊý¾Ý
Pl/sql developer¹¤¾ßÁ¬½ÓʵÀýºó¼´×÷Ϊһ¸öÓû§½ø³ÌÕ¼ÓÃÒ»¸ösession£»
 
select * from  v$session t  where t.PROGRAM='plsqldev.exe' and  t.USERNAME='DZJC'
²éѯ½á¹ûÏÔʾÁ˼¸¸ö¹Ø¼üµÄ×Ö¶Î
SADDR   RAW(4)  S ......

Sql ²éѯµ±Ìì¡¢±¾ÖÜ¡¢±¾Ô¼Ç¼

Sql´úÂë:Powered by chenjiazi
--²éѯµ±Ì죺   
select * from info where DateDiff(dd,datetime,getdate())=0   
  
--²éѯ24СʱÄÚµÄ:   
select * from info where DateDiff(hh,datetime,getDate())<=24   
  
--infoΪ±íÃû,datetimeΪÊý ......

ÔÚPHPÖÐÈ«Ãæ×èÖ¹SQL×¢Èëʽ¹¥»÷Ö®Ò»

Ò»¡¢ ÒýÑÔ
¡¡¡¡PHPÊÇÒ»ÖÖÁ¦Á¿Ç¿´óµ«Ï൱ÈÝÒ×ѧϰµÄ·þÎñÆ÷¶Ë½Å±¾ÓïÑÔ£¬¼´Ê¹ÊǾ­Ñé²»¶àµÄ³ÌÐòÔ±Ò²Äܹ»Ê¹ÓÃËüÀ´´´½¨¸´ÔӵĶ¯Ì¬µÄwebÕ¾µã¡£È»¶ø£¬ËüÔÚʵÏÖÒòÌØÍø·þÎñµÄÃØÃܺͰ²È«·½ÃæÈ´³£³£´æÔÚÐí¶àÀ§ÄÑ¡£ÔÚ±¾ÏµÁÐÎÄÕÂÖУ¬ÎÒÃǽ«Ïò¶ÁÕß½éÉܽøÐÐweb¿ª·¢Ëù±ØÐèµÄ°²È«±³¾°ÒÔ¼°PHPÌض¨µÄ֪ʶºÍ´úÂë-Äã¿ÉÒÔ½èÒÔ±£»¤Äã×Ô¼ºµÄwebÓ¦Óó ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ