位置: 编程技术 - 正文

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

  • 材料抵扣货款怎么写简单协议范本
  • 会计中管理费用和财务费用的区别
  • 入账价值 入账成本 入账金额
  • 以前年度损益科目核算业务
  • 动产租赁和不动产哪个好
  • 小规模纳税人普票收入会计分录
  • 取得不动产权证书时间是指哪个时间
  • 企业改制重组增值税优惠政策
  • 企业进口关税和消费关税
  • 政府补助的核算方法名词解释
  • 被投资单位提取盈余公积权益法
  • 家电公司销售电器赠送小礼品如何做账?
  • 个人挂靠公司承接工程如何做会计处理?
  • 生产过程中产生的废料怎么管理
  • 在年度汇算清缴前取得去年成本发票
  • 未开票收入为负数如何写说明
  • 旧税号还能开票吗
  • 小规模文化交流活动
  • 以前年度的税金及附加
  • 银行承兑汇票加工费合同
  • 一般纳税人企业所得税计算公式
  • 工业企业出售厂房需要预缴税款吗
  • win11如何在开机的时候进入安全模式
  • 上月发生的费用本月报销记账
  • 跨年退货会计处理
  • win11安装失败0xc1900201
  • php常见面试问题
  • windows太阳谷更新
  • 代发工资如何合理避税
  • window10怎么禁用系统弹窗
  • 适用增值税差额征税政策的纳税人填写差额后的销售额
  • PHP:file_get_contents()的用法_Filesystem函数
  • 为什么微信转账不成功
  • yolov3训练
  • 换出长期股权投资的会计处理
  • h5页面内嵌到微信
  • web前端三大主流框架vue
  • php5魔术方法
  • 企业对外投资资产的成本可以税前扣除吗
  • 法人借钱给公司,公司可以直接转给法人吗
  • 印花税土地使用权计税依据
  • 培训机构账务处理
  • 支付网银年服务费
  • SQLite3 命令行操作指南
  • sqlserver数据类型转换函数
  • 织梦二次开发教程
  • 开业前需要支出什么费用
  • 本期应补退税额为负数怎么申报
  • 应交税金相关内容包括
  • 城市维护建设税,教育费附加,地方教育费附加
  • sql 临时数据
  • 电脑买回来可以直接用吗
  • 捆绑销售的会计处理?
  • 房地产企业土地增值税预缴
  • 小规模纳税人劳务派遣可以差额征税吗
  • 新政府会计制度与旧制度区别
  • 住宿费开专票怎么做账
  • 对方开票少开几角会计分录
  • 原材料用于在建工程进项税可以抵扣吗
  • 公司成立前的费用发票可以入账吗
  • 管理费用的核算方法
  • 个人承担的社保算公司的费用吗
  • 无形资产是当月计提折旧吗
  • 流动资产合计怎么算
  • mysql5.5解压版安装教程
  • windowsserver2003ftp服务器怎么搭建
  • macbook appstore在哪
  • win10修改默认
  • mac2020怎么换开机背景
  • centos7.1
  • xp系统 修复
  • win8怎么打开ie浏览器
  • win8怎么切换界面
  • opengl csdn
  • opengl extension
  • shell脚本常用命令及操作
  • 如何判断sma
  • jquery父节点
  • shell脚本实现Linux运维监控
  • 如何查询汽车发票
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设