位置: 编程技术 - 正文

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

  • 个税申报的收入扣除社保吗
  • 行政法律法规是规定行政机关
  • 给对方汇钱
  • 个人名字的话费能做账吗
  • 发票同步功能在哪里
  • 房地产企业季度所得税申报
  • 以前年度损益调整影响本年利润
  • 会计净额法和总额法
  • 股票交易印花税税率
  • 房产租金收入房产税
  • 滞纳金可以个人承担吗
  • 融资性售后回租承租方出售资产为什么不缴纳增值税
  • 建筑施工企业质量体系环境包括
  • 库存现金日记账和库存现金总账都应逐日逐笔
  • 物业公司收到开发代付物业管理费怎么做账
  • 城建税教育附加地方教育附加的税率
  • 当月发货必须当月开票吗
  • 实收资本取出来要交税吗?
  • 取得稳岗补贴后怎么办
  • 建筑劳务公司人员结构
  • 怎么查银行账户余额
  • 跨年度残保金退回做什么
  • 工程类劳务发票
  • 一般商贸企业出口白酒要交税吗
  • 科技型企业科研项目申报
  • 票据状态提示付款
  • windows10你需要trustedinstaller提供的权限才能更改
  • element plus 虚拟化表格
  • 公司给其他单位分红需要对方开票吗
  • 字体文件夹在哪
  • 装修费用账务怎么处理
  • 应付职工薪酬负数风险
  • 详解16型人格
  • 定期定额和核定征收哪个好
  • 猿创设计科技有限公司
  • 基于Java+SpringBoot+vue+element驾校管理系统设计和实现
  • 并发操作的定义
  • Php实现注解注入
  • 增值税 转出
  • 将本月发生的制造费用总额按生产工人
  • 非一般纳税人怎么报税
  • 开发商需要缴纳保证金
  • 全年累计个税扣除公式
  • 月末库存商品结转成本怎么算
  • js与或运算符
  • 织梦cms要钱吗
  • 现金结算的特点和概念
  • sql server 实例
  • sql server s
  • 筹建期间的开办费为什么不属于资产
  • 主营业务收入借贷方
  • 应交增值税负数表示什么
  • 农民专业合作社税收优惠政策
  • 收到退回的以前的快递
  • 工资标准表
  • 预计负债转回对所得税费用的影响
  • 资产减值损失属于损益类的收入还是费用
  • 长期股权投资利润调整加折旧
  • 回购股票注销股票怎么办
  • 以前年度多计提的税金怎么调整
  • 母子公司之间内部交易形成的坏账可以所得税税前扣除吗
  • 航天信息开票软件客服
  • 银行存款日记账对方科目两个怎么办
  • 物业管理企业应按职工工资总额的1.5%计提工会经费
  • 为什么没有win8系统
  • python函数详解
  • cocos2djs
  • python如何不换行
  • shell获取脚本进程id号
  • android多指触控
  • jquery使用教程
  • python 文件操作,读,写,指定位置
  • select ui
  • jquery-validate
  • 福建省地税局副局长 阮
  • 小规模纳税人可以用专票抵扣税吗
  • 地税局属于省直单位吗
  • 美国对中国商品征收关税
  • 利润表中所得税费用包括
  • 去银行签贷款合同后多久办过户
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设