PHP PDO »ù´¡
PHP PDO »ù´¡
http://blog.csdn.net/nailwl/archive/2009/10/27/4733655.aspx
PDOÊÇÒ»¸ö“Êý¾Ý¿â·ÃÎʳéÏó²ã”£¬×÷ÓÃÊÇͳһ¸÷ÖÖÊý¾Ý¿âµÄ·ÃÎʽӿڣ¬ÓëmysqlºÍmysqliµÄº¯Êý¿âÏà±È£¬PDOÈÿçÊý¾Ý¿âµÄʹÓøü¾ßÓÐÇ׺ÍÁ¦£»ÓëADODBºÍMDB2Ïà±È£¬PDO¸ü¸ßЧ¡£Ä¿Ç°¶øÑÔ£¬ÊµÏÖ“Êý¾Ý¿â³éÏó²ã”ÈÎÖضøµÀÔ¶£¬Ê¹ÓÃPDOÕâÑùµÄ“Êý¾Ý¿â·ÃÎʳéÏó²ã”ÊÇÒ»¸ö²»´íµÄÑ¡Ôñ¡£
PDO->beginTransaction() — ±êÃ÷»Ø¹öÆðʼµã
PDO->commit() — ±êÃ÷»Ø¹ö½áÊøµã£¬²¢Ö´ÐÐSQL
PDO->__construct() — ½¨Á¢Ò»¸öPDOÁ´½ÓÊý¾Ý¿âµÄʵÀý
PDO->errorCode() — »ñÈ¡´íÎóÂë
PDO->errorInfo() — »ñÈ¡´íÎóµÄÐÅÏ¢
PDO->exec() — ´¦ÀíÒ»ÌõSQLÓï¾ä£¬²¢·µ»ØËùÓ°ÏìµÄÌõÄ¿Êý
PDO->getAttribute() — »ñÈ¡Ò»¸ö“Êý¾Ý¿âÁ¬½Ó¶ÔÏó”µÄÊôÐÔ
PDO->getAvailableDrivers() — »ñÈ¡ÓÐЧµÄPDOÇý¶¯Æ÷Ãû³Æ
PDO->lastInsertId() — »ñȡдÈëµÄ×îºóÒ»ÌõÊý¾ÝµÄÖ÷¼üÖµ
PDO->prepare() — Éú³ÉÒ»¸ö“²éѯ¶ÔÏó”
PDO->query() — ´¦ÀíÒ»ÌõSQLÓï¾ä£¬²¢·µ»ØÒ»¸ö“PDOStatement”
PDO->quote() — Ϊij¸öSQLÖеÄ×Ö·û´®Ìí¼ÓÒýºÅ
PDO->rollBack() — Ö´Ðлعö
PDO->setAttribute() — Ϊһ¸ö“Êý¾Ý¿âÁ¬½Ó¶ÔÏó”É趨ÊôÐÔ
PDOStatement->bindColumn() — Bind a column to a PHP variable
PDOStatement->bindParam() — Binds a parameter to the specified variable name
PDOStatement->bindValue() — Binds a value to a parameter
PDOStatement->closeCursor() — Closes the cursor, enabling the statement to be executed again.
PDOStatement->columnCount() — Returns the number of columns in the result set
PDOStatement->errorCode() — Fetch the SQLSTATE associated with the last operation on the statement handle
PDOStatement->errorInfo() — Fetch extended error information associated with the last operation on the statement handle
PDOStatement->execute() — Executes a prepared statement
PDOStatement->fetch() — Fetches the next row from a result set
PDOStatement->fetchAll(
Ïà¹ØÎĵµ£º
//1. Óû§ÃÜÂëÁùλÊý,²»ÄÜ´óÓÚÁùλ¶ø²»ÄÜСÓÚÁùÊý,Êý×ÖÖµÕýÔòΪ[0-9],ÇëÓÃPHPд³öÓм¸ÖÖ¿ÉÄÜÐÔ,²¢×ö±©Á¦Æƽâ;
function dePassword($pwd) {
$tmp = array('000000', '555555', '999999');
for ($i = 0; $i < 3; $i++) {
if ($pwd == $tmp[$i]) return $tmp[$i];
}
return $pwd < $tmp[1] ? getPwd(0, $pwd ......
1 ¿ªÊ¼Ð´PHP³ÌÐò
¸úѧC/C++¡¢javaÒ»Ñù£¬ÎÒÃÇÏÈ´Óhello world¿ªÊ¼£º
PHP µÄ½Å±¾¿éÒÔ <?php ¿ªÊ¼£¬ÒÔ ?> ½áÊø¡£Äú¿ÉÒÔ°Ñ PHP µÄ½Å±¾¿é·ÅÖÃÔÚhtmlÎĵµÖеÄÈκÎλÖᣵ±È»£¬ÔÚÖ§³Ö¼òдµÄ·þÎñÆ÷ÉÏ£¬Äú¿ÉÒÔʹÓà <? ºÍ ?> À´¿ªÊ¼ºÍ½áÊø½Å±¾¿é¡£²»¹ý£¬ÎªÁË´ïµ½×îºÃµÄ¼æÈÝÐÔ£¬ÎÒÃÇÍƼöÄúʹÓñê×¼ÐÎʽ£¨ <?php£© £¬¶ ......
Ñ»·Óï¾ä
ÔÚÄú±àд´úÂëʱ£¬Äú¾³£ÐèÒªÈÃÏàͬµÄ´úÂë¿éÔËÐкܶà´Î¡£Äú¿ÉÒÔÔÚ´úÂëÖÐʹÓÃÑ»·Óï¾äÀ´Íê³ÉÕâ¸öÈÎÎñ¡£
ÔÚ PHP ÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÁÐÑ»·Óï¾ä£º
while
Ö»ÒªÖ¸¶¨µÄÌõ¼þ³ÉÁ¢£¬ÔòÑ»·Ö´ÐдúÂë¿é
do...while
Ê×ÏÈÖ´ÐÐÒ»´Î´úÂë¿é£¬È»ºóÔÚÖ¸¶¨µÄÌõ¼þ³ÉÁ¢Ê±Öظ´Õâ¸öÑ»·
for
Ñ»·Ö´ÐдúÂë¿éÖ¸¶¨µÄ´ÎÊý
foreach
¸ù ......
Êý×é
ÔÚʹÓà PHP ½øÐпª·¢µÄ¹ý³ÌÖУ¬»òÔç»òÍí£¬Äú»áÐèÒª´´½¨Ðí¶àÏàËƵıäÁ¿¡£ÎÞÐèºÜ¶àÏàËƵıäÁ¿£¬Äã¿ÉÒÔ°ÑÊý¾Ý×÷ΪԪËØ´æ´¢ÔÚÊý×éÖС£Êý×éÖеÄÔªËض¼ÓÐ×Ô¼ºµÄ ID£¬Òò´Ë¿ÉÒÔ·½±ãµØ·ÃÎÊËüÃÇ¡£
ÓÐÈýÖÖÊý×éÀàÐÍ£º
ÊýÖµÊý×é
´øÓÐÊý×Ö ID ¼üµÄÊý×é
¹ØÁªÊý×é
Êý×éÖеÄÿ¸ö ID ¼ü¹ØÁªÒ»¸öÖµ
¶àάÊý×é
°üº¬Ò»¸ö»ò¶à¸öÊý×éµÄ ......
PHP
Îļþ´¦Àí
fopen()
º¯ÊýÓÃÓÚÔÚ
PHP
Öдò¿ªÎļþ¡£
´ò¿ªÎļþ
fopen()
º¯ÊýÓÃÓÚÔÚ
PHP
Öдò¿ªÎļþ¡£
´Ëº¯ÊýµÄµÚÒ»¸ö²ÎÊýº¬ÓÐÒª´ò¿ªµÄÎļþµÄÃû³Æ£¬µÚ¶þ¸ö²ÎÊý¹æ¶¨ÁËʹÓÃÄÄÖÖģʽÀ´´ò¿ªÎļþ£º
<html>
<body>
<?php
$file=fopen("welcome.txt","r");
?>
......