位置: 编程技术 - 正文

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")

  • 工业企业应缴纳的税金有哪些
  • 代开发票含税价怎么核算为不含税发票
  • 固定资产清理净损失怎么算
  • 新成立的公司残保金如何申报
  • 房地产企业购入用于建造商品房的土地使用权
  • 社会组织属于非法人组织吗为什么
  • 出让固定资产怎样计算增值税
  • 包装物押金会计分录怎么做
  • 公司增资认缴需要什么流程呢怎么办理
  • 固定资产原值变更当月计提折旧
  • 办理核定企业所需资料
  • 机会成本怎么计量
  • 科技开发属于什么产品
  • 原材料费用的分配
  • 货物装卸过程中由于操作不当或违反操作规程
  • 云服务器免费使用
  • 华为微信铃声怎么设置不跟随系统
  • dir852迅雷路由器
  • 员工的罚款计入什么科目
  • 经济成本和会计成本的大小
  • 委托检验报告能否作为处罚依据
  • 股东不用上班吗
  • macos big sur 电池
  • 垫付员工保险费的会计科目
  • 企业所得税年报申报时间
  • 铁路运输企业所得税优惠
  • 顺流交易合并抵消 chenyiwei
  • php中cookie的值存储在哪
  • php有很多流行的mvc框架,这些框架可以
  • 公司报销客户的差旅费
  • 360路由器怎么连接网络
  • php 获取文件类型
  • 修改gradle版本
  • wordpress 函数
  • php 通信
  • WGAN(Wasserstein GAN)看这一篇就够啦,WGAN论文解读
  • js文件合并工具
  • php输出空格语句
  • 实收资本的会计处理
  • 逆回购划算吗
  • 物流辅助服务属于什么科目
  • 撤销税务局
  • 未达起征点增值税申报表怎么填
  • 增值税免税优惠梳理
  • 原材料报废收入账务处理
  • 收到土地使用权的租金
  • 房地产企业代收费用
  • 普通发票怎么冲红字
  • 社保补缴收滞纳金吗
  • 收到代持股权的账务处理
  • 工程材料票占工程款的比例
  • 建筑材料租赁公司
  • 转账支票的特点有哪些
  • 残保金补申报需要交滞纳金吗
  • 管理费用包括哪些
  • 物流公司回扣几个点
  • 公司注销剩余的存货怎么处理
  • 账户设置的三种情况
  • 财务预算怎么做模板
  • 净资产总计等于什么
  • mysql正整数类型
  • mysql数据库操作题
  • torch.cuda.set_device
  • mac快捷键一览
  • optimize error by column count
  • xp系统的搜索
  • spyware.exe - spyware是什么进程
  • windows xp iis安装
  • sentstrt.exe - sentstrt进程是什么文件 有什么用
  • iptables添加规则立即生效
  • win10更新补丁导致打印机
  • win10任务栏怎么变成透明
  • linux配置命令
  • [OpenGL ES 04]3D变换实践篇:平移,旋转,缩放
  • JavaScript中的方法名不区分大小写
  • android开发环境的搭建步骤
  • 前端面试题及答案2023vue3
  • unity3d功能
  • jquery事件委托原理
  • 源码搜索
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设