位置: 编程技术 - 正文

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

  • 对外投资应由
  • 坏账损失核算的两种方法
  • 开票地址一定要写全吗
  • 递延所得税资产和负债怎么理解
  • 预缴土地增值税的会计处理
  • 物流辅助服务印花税税率
  • 小规模纳税人与一般纳税人区别
  • 农产品进项抵扣政策
  • 开具不规范的发票
  • 一般纳税人计提水利基金会计分录
  • 开具成品油专用发票时,应遵守哪些规则
  • 政府性搬迁补偿收入的税务处理
  • 应纳税调增调减会计分录
  • 2014年税收征管体制改革
  • 房地产并购的税率是多少
  • 一般纳税人销售自己使用过的物品
  • 淘宝开企业店铺需要什么资料
  • 生产型企业出口非自产产品能享有退税吗
  • 广告业 增值税
  • 携税宝如何网上缴费
  • 个税没有扣除项,需要填写和确认吗
  • 华为手机进入recovery模式怎么退出
  • RSync文件备份同步 Linux服务器rsync同步配置图文教程
  • 小规模纳税人月收入超过10万,要交多少税
  • 事业编党费如何核算
  • php数组函数实现机选双色球
  • 远程桌面连接失败了
  • 上月多计提的所得税怎么做分录
  • 硬盘最小的存储单位
  • 科克伯什么意思
  • php数组有哪几种类型
  • win7系统更改属性内存信息的方法有哪些
  • thinkphp删除数据
  • vite搭建项目
  • php深度分析
  • php 跨域
  • vue请求后端接口
  • Laravel5权限管理方法详解
  • 报废机器设备如何缴纳增值税
  • uname命令功能
  • 原始投资额的现值
  • 合伙企业与公司一样具有高度的人合性
  • mysql转数字为字符串
  • 增值税抵扣环节
  • 新公司开基本户需要带什么材料
  • 跨年的房租费用怎么做账
  • 增资扩股和股权转让一样吗
  • 累计预扣法利弊
  • 公司支付款项制度
  • 销售开票会计分录怎么做
  • 超市的库存商品是怎么记账的
  • 企业所得税汇算表
  • 我国流转税税制结构的现状及改进意见
  • 银行收到一笔款项企业尚未入账属于什么情况的未达账项
  • 小规模企业应交税费分录
  • 企业发生亏损时,下列各项,( )是弥补亏损的渠道
  • sqlserver存储过程声明变量
  • sql语句 时间
  • mysql 5.6.23 winx64.zip安装详细教程
  • Mac如何使用clash上外网
  • windows崩溃后怎么修复
  • linux uzip
  • 如何设置无线网密码
  • linux eval命令
  • win7系统打不开浏览器
  • sks文件是什么
  • WIN7如何设置屏幕保护密码
  • jquery插件使用教程
  • cmd attribute
  • 置顶句子怎么弄
  • unity3D游戏开发
  • javascript常用语句
  • 选择照片的快捷键
  • 教学实例分析怎么写
  • linux的gunzip命令
  • javascript怎么做
  • 企业所得税汇总纳税备案表
  • 如何打印个人所得税证明
  • 电信宽带绑定的手机号怎么解除绑定
  • 文化传媒公司能卖多少钱
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设