note 17805 deleted from function.mssql-bind by didou

From: Date: Sun, 04 Feb 2007 05:34:07 +0000
Subject: note 17805 deleted from function.mssql-bind by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-122782@lists.php.net to get a copy of this message
Note Submitter: fjortizATcomunetDOTes ---- After creating a statement resource with mssql_init, you can bind all the parameters. These are the arguments: - stmt: statement resource obtained with mssql_init - param_name: string with the parameter name. YOU HAVE TO INCLUDE the @ character, like the T-SQL syntax. See the full example that I'll include in mssql_execute explanation. - var: this is the PHP variable you'll bind the MSSQL parameter to. You can pass it BY VALUE, but you can also pass it BY REFERENCE (&var), to retrieve OUTPUT and RETVAL values after procedure execution. The return value (a long integer value) is treated like a special OUTPUT parameter, called "RETVAL" (without the @). See the example at mssql_execute to see how it works. - type: one of this new supported PHP constants. SQLTEXT, SQLVARCHAR,SQLCHAR, SQLINT1,SQLINT2, SQLINT4, SQLBIT,SQLFLT8 See notes on bottom of this contribution for the tricks, quirks and DB-lib bugs related to the types. - is_output: boolean value to say whether the value is an OUTPUT parameter or not. If it's an OUTPUT parameter but you say nothing or FALSE, it will be treated as a normal input parameter and no error will be yielded. - is_null: to say the parameter is NULL. Don't pass an empty PHP variable to achieve this, it won't work. Use this boolean value. - maxlen: used with char/varchar values. You have to indicate the length of the data so if the parameter is a varchar(50), the type must be SQLVARCHAR and maxlen must be 50. Bugs in MSSQL DB-lib, quirks, etc... - You can't modify and get a "char(n) OUTPUT" parameter. I tried from "Query Analyzer" and I get the same results. There must be a bug in MSSQL client libs. You can get output from a varchar(n), though. - The only float type needed for "float","double" and "decimal(n,m)" parameters is SQLFLT8, I don't know why but SQLFTL4 and SQLFLTN don't work properly for OUTPUT parameters. - There is a bug in MSSQL Client Libraries that avoid sending varchar parameters for more than 255 characters to a stored procedure. Use mssql_query instead.

« previous php.notes (#122782) next »