530 likes | 738 Views
2001/03/16. PHP4????PostgreSQL????????. 2. ?????. PHP?????????PHP3?PHP4???PHP4?????????????PEAR DB??????????????????????. 2001/03/16. PHP4????PostgreSQL????????. 3. PHP??. ??Web????????????????PHP: Hypertext PreprocesserHTML?????C?????Apache???????????????????????????????????????????????
E N D
1. PHP4????PostgreSQL???????? ????
(?)???·????
koyama@beatcraft.com
2. 2001/03/16 PHP4????PostgreSQL???????? 2 ????? PHP???
??????
PHP3?PHP4???
PHP4?????????????
PEAR DB???????
????????????
???
3. 2001/03/16 PHP4????PostgreSQL???????? 3 PHP?? ??Web????????????????
PHP: Hypertext Preprocesser
HTML?????
C?????
Apache???????????
??????????????????
????????????????????????????
4. 2001/03/16 PHP4????PostgreSQL???????? 4 ??????????? PHP/FI??
Perl?????cgi?????
Rasmus Lerdorf????
???C?????
Personal Home Page Tools???????
Personal Home Page Construction Kit
???????? FI (Form Interpreter)???
PHP/FI 2.0
5. 2001/03/16 PHP4????PostgreSQL???????? 5 ??(2) PHP3????
Andi Gutmans?, Zeev Suraski?
??????????????
PHP4????
Zend???????????
6. 2001/03/16 PHP4????PostgreSQL???????? 6 ????? <html>
<head>
<title>PHP test</title>
</head>
<body>
<?php echo "Hello World<p>"; ?>
</body>
</html>
7. 2001/03/16 PHP4????PostgreSQL???????? 7 ??(1) $???????
?????????????
<?php echo $HTTP_USER_AGENT; ?>
?Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)
<?php phpinfo( ); ?>
8. 2001/03/16 PHP4????PostgreSQL???????? 8 ??? <?php
if (strstr($HTTP_USER_AGENT, "MSIE")) {
echo "You are using Internet Explorer<br>";
}
else {
echo "You are not using Internet Explorer<br>";
}
?>
9. 2001/03/16 PHP4????PostgreSQL???????? 9 ??????????? <form action="action.php" method="post">
Your name: <input type="text" name="name">
Your age: <input type="text" name="age">
<input type="submit">
</form>
10. 2001/03/16 PHP4????PostgreSQL???????? 10 ??(2) ?????????????
(0 == "") -> true
?????????????
(0 === "") -> false
?????????????
$hoge = 1;
echo $hgoe;
11. 2001/03/16 PHP4????PostgreSQL???????? 11 ??(3) local?????????????global?????????
function func() {
global $hoge;
echo $hoge;
}
$hoge = "funya";
func();
12. 2001/03/16 PHP4????PostgreSQL???????? 12 ??(1) ??????????
?????????
$ar = array( "a" => "A", "b" => "B" );
$ar[ ] = "C";
$ar[ ] = "D";
print_r( $ar );
13. 2001/03/16 PHP4????PostgreSQL???????? 13 ??(2) ????????????
reset( $ar );
while (list($key, $val) = each($ar)) {
echo "$key: $val\n";
}
reset() ??????????
14. 2001/03/16 PHP4????PostgreSQL???????? 14 ??(3) reset() ????????????
foreach ($ar as $val) {
echo $val;
}
foreach ($ar as $key => $val) {
echo "$key: $val\n";
}
15. 2001/03/16 PHP4????PostgreSQL???????? 15 ??(1) ???????
function funcname( $arg1, $arg2 = "hoge" ) {
:
}
16. 2001/03/16 PHP4????PostgreSQL???????? 16 ??(2) ??????????
function hoge() {
return array( 1, "a" );
}
list( $num, $str ) = hoge();
17. 2001/03/16 PHP4????PostgreSQL???????? 17 ??(3) ????????????
function hoge( &$a ) {
$a++;
}
$fuga = 1;
hoge( $fuga );
18. 2001/03/16 PHP4????PostgreSQL???????? 18 ??? ????????
class Base {
var $a;
function hoge() { }
}
class Derived extends Base {
var $b;
function fuga() { }
}
19. 2001/03/16 PHP4????PostgreSQL???????? 19 PHP3???? ???????????(????)???????
????PHP-3.0.18-i18n-ja-2
php.ini????????????????????
??????????????????
PHP4??????????,????????
20. 2001/03/16 PHP4????PostgreSQL???????? 20 PHP4??? Zend Script Engine???
???????
Reference Counting
Here Printing
Extention API ?????
????????
??????????
PCRE (Perl Compatible Regular Expressions)
Output Buffer?????
21. 2001/03/16 PHP4????PostgreSQL???????? 21 PHP4??? PHP3???????????
??????????????????(?????)
?????????????????????? ? jstring
ftp://night.fminn.nagano.nagano.jp/php4/
???????????????????
22. 2001/03/16 PHP4????PostgreSQL???????? 22 PHP4?????????(1) ???
PHP4??Output Buffering???
?????????????????
???jstring?????????
Content-Type???????
???????????????????
???????????????????
23. 2001/03/16 PHP4????PostgreSQL???????? 23 PHP4?????????(2) ???(??)
Get/Post ????????????????
$HTTP_POST_VARS, $HTTP_GET_VARS
???????????????????????????????????????
??????????EUC-JP????????
????
24. 2001/03/16 PHP4????PostgreSQL???????? 24 charconv.inc class CConv
???????????????????????????
????PHP3???????????
??: EUC-JP
??: SJIS
????????
25. 2001/03/16 PHP4????PostgreSQL???????? 25 CConv???(1) ??
<?php CConv::start(); ?>
<html>
<head><title>??????</title></head>
<body>
<?php echo "??????<br>\n"; ?>
</body>
</html>
<?php CConv::finish(); ?>
26. 2001/03/16 PHP4????PostgreSQL???????? 26 CConv???(2) ??????????????
<?php
CConv::convAll();
// $input_value???
?>
CConv::start() ????? convAll() ??????
????HTML??????????? start() ???OK
??????
<input type="hidden" name="__encoding" value="?????????">
27. 2001/03/16 PHP4????PostgreSQL???????? 27 PEAR???? PHP Extention and Add-on Repository
TeX?CTAN?Perl?CPAN?Ruby?RAA
PHP??????????????????
Stig Bakken????????????
PHP????????????????????? Reference Code
PHPLib?PEAR?????????????
28. 2001/03/16 PHP4????PostgreSQL???????? 28 PEAR DB PEAR????DB???
????DBMS????PHP?????????????
????C?????????????PHP??????????
???????????DB????????????????
Perl?DBI + DBD?????
29. 2001/03/16 PHP4????PostgreSQL???????? 29 PEAR DB???(1) ??
$con_str = "host=localhost dbname=phptest user=koyama password=xxxx";
$con = pg_connect( $con_str );
$sql = "select * from test_tbl";
$result = pg_exec( $con, $sql );
$vals = pg_fetch_row( $result, 0 );
foreach($vals as $val) {
echo "val: $val<br>\n";
}
pg_freeresult( $result );
pg_close( $con );
30. 2001/03/16 PHP4????PostgreSQL???????? 30 PEAR DB???(2) PEAR DB????
require_once( "DB.php" );
$dsn = "pgsql://koyama:xxxx@localhost/phptest";
$db = DB::connect( $dsn );
$sql = "select * from test_tbl";
$result = $db->simpleQuery( $sql );
$vals = $db->fetchRow( $result );
foreach ($vals as $val) {
echo "val: $vals<br>\n";
}
$db->freeresult( $result );
$db->disconnect();
31. 2001/03/16 PHP4????PostgreSQL???????? 31 DB??????? SQL??????????????
???SQL??????????
???????1??????????????
select * from test_tbl where xxx='xxx'
?????????????SQL???????????????????
32. 2001/03/16 PHP4????PostgreSQL???????? 32 ????????? 1?????????????
?????????????????
primary key????????/???????
SQL?????????
?????????????????????
?DBMS?????????
????????????
33. 2001/03/16 PHP4????PostgreSQL???????? 33 ???? PostgreSQL-7.0.3
PHP-4.0.4pl1
PHP4?????????????PHP3????????
PHP-4.0.4???PHP4????????????????????????
?????????????????
Create table t1 (
v1 int primary key,
v2 text,
v3 bool,
v4 date
);
34. 2001/03/16 PHP4????PostgreSQL???????? 34 hoge1.php pg_xxx()??????
pgsql???????????????
DB?????????????????????????????????
35. 2001/03/16 PHP4????PostgreSQL???????? 35 hoge2.php PEAR DB????????
DSN(data source name)?????????????DBMS??????????
?????Oracle??PostgreSQL????????
??????DBMS??????????????(?)
36. 2001/03/16 PHP4????PostgreSQL???????? 36 hoge3.php ???????????????
?????????????
????????????????????????????????
???????SQL??????
select / insert / update /delete
PostgreSQL??bool???t??f???????PHP? true/false???
???? '' ???
???
???? insert/update????????????
37. 2001/03/16 PHP4????PostgreSQL???????? 37 hoge4.php ???????????????
load/insert/update ?? setup/commit ?
commit()?????DB????????????????????insert/update ??????
getValsForDB()
insert/update ????
38. 2001/03/16 PHP4????PostgreSQL???????? 38 hoge4.php???? ????t1????????
????????????????????????
????????????????????
??????
39. 2001/03/16 PHP4????PostgreSQL???????? 39 ??????????? ?????????????
?????
?????????
primary key
??????????????????????????????
40. 2001/03/16 PHP4????PostgreSQL???????? 40 hoge5.php(1) class AbstructTable
?????????
??????????????3?????????????
getTableName()
getPrimaryKey()
getType()
??
primary key??????????????
setup() ?1???????????
41. 2001/03/16 PHP4????PostgreSQL???????? 41 hoge5.php(2) setup()
????????????DB??????
keyCheck()
primary key???????
primary key??????????/????????
makeWhereStr()
where??????
42. 2001/03/16 PHP4????PostgreSQL???????? 42 hoge5.php(3) getVal()
???????SQL???????????
???? ' ' ???
???? NULL????
exists()
?????????????????????
primary key??????select????
??????????????????
43. 2001/03/16 PHP4????PostgreSQL???????? 43 hoge5.php(4) commit()
exists()???????update()/inset() ?????
load()
?????DB?????????????????????
DB_FETCHMODE_ASSOC
??????(??)???????(???)???key?????????
44. 2001/03/16 PHP4????PostgreSQL???????? 44 hoge5.php(5) insert()
DB????????
update()
DB????????
45. 2001/03/16 PHP4????PostgreSQL???????? 45 hoge5.php(6) Table1????AbstructTable???????
class Table1 extends AbstructTable { … }
???????????????
?????????? hoge4.php ???
46. 2001/03/16 PHP4????PostgreSQL???????? 46 ???? ??????????????????
$name = "job";
echo $$name; // $job
?????????????
$name = "member";
echo $this->$name; // $this->member
47. 2001/03/16 PHP4????PostgreSQL???????? 47 get_class_vars() get_object_vars( $this )
?????????????????????
get_class_vars()
???????????????????
class Hoge { var $val1 = ""; }
$h = new Hoge;
$h->val2 = "val2";
get_object_vars( $h ); // "val1", "val2"
get_class_vars( get_class( $h ) ); // "val1"
48. 2001/03/16 PHP4????PostgreSQL???????? 48 ????????????? abstructtable.inc
??????????
??????????????????????????
49. 2001/03/16 PHP4????PostgreSQL???????? 49 hoge6.php ???????
????????
SQL??????????DB????????
??????????????
??????????regist_date?????
???????last_updated?????
50. 2001/03/16 PHP4????PostgreSQL???????? 50 ????????????(1) define() ??????????????????????????
?????????????????????????????
??????????? .xxxrc ????
localconfig.inc???????????????????????????????
51. 2001/03/16 PHP4????PostgreSQL???????? 51 ????????????(2) ?????????????????
define( "LOCAL_CONFIG_PATH", "localconfig.inc" );
function isLocalConfigExists() {
$fp = @fopen( LOCAL_CONFIG_PATH, "r", 1 );
if (!$fp)
return false;
fclose( $fp );
return true;
}
if (isLocalConfigExists()) {
include_once( LOCAL_CONFIG_PATH );
}
52. 2001/03/16 PHP4????PostgreSQL???????? 52 PHP???????? Zend Cache
????????????????????????????
Zend Encoder
????????????????????????????
Zend IDE
??????
Java???
????????????
53. 2001/03/16 PHP4????PostgreSQL???????? 53 ?????? ?????????????????????…
PHP-GTK
???????????????
54. 2001/03/16 PHP4????PostgreSQL???????? 54 Q&A