以下为引用的内容: CREATE TABLE practicetable { someID SERIAL, time TIMESTAMP DEFAULT now(), name VARCHAR(50), address VARCHAR(50), city VARCHAR(50), state VARCHAR(2), country VARCHAR(3) DEFAULT 'USA', postlcode VARCHAR(15), age smallint, lattitude real, longitude real, somebool boolean, message textitem }; |
以下为引用的内容: </P> <?php // /usr/local/lib/php/mysite/configfile.php $hostname = "localhost"; $username = "username"; $database = "mydb"; $password = "mypasswd"; ?> <?php //标准的HTML头 include("mysite/configfile.php"); ?> <html> <head> <title>Bill's Kazoos</title> ... </head> <body> ... |
以下为引用的内容: $connection_id=mysql_connect($hostname, $username, $password); mysql_select_db($database, $connection_id); |
以下为引用的内容: $connection_id=mysql_pconnect($hostname, $username, $password); mysql_select_db($database, $connection_id); |
以下为引用的内容: $connection_id=pg_connect("host=$hostname dbname=$database user=$username password=$password"); |
以下为引用的内容: function postg_connect($hostname, $username, $password, $database) { return pg_connect("host=$hostname dbname=$database user=$username password=$password"); } //如果你仅仅使用一个数据库,你最好将这些变量放到你的配置文件中 function postg_autoconnect() { global $hostname, $username $password $database; return pg_connect("host=$hostname dbname=$database user=$username password=$password"); } //查询函数 function postg_query($query, $connection_id) { return pg_exec($connection_id, $query); } |
以下为引用的内容: <?php // /usr/local/lib/php/mysite/configfile.php $hostname = "localhost"; $username = "username"; $database = "mydb"; $password = "mypasswd"; //内部计数变量 $fetch_array_counter=0; $fetch_object_counter=0; $fetch_row_counter=0; //处理连接到PostgreSQL数据库的函数 function postg_connect($hostname, $username, $password, $database) { return pg_connect(host=$hostname, dbname=$database user=$username, password=$password"); } //不需要任何参数的连接 function postg_autoconnect() { global $hostname, $username, $password, $database; return pg_connect(host=$hostname, dbname=$database user=$username, password=$password"); } //查询函数 function postg_query($query, $connection_id) { //将全局变量设置为0 global $fetch_array_counter, $fetch_row_counter, $fetch_object_counter; $fetch_array_counter=$fetch_row_counter=$fetch_object_counter=0; return pg_exec($connection_id, $query); } //pg_fetch_array()置换 function postg_fetch_array($rslt) { global $fetch_array_counter; $fetch_array_counter++; //计数器加一 return pg_fetch_array($rslt, $fetch_array_counter); } //pg_fetch_row()置换 function postg_fetch_row($rslt) { global $fetch_row_counter; $fetch_row_counter++; //计数器加一 return pg_fetch_row($rslt, $fetch_row_counter); } //pg_fetch_object()置换 function postg_fetch_object($rslt) { global $fetch_object_counter; $fetch_object_counter++; //计数器加一 return pg_fetch_object($rslt, $fetch_object_counter); } ?> |
以下为引用的内容: function postg_insert_id($tablename, $fieldname) { global connection_id; $result=pg_exec($connection_id, "SELECT last_value FROM ${tablename}_ ${fieldname}_seq"); $seq_array=pg_fetch_row($result, 0); return $seq_array[0]; } |
10260 次浏览 0 条评论 收藏
微信扫码分享给朋友
复制链接分享
专属产品经理帮您系统分析