**一.不建议使用PostgreSQL的别名函数** #PHP 8不赞成PostgreSQL扩展中的24个函数别名 ## 不推荐使用的功能 用以下函数来代替 ~~~ pg_clientencoding pg_client_encoding pg_cmdtuples pg_affected_rows pg_errormessage pg_last_error pg_fieldisnull pg_field_is_null pg_fieldname pg_field_name pg_fieldnum pg_field_num pg_fieldprtlen pg_field_prtlen pg_fieldsize pg_field_size pg_fieldtype pg_field_type pg_freeresult pg_free_result pg_getlastoid pg_last_oid pg_loclose pg_lo_close pg_locreate pg_lo_create pg_loexport pg_lo_export pg_loimport pg_lo_import pg_loopen pg_lo_open pg_loread pg_lo_read pg_loreadall pg_lo_read_all pg_lounlink pg_lo_unlink pg_lowrite pg_lo_write pg_numfields pg_num_fields pg_numrows pg_num_rows pg_result pg_fetch_result pg_setclientencoding pg_set_client_encoding ~~~ **二.安装postgresql数据** #为了速度快一些使用yum来安装 ~~~ yum -y install postgresql* postgresql-devel ~~~ **三.给PHP8打pgsql.so扩展模块** 1.进入pgsql模块目录 ~~~ cd /mnt/php-8.0.0/ext/pgsql ~~~ 2.phpize生成configure ~~~ /usr/local/php/bin/phpize ~~~ 3.php-config编译so文件 ~~~ ./configure --with-php-config=/usr/local/php/bin/php-config make && make install ~~~ **四.配置php支持postgresql函数集** #php.ini ~~~ extension=pgsql.so ~~~ #.查看pgsql模块 ~~~ phpinfo(); ~~~ **五.测试pg\_numrows和pg\_num\_rows函数支持情况** ~~~ pg_numrows(); Deprecated: Function pg_numrows() is deprecated pg_num_rows(); Fatal error: Uncaught ArgumentCountError: pg_num_rows() expects exactly 1 argument, 0 given ~~~