位置: 编程技术 - 正文

PHP:pg_query_params()的用法_PostgreSQL函数

发布时间:2024-01-01
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")

  • 什么时候公司需要赔偿员工
  • 各行业的税负率表2022
  • 课税为什么叫课税
  • 应交税费科目的借贷方向
  • 开具红字发票的当月就要进项税额转出吗
  • 工商银行特色贷款
  • 折让折扣负数发票的会计处理
  • 增值税期初应补税额计算
  • 收到股东投资款怎么做账
  • 新企业第一次报所得税
  • 中小企业怎么避税
  • 外购货物对外捐赠企业所得税
  • 出租固定资产取得的租金收入属于什么收入
  • 公司办公室收到上级主管部门的一份
  • 单位预付卡
  • 哪些营业外收入需要缴纳增值税
  • 事业单位购入存货分录
  • 企业所得税属于什么科目
  • 17增值税发票怎么计算
  • 互联网合同范本
  • 用现金缴纳海关增值税能否抵扣?
  • 资产负债表是累计记账吗
  • 生育津贴有什么作用
  • 销售人员差旅费管理办法
  • 产品研发费用计入什么科目
  • 交通费进项税抵扣计算
  • 股权收购特殊性税务处理案例
  • 合同成本对应科目
  • 公司贷款收入如何计算
  • 短期借款应付利息列报
  • mac怎么隐藏app
  • 冲减其他应收款需要领导审批吗
  • 转出未交增值税怎么算
  • wamp设置
  • 火狐十大必用插件
  • 原材料科目是什么意思
  • 行政事业单位转让不动产
  • 净资产现金回收率说明什么
  • Laravel5.5新特性之友好报错以及展示详解
  • php数据库分页是怎么实现的
  • burp怎么安装
  • 网络安全网络文明
  • lvs命令详解
  • 预缴增值税怎么算
  • 融资租赁首付租金会计账务处理
  • 关于非营利组织企业所得税免税收入问题的通知
  • 长期待摊费用的账务处理
  • vue动态修改scss变量
  • SqlServer 2005 T-SQL Query 学习笔记(3)
  • 无法偿付的应付账款计入什么科目政府会计
  • 跨月普票发票怎么红冲
  • 小规模纳税人减按1%政策
  • 库存商品结转成本的金额怎么计算
  • 固定资产没有发票
  • 补开以前的发票可以抵企业所得税吗?
  • 预收账款属于借还是贷
  • 律师的行业
  • 小微企业注册流程及注意事项
  • 其他债权投资有没有减值准备
  • 建筑业简易征收税率5%
  • 其他流动资产
  • sql server2019数据库
  • MySQL存储过程与触发器
  • 统计得到的一组数据有80个
  • 简单谈谈设计与市场的关系
  • vista技巧:更改电源默认按钮为关机
  • linux服务器怎么用
  • vc运行程序
  • mac双系统切换快捷键
  • win8怎么进入桌面系统
  • cortana小娜怎么用
  • windows应用图标
  • unity shader ao
  • Javascript valueOf 使用方法
  • jquery返回顶部代码
  • 自然人电子税务局网页端
  • 宁波地税如何网上缴费
  • 国家税务局总局河南官网
  • 济南高新区国家税务局
  • 合肥地税局上班时间
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号