PHP: Hypertext Preprocessor (original) (raw)

odbc_procedurecolumns

(PHP 4, PHP 5, PHP 7, PHP 8)

odbc_procedurecolumns — Retrieve information about parameters to procedures

Description

Parameters

odbc

The ODBC connection object, see odbc_connect() for details.

catalog

The catalog ('qualifier' in ODBC 2 parlance).

schema

The schema ('owner' in ODBC 2 parlance). This parameter accepts the following search patterns:% to match zero or more characters, and _ to match a single character.

procedure

The proc. This parameter accepts the following search patterns:% to match zero or more characters, and _ to match a single character.

column

The column. This parameter accepts the following search patterns:% to match zero or more characters, and _ to match a single character.

Return Values

Returns the list of input and output parameters, as well as the columns that make up the result set for the specified procedures. Returns an ODBC result object or [false](reserved.constants.php#constant.false) on failure.

The result set has the following columns:

Drivers can report additional columns.

The result set is ordered by PROCEDURE_CAT, PROCEDURE_SCHEM,PROCEDURE_NAME and COLUMN_TYPE.

Changelog

Version Description
8.4.0 odbc expects an Odbc\Connection instance now; previously, a resource was expected.
8.4.0 This function returns an Odbc\Result instance now; previously, a resource was returned.
8.0.0 Prior to this version, the function could only be called with either one or five arguments.

Examples

Example #1 List Columns of a stored Procedure

<?php <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>c</mi><mi>o</mi><mi>n</mi><mi>n</mi><mo>=</mo><mi>o</mi><mi>d</mi><mi>b</mi><msub><mi>c</mi><mi>c</mi></msub><mi>o</mi><mi>n</mi><mi>n</mi><mi>e</mi><mi>c</mi><mi>t</mi><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">conn = odbc_connect(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">co</span><span class="mord mathnormal">nn</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">o</span><span class="mord mathnormal">d</span><span class="mord mathnormal">b</span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">o</span><span class="mord mathnormal">nn</span><span class="mord mathnormal">ec</span><span class="mord mathnormal">t</span><span class="mopen">(</span></span></span></span>dsn, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>u</mi><mi>s</mi><mi>e</mi><mi>r</mi><mo separator="true">,</mo></mrow><annotation encoding="application/x-tex">user, </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">u</span><span class="mord mathnormal" style="margin-right:0.02778em;">ser</span><span class="mpunct">,</span></span></span></span>pass); <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>c</mi><mi>o</mi><mi>l</mi><mi>u</mi><mi>m</mi><mi>n</mi><mi>s</mi><mo>=</mo><mi>o</mi><mi>d</mi><mi>b</mi><msub><mi>c</mi><mi>p</mi></msub><mi>r</mi><mi>o</mi><mi>c</mi><mi>e</mi><mi>d</mi><mi>u</mi><mi>r</mi><mi>e</mi><mi>c</mi><mi>o</mi><mi>l</mi><mi>u</mi><mi>m</mi><mi>n</mi><mi>s</mi><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">columns = odbc_procedurecolumns(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">co</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">u</span><span class="mord mathnormal">mn</span><span class="mord mathnormal">s</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0361em;vertical-align:-0.2861em;"></span><span class="mord mathnormal">o</span><span class="mord mathnormal">d</span><span class="mord mathnormal">b</span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">p</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mord mathnormal">roce</span><span class="mord mathnormal">d</span><span class="mord mathnormal">u</span><span class="mord mathnormal">reco</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">u</span><span class="mord mathnormal">mn</span><span class="mord mathnormal">s</span><span class="mopen">(</span></span></span></span>conn, 'TutorialDB', 'dbo', 'GetEmployeeSalesYTD;1', '%'); while (($row = odbc_fetch_array($columns))) { print_r($row); break; // further rows omitted for brevity } ?>

The above example will output something similar to:

Array ( [PROCEDURE_CAT] => TutorialDB [PROCEDURE_SCHEM] => dbo [PROCEDURE_NAME] => GetEmployeeSalesYTD;1 [COLUMN_NAME] => @SalesPerson [COLUMN_TYPE] => 1 [DATA_TYPE] => -9 [TYPE_NAME] => nvarchar [COLUMN_SIZE] => 50 [BUFFER_LENGTH] => 100 [DECIMAL_DIGITS] => [NUM_PREC_RADIX] => [NULLABLE] => 1 [REMARKS] => [COLUMN_DEF] => [SQL_DATA_TYPE] => -9 [SQL_DATETIME_SUB] => [CHAR_OCTET_LENGTH] => 100 [ORDINAL_POSITION] => 1 [IS_NULLABLE] => YES )

Found A Problem?

There are no user contributed notes for this page.