位置: 编程技术 - 正文
推荐整理分享PHP:pg_prepare()的用法_PostgreSQL函数,希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:,内容如对您有帮助,希望把文章链接给更多的朋友!
(PHP 5 >= 5.1.0)
pg_prepare — Submits a request to create a prepared statement with the given parameters, and waits for completion.
说明 resource pg_prepare ([ resource $connection ], string $stmtname , string $query )pg_prepare() creates a prepared statement for later execution with pg_execute() or pg_send_execute(). This feature allows commands that will be used repeatedly to be parsed and planned just once, rather than each time they are executed. pg_prepare() is supported only against PostgreSQL 7.4 or higher connections; it will fail when using earlier versions.
The function creates a prepared statement named stmtname from the query string, which must contain a single SQL command. stmtname may be "" to create an unnamed statement, in which case any pre-existing unnamed statement is automatically replaced; otherwise it is an error if the statement name is already defined in the current session. If any parameters are used, they are referred to in the query as $1, $2, etc.
Prepared statements for use with pg_prepare() can also be created by executing SQL PREPARE statements. (But pg_prepare() is more flexible since it does not require parameter types to be pre-specified.) Also, although there is no PHP function for deleting a prepared statement, the SQL DEALLOCATE statement can be used for that purpose.
参数connection
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().
stmtnameThe name to give the prepared statement. Must be unique per-connection. If "" is specified, then an unnamed statement is created, overwriting any previously defined unnamed statement.
queryThe 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.
返回值A query result resource on success 或者在失败时返回 FALSE.
范例
Example #1 Using pg_prepare()
<?php//Connecttoadatabasenamed"mary"$dbconn=pg_connect("dbname=mary");//Prepareaqueryforexecution$result=pg_prepare($dbconn,"my_query",'SELECT*FROMshopsWHEREname=$1');//Executethepreparedquery.Notethatitisnotnecessarytoescape//thestring"Joe'sWidgets"inanyway$result=pg_execute($dbconn,"my_query",array("Joe'sWidgets"));//Executethesamepreparedquery,thistimewithadifferentparameter$result=pg_execute($dbconn,"my_query",array("ClothesClothesClothes"));?> 参见pg_execute() - Sends a request to execute a prepared statement with given parameters, and waits for the result. pg_send_execute() - Sends a request to execute a prepared statement with given parameters, without waiting for the result(s).
PHP:pg_port()的用法_PostgreSQL函数 pg_port(PHP4,PHP5)pg_port返回该连接的端口号说明intpg_port(resource$connection)pg_port()返回给定的PostgreSQLconnection资源所连接的端口号。
PHP:pg_pconnect()的用法_PostgreSQL函数 pg_pconnect(PHP4,PHP5)pg_pconnect打开一个持久的PostgreSQL连接说明resourcepg_pconnect(string$connection_string[,int$connect_type])pg_pconnect()打开一个到PostgreSQL数据库的持久连
PHP:pg_ping()的用法_PostgreSQL函数 pg_ping(PHP4=4.3.0,PHP5)pg_pingPing数据库连接说明boolpg_ping(resource$connection)pg_ping()ping数据库连接,如果中断则尝试重新连接。如果连接在活动状态返回TRUE,否
标签: PHP:pg_prepare()的用法_PostgreSQL函数
本文链接地址:https://www.jiuchutong.com/biancheng/281457.html 转载请保留说明!友情链接: 武汉网站建设