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

[PHP]PDOµÄʹÓÃ

1. °²×°php5.1ÒÔÉϵİ汾,ÓÐÖ§³Öpdo!ΪÁËʹÄãµÄ»·¾³ÄÜÌṩ¶ÔpdoµÄÖ§³Ö!ÔÚphp.iniÎļþ¼ÓÈëÒÔÏÂ:
extension=php_pdo.dll
extension=php_pdo_mysql.dll
extension=php_pdo_mssql.dll(Ö§³ÖmssqlÊý¾Ý¿â)
2. ÒÔÏÂΪPHÖÐPDOµÄ¾ßÌåʹÓÃ
 <?php
$dsn = 'mysql:dbname=MyDbName;host=localhost';
$user = 'root';
$password = '666666';
try {
$dbCon = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
print 'Connection failed: '.$e->getMessage();
}
//------------pdo query example---------
$strSQL = "select * from Users";
//---------method1---------
try {
$result = $dbCon->query($strSQL);
if( $result ){
$uCol = $result ->columnCount();
$arRS = $result ->fetchAll();
foreach ($arRS as $row){
for( $i=0; $i<$uCol; $i++ )
print $row[$i]." ";
print "<br>";
}
}
}catch (PDOException $e) {
print $e->getMessage();
}

//---------method2---------
try {
$sth = $dbCon->prepare($strSQL);
$sth->execute();
$uCol = $sth->columnCount();

while($row = $sth->fetch()){
for( $i=0; $i<$uCol; $i++ )
print $row[$i]." ";
print "<br>";
}

$result = $sth->fetchAll();
foreach ($result as $row){
for( $i=0; $i<$uCol; $i++ )
print $row[$i]." ";
print "<br>";
}
}catch (PDOException $e) {
print $e->getMessage();
}
?>


Ïà¹ØÎĵµ£º

PHPÓëMySQL¿ª·¢ÖеÄ×Ö·û±àÂëÎÊÌâ

Ò»£®¹ØÓÚMySQLÊý¾Ý¿â·þÎñÆ÷
MySQL·þÎñÆ÷µÄĬÈϱàÂëÊÇLatin1£¬²»Ö§³ÖÖÐÎÄ£¬ÄÇôÈçºÎÐÞ¸ÄMySQLµÄĬÈϱàÂëÄØ£¬ÏÂÃæÒÔUTF-8ΪÀýÀ´ËµÃ÷¡£
1¡¢ÖÐÖ¹MySQL·þÎñ£¨bin/mysqladmin -u root shutdown£©
2¡¢ÔÚ/etc/ÏÂÕÒµ½my.cnf£¬Èç¹ûûÓоͰÑMySQLµÄ°²×°Ä¿Â¼ÏµÄsupport-filesĿ¼ÏµÄmy-medium.cnf¸´ÖƵ½/etc/ϲ¢¸ÄÃûΪmy.cnf¼´¿É ......

PHP ¿ª·¢±à¼­¹¤¾ß

Ç¿´ó¶øÇÒÃâ·ÑµÄ zend studio Ê×µ±Æä³å£¬¿Éϧ±¾ÈË»úÆ÷ÅäÖò»¸ß£¬ÔËÐÐÆðÀ´Ê®·Ö³ÔÁ¦£¬ÓÃûÁ½´ÎÌ«ÊÜ×ï¾Í·ÅÆúÁË¡£
PHPEdit£¬¶ÌС¾«º·£¬¿ÉÏÞʱÊÔÓ㬸оõÒ»°ã¡£
PHPDesigner ÕýÔÚÓ㬻¹ÊÇ¿ÉÒÔÒ»ÊÔ£¬ÍøÉϵÄ×¢²á»ú³öµÄÒ²Ï൱¼°Ê±¡£ 0.0
´¿Îı¾±à¼­ Editplus »¹Êdz£±¸¹¤¾ß¡£ ......

26¿î¹úÍ⿪ԴPHP½¨Õ¾³ÌÐò


¿ªÔ´½¨Õ¾³ÌÐòÈñà³Ì¸ßÊÖºÍÖ»¶®´ò×ÖÉÏÍøµÄÈ˶¼¿ÉÒÔ¿ìËÙ½¨Á¢Ò»¸ö¹¦ÄÜÇ¿´ó¡¢½çÃæƯÁÁµÄÍøÕ¾¡£²»¹ÜÄãÊÇÏ뽨һ¸ö²©¿Í¡¢ÂÛ̳¡¢CMS¡¢µç×ÓÉÌÎñÍøÕ¾£¬»òÊÇWiki¡¢Ïà²á¹ÜÀí¡¢RSS¾ÛºÏºÍÀàDiggÍøÕ¾¡£Ä㶼¿ÉÒÔͨ¹ýÕâЩ½¨Õ¾¹¤¾ß¿ìËÙ½¨Á¢¡£
ÎÒÃÇ֮ǰ½éÉܹý23¸ö¿ªÔ´µÄCMS¹ÜÀíϵͳ£¬ÏÖÔÚÔòÈÃÎÒÃÇÀ´¿´Ò»ÏÂ26¿î¿ªÔ´½¨Õ¾³ÌÐò¡£
¹úÍâPHP¿ªÔ´½¨ ......

phpÖе¥ÒýºÅºÍË«ÒýºÅÇø±ð

1 PHPÖе¥ÒýºÅÓëË«ÒýºÅµÄÇø±ð  
¡¡¡¡ÔÚPHPÖУ¬Í¨³£Ò»¸ö×Ö·û´®±»¶¨ÒåÔÚÒ»¶ÔÒýºÅÖУ¬È磺
'I am a string in single quotes'
"I am a string in double quotes"
¡¡¡¡PHPÓï·¨·ÖÎöÆ÷ÊÇÓóɶԵÄÒýºÅÀ´ÅжÏÒ»¸ö×Ö·û´®µÄ¡£Òò´Ë£¬ËùÓÐ×Ö·û´®±ØÐëʹÓÃͬһÖÖµ¥»òÕßË«
ÒýºÅÀ´¶¨Ò忪ʼºÍ½áÊø¡£ÀýÈ磬ÏÂÃæµÄ×Ö´®¶¨ÒåÊ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ