位置: 编程技术 - 正文

PHP:pg_query_params()的用法_PostgreSQL函数

编辑:rootadmin
pg_query_params

推荐整理分享PHP:pg_query_params()的用法_PostgreSQL函数,希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:,内容如对您有帮助,希望把文章链接给更多的朋友!

(PHP 5 >= 5.1.0)

pg_query_params — Submits a command to the server and waits for the result, with the ability to pass parameters separately from the SQL command text.

说明 resource pg_query_params ([ resource $connection ], string $query , array $params )

Submits a command to the server and waits for the result, with the ability to pass parameters separately from the SQL command text.

pg_query_params() is like pg_query(), but offers additional functionality: parameter values can be specified separately from the command string proper. pg_query_params() is supported only against PostgreSQL 7.4 or higher connections; it will fail when using earlier versions.

If parameters are used, they are referred to in the query string as $1, $2, etc. The same parameter may appear more than once in the query; the same value will be used in that case. params specifies the actual values of the parameters. A NULL value in this array means the corresponding parameter is SQL NULL.

The primary advantage of pg_query_params() over pg_query() is that parameter values may be separated from the query string, thus avoiding the need for tedious and error-prone quoting and escaping. Unlike pg_query(), pg_query_params() allows at most one SQL command in the given string. (There can be semicolons in it, but not more than one nonempty command.)

参数

connection PHP:pg_query_params()的用法_PostgreSQL函数

PostgreSQL database connection resource. When connection is not present, the default connection is used. The default connection is the last connection made by pg_connect() or pg_pconnect().

query

The parameterized SQL statement. Must contain only a single statement. (multiple statements separated by semi-colons are not allowed.) If any parameters are used, they are referred to as $1, $2, etc.

User-supplied values should always be passed as parameters, not interpolated into the query string, where they form possible SQL injection attack vectors and introduce bugs when handling data containing quotes. If for some reason you cannot use a parameter, ensure that interpolated values are properly escaped.

params

An array of parameter values to substitute for the $1, $2, etc. placeholders in the original prepared query string. The number of elements in the array must match the number of placeholders.

Values intended for bytea fields are not supported as parameters. Use pg_escape_bytea() instead, or use the large object functions.

返回值

A query result resource on success 或者在失败时返回 FALSE.

范例

Example #1 Using pg_query_params()

<?php//Connecttoadatabasenamed"mary"$dbconn=pg_connect("dbname=mary");//FindallshopsnamedJoe'sWidgets.Notethatitisnotnecessaryto//escape"Joe'sWidgets"$result=pg_query_params($dbconn,'SELECT*FROMshopsWHEREname=$1',array("Joe'sWidgets"));//Compareagainstjustusingpg_query$str=pg_escape_string("Joe'sWidgets");$result=pg_query($dbconn,"SELECT*FROMshopsWHEREname='{$str}'");?>

参见

pg_query() - 执行查询

PHP:pg_put_line()的用法_PostgreSQL函数 pg_put_line(PHP4=4.0.3,PHP5)pg_put_line向PostgreSQL后端发送以NULL结尾的字符串说明boolpg_put_line([resource$connection],string$data)pg_put_line()向PostgreSQL后端服务器发送以NULL

PHP:pg_prepare()的用法_PostgreSQL函数 pg_prepare(PHP5=5.1.0)pg_prepareSubmitsarequesttocreateapreparedstatementwiththegivenparameters,andwaitsforcompletion.说明resourcepg_prepare([resource$connection],string$stmtname,string$query)pg_pre

PHP:pg_port()的用法_PostgreSQL函数 pg_port(PHP4,PHP5)pg_port返回该连接的端口号说明intpg_port(resource$connection)pg_port()返回给定的PostgreSQLconnection资源所连接的端口号。

标签: PHP:pg_query_params()的用法_PostgreSQL函数

本文链接地址:https://www.jiuchutong.com/biancheng/281455.html 转载请保留说明!

上一篇:PHP:pg_query()的用法_PostgreSQL函数

下一篇:PHP:pg_put_line()的用法_PostgreSQL函数("php")

  • 外贸企业税务处理方式
  • 营业收入与利润变化图
  • 原值和净值在报表怎么找
  • 核定征收企业怎么分红的
  • 不是单位职工个税怎么算
  • 企业自有房产的所有权
  • 会计凭证的填制与审核过程
  • 销项负数发票用勾选吗
  • 年终奖第二年才发怎么计算个税在个税app
  • 增值税抵扣凭证管理
  • 资管产品征税
  • 企业内部控制审计报告应当与内部控制评价报告
  • 工程税票怎么开需要交多少
  • 预缴企业所得税分录
  • 金融企业贷款损失准备金
  • 增值税普通发票红冲之后还能查询吗
  • 差旅费税务要求比例
  • 固定资产后续支出是指固定资产在使用过程中发生的
  • 待处理财产损益期末结转到哪里
  • 公司自有房屋出租 营业范围
  • 无法设置面容id怎么办
  • 如何使用ChapGPT
  • windows11怎么创建宽带拨号连接图标
  • 跟客户合作后发给客户的句子
  • 更改macbook
  • 公司付物业费没开发票
  • wordpress介绍
  • 扣缴义务人应扣未扣如何处罚
  • 怎么给复选框赋值
  • ensp综合实验配置
  • 手把手教你win7换主板不重装系统的方法
  • 优化器总结
  • Win11 KB5025239 / KB5025224 累积更新今日发布
  • basename $1
  • 建设工程施工合
  • 应税工资和实发工资区别
  • java线程的执行体
  • discuzcms
  • sqlcode错误码100
  • 资本成本在财务报表中怎么体现
  • 累计销售额怎么算
  • 差旅费的处理
  • 如何理解合并报表编制程序中的调整与抵消处理
  • 库存商品入库的会计分录怎么写
  • 存货跌价准备是什么意思
  • 律师事务所账务处理例题
  • 税局代开专票对方隔月退回重开如何做账务处理呢?
  • 计提五险一金如何做分录
  • 长期股权投资全部亏损汇算清缴怎么填
  • 所有者权益的确认依赖于资产和负债的确认
  • 应付账款怎么入账
  • 企业营业外支出是什么意思
  • 行政单位负债类科目包括
  • MySQL中的max()函数使用教程
  • mysql常见报错
  • Centos 5.5 php5.1.2升级到php5.2.6的方法
  • incomp.file ver什么意思
  • ubuntu20.04问题
  • ubuntu20.04怎么用
  • macbook桌面2
  • windows升级10
  • windows 10预览版
  • win10系统怎么查询ip
  • 新手如何入门
  • win7系统开机黑屏如何处理
  • 简单谈谈你的入党动机
  • 基于android的app
  • angularjs2
  • Linuxshell脚本实现自动化软件部署内容
  • javascript toggle
  • android基于linux还是unix
  • python openfoam
  • python 包 __init__
  • 北京海淀区国税有几个办税大厅?
  • 企业销售旧货增值税税率
  • 四川地方税务局网址是什么
  • 贵州省微企补助政策
  • 合并方为进行企业合并发生的佣金和手续费怎么处理?
  • 车辆购置税交了怎么查询不到
  • 税法难吗
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设