位置: 编程技术 - 正文

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

  • 中国注册税务师协会法律法规库
  • 长期借款利息费用计算
  • 市场运营部门工作职责
  • 小规模升一般纳税人怎么操作
  • 两免三减半的范围
  • 发票代码和发票号码是什么
  • 次年度所得税预缴申报期限怎么执行?
  • 财政补贴金额
  • 小规模纳税人多少免征增值税
  • 退回剩余的工程物资
  • 办公楼贷款比例
  • 进口增值税已付发票未到如何入账
  • 增值税发票过期了税金怎么办
  • 投资者投入固定资产的成本
  • 购销合同印花税税率2023
  • 代扣代缴企业所得税10%
  • 金税盘服务费可以当月抵扣吗
  • 委托代收款
  • 资产收购账务处理
  • 股东增加投资款要交印花税吗
  • 公司研发产品
  • 建筑企业法定代表人和建筑公司资质不是一个人
  • 固定资产折旧计算方法
  • 有进项税额转出怎么结转增值税
  • 跨年度的收入如何做分录
  • 个人车辆过户给公司
  • linux连接windows的服务redis
  • 宽带测速器在线测速
  • 工程咨询费用取费标准
  • 住房公积金余额查询
  • 员工宿舍的物业费要交个税吗
  • 员工工伤保险报销条件
  • 欧罗巴山脉自驾
  • 什么叫股权溢价之谜?
  • 黄金旧料卖出收据怎么写
  • 卡格拉河
  • qiankun跨域问题
  • 申请专利费用计入哪个科目
  • node.js教程详细
  • 机器学习分类算法之XGBoost(集成学习算法)
  • discuz 移动端
  • python的图
  • python2 tkinter
  • 凭证过账后发现了错误,如何处理
  • 残疾人就业保障金申报时间
  • 增值税申报系统登录密码
  • uni-simple-router 跳转无效
  • vue连接webapi
  • mysql的主从
  • 未取得发票的费用所得税汇算调增,该填哪里呢?
  • 不动产在建工程领用原材料进项税额可以抵扣吗
  • 职工罚款的会计处理办法
  • 纸巾的发票可以抵扣进项税吗
  • 汽车租赁公司怎么办理
  • 应收账款平账怎么处理
  • 可供分配利润是未分配利润吗
  • 资产负债表固定资产怎么填
  • 融资租入的设备怎么入账
  • 计提折旧有哪些会计科目
  • 物业公司代业主委员会收公共收益怎么开发票
  • sql server 错误
  • windows xp和windows 2000
  • win10无人值守文件使用方法
  • centos6.7防火墙
  • WARNING: /tmp: File system full, swap space limit exceeded的解决办法
  • centos7命令行快捷键
  • win7升级到win10有无影响
  • 通过intent可以启动哪些组件
  • Unity3D面试题整合
  • javascript中this的用法
  • nodejs 文件操作
  • 常用的jquery鼠标事件
  • jquery怎么获取
  • 如何在android studio中导入其他包
  • 税务相关文件
  • 车辆购置税查询不到应征欠税信息,不能进行扣款操作
  • 你需要了解什么 英语
  • 广州哪里有餐饮费发票
  • 防疫物资开票免税吗
  • 企业需要缴纳哪些费用
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设