لمحترفي الويبPHP - معمو — الصفحة ٨٦

الفصل الثالث 86 البرنامج النصي peardb1.php 7. $host = "192.168.0.1"; 8. $database = "php"; 9. 10. 11. 12. /* 13. 14. $dsn = "$type: //$user: $pass@$host/$database"; $dbconn = DB:: connect ($dsn); if (DB::isError ($dbconn)) { die ($dbconn->getMessage()); } create table bebop ( id INT, 15. name VARCHAR (8), 16. origin CHAR(2)); 17. */ 18. $values = array ( 19. 20. 21. 22. 23. "insert into bebop values "insert into bebop values "insert into bebop values "insert into bebop values "insert into bebop values ('0', 'Spike', 'MA')", ('1', 'Jett', 'AZ')" ('2', 'Faye', 'FL')" ('3', 'Ed', 'NM')" ('4', 'Ein', 'CO')" 24. ); 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. $result = $dbconn->query("select * from bebop"); if (DB::isError ($result)) { die ($result->getMessage()); } if ($result->numRows() == 0) { echo "<P>Populating the DB!<p>"; for($i = 0; $i < sizeof ($values); $i++) { $result2= $dbconn->query ($values [$i]); if (DB::isError ($result2)) { die ($result2->getMessage()); } } echo "<P>Done the DB! Reload Page<p>"; 35. } else { $result = $dbconn->query("select name, origin from bebop"); if (DB::isError ($result)) { die ($result->getMessage()); } echo "<P>Default Fetch Mode (DB_FETCHMODE_ORDERED): "; while($result->fetchinto ($row)) { 36. 37. 38. 39. 40. echo <br>" $row[0] 11 11 . 41. } 42. $result = $dbconn->query("select name, origin from bebop"); $row[1];
ص٨٦

نص مستخرج آليًا من الصورة، وقد يقع فيه خطأ.