**一.不建議使用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
```
 
**配套的PHP8新特性詳解視頻教程,請查看以下專輯**
鏈接:[https://www.ixigua.com/6937490165329822219](https://www.ixigua.com/6937490165329822219)
- 第1章:LNP Web環境搭建
- 1-1 Nginx1.19源碼編譯安裝
- 1-2 Nginx1.19環境配置
- 1-3 Nginx1.19性能優化與測試
- 1-4 PHP8.0源碼編譯安裝
- 1-5 PHP8.0環境配置
- 1-6 PHP8.0性能優化與測試
- 第2章:JIT即時編譯
- 2-1 JIT編譯原理
- 2-2 Tracing JIT和Function JIT編譯引擎
- 2-3 Opcodes編譯原理
- 2-4 Opcache和JIT功能開啟
- 2-5 JIT高性能測試
- 第3章:PHP8的主要新特性
- 3-1 php8的命名參數
- 3-2 Reflection反射
- 3-3 注解
- 3-4 構造器屬性提升
- 3-5 聯合類型
- 3-6 Nullsafe空安全運算符
- 3-7 Match表達式
- 第4章:PHP8的新功能和類
- 4-1 PhpToken類
- 4-2 Stringable接口
- 4-3 WeakMap類
- 4-4 Str_contains函數
- 4-5 Str_starts_with和Str_ends_with函數
- 4-6 Fdiv函數
- 4-7 Get_resource_id函數
- 4-8 Get_debug_type函數
- 第5章:類型系統改進
- 5-1 新的Mixed偽類型
- 5-2 Static類方法的返回類型
- 第6章:錯誤處理方面的改進
- 6-1 系統函數引發TypeError和ValueError異常
- 6-2 Throw表達式拋出異常
- 6-3 無變量捕獲的Catch
- 6-4 默認錯誤報告設置為E_ALL
- 6-5 默認情況下顯示PHP啟動錯誤
- 6-6 Assert斷言默認情況下引發異常
- 6-7 操作符@不再抑制Fatal錯誤
- 6-8 PDO默認錯誤模式為ERRMODE_EXCEPTION
- 第7章:資源到對象的遷移
- 7-1 GdImage類對象替換了GD映像資源
- 7-2 CurlHandle類對象替換Curl處理程序
- 7-3 套接字擴展資源Socket是類對象
- 7-4 XMLWriter對象替換xmlwriter資源
- 第8章:PHP面向對象的編程更改
- 8-1 不兼容的方法簽名的致命錯誤
- 8-2 嚴格執行類魔術方法簽名
- 8-3 靜態調用非靜態類方法會導致致命錯誤
- 8-4 繼承規則不適用于Private類方法
- 8-5 對象支持Class魔術常量
- 第9章:與字符串相關的更改
- 9-1 Substr和Iconv_substr偏移越境返回空字符串
- 9-2 加減運算符優先級高于點連接符
- 第10章:其他功能與特性
- 10-1 Printf采用新精度和寬度修飾符
- 10-2 內置Web服務器支持動態端口選擇
- 10-3 參數列表和閉包Use列表中允許結尾逗號
- 10-4 隱式負數組鍵增量不會跳過負數
- 10-5 Crypt函數Salt為必選參數
- 10-6 調用禁用函數或類為未定義狀態
- 10-7 可選參數之后禁止出現必選參數
- 第11章:棄用的函數與方法
- 11-1 ReflectionFunction::isDisabled棄用
- 11-2 ReflectionParameter::getClass棄用
- 11-3 ReflectionParameter::isArray棄用
- 11-4 ReflectionParameter::isCallable棄用
- 11-5 ReflectionClass::export棄用
- 11-6 ReflectionFunction::export棄用
- 11-7 Get_defined_functions改進禁用函數
- 11-8 24個PostgreSQL的別名函數棄用