cvs: phpdoc /en/reference/mssql constants.xml ini.xml setup.xml /en/reference/mssql/functions mssql-bind.xml mssql-connect.xml mssql-data-seek.xml
mssql-execute.xml mssql-fetch-array.xml mssql-fetch-assoc.xml mssql-fetch-batch.xml mssql-fetch-field.xml mssql-fetch-object.xml mssql-fetch-row.xml
mssql-field-length.xml mssql-field-name.xml mssql-field-seek.xml mssql-field-type.xml mssql-free-result.xml mssql-free-statement.xml
mssql-get-last-message.xml mssql-guid-string.xml mssql-init.xml mssql-min-error-severity.xml mssql-min-message-severity.xml mssql-next-result.xml
mssql-num-fields.xml mssql-pconnect.xml mssql-query.xml mssql-result.xml mssql-rows-affected.xml
| From: | Kalle Sommer Nielsen | Date: | Wed, 08 Oct 2008 18:29:23 +0000 |
| Subject: | cvs: phpdoc /en/reference/mssql constants.xml ini.xml setup.xml /en/reference/mssql/functions mssql-bind.xml mssql-connect.xml mssql-data-seek.xml mssql-execute.xml mssql-fetch-array.xml mssql-fetch-assoc.xml mssql-fetch-batch.xml mssql-fetch-field.xml mssql-fetch-object.xml mssql-fetch-row.xml mssql-field-length.xml mssql-field-name.xml mssql-field-seek.xml mssql-field-type.xml mssql-free-result.xml mssql-free-statement.xml mssql-get-last-message.xml mssql-guid-string.xml mssql-init.xml mssql-min-error-severity.xml mssql-min-message-severity.xml mssql-next-result.xml mssql-num-fields.xml mssql-pconnect.xml mssql-query.xml mssql-result.xml mssql-rows-affected.xml |
||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-2214@lists.php.net to get a copy of this message | ||
kalle Wed Oct 8 18:29:23 2008 UTC
Modified files:
/phpdoc/en/reference/mssql constants.xml ini.xml setup.xml
/phpdoc/en/reference/mssql/functions mssql-bind.xml
mssql-connect.xml
mssql-data-seek.xml
mssql-execute.xml
mssql-fetch-array.xml
mssql-fetch-assoc.xml
mssql-fetch-batch.xml
mssql-fetch-field.xml
mssql-fetch-object.xml
mssql-fetch-row.xml
mssql-field-length.xml
mssql-field-name.xml
mssql-field-seek.xml
mssql-field-type.xml
mssql-free-result.xml
mssql-free-statement.xml
mssql-get-last-message.xml
mssql-guid-string.xml
mssql-init.xml
mssql-min-error-severity.xml
mssql-min-message-severity.xml
mssql-next-result.xml
mssql-num-fields.xml
mssql-pconnect.xml
mssql-query.xml
mssql-result.xml
mssql-rows-affected.xml
Log:
News
* Added missing <literal> on setup note
* Added a reference to PDO_DBLIB and PDO_ODBC on setup note
* Added a source comment on mssql_connect() explaining how to use a connect with a custom port
* Added undocumented ini setting mssql.charset (available as of PHP 5.1.2)
* Added missing parameter descriptions on mssql_guid_string
* Added missing examples for
* mssql_data_seek (Ross)
* mssql_execute
* mssql_fetch_array
* mssql_fetch_assoc
* mssql_fetch_field
* mssql_fetch_object
* mssql_fetch_row (RMLR)
* mssql_field_length
* mssql_field_name
* mssql_field_seek
* mssql_field_type
* mssql_free_result
* mssql_free_statement
* mssql_get_last_message
* mssql_guid_string
* mssql_init
* mssql_min_error_severity
* mssql_min_message_severity
* mssql_num_fields
* mssql_pconnect (RMLR)
* mssql_result
* Added constant descriptions
* Documented the following functions
* mssql_get_last_message
* mssql_min_error_severity
* mssql_min_message_severity
* Changed examples on the following
* mssql_bind
* mssql_fetch_batch
* mssql_next_result
* mssql_query
* Fixed example on mssql_rows_affected
http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/constants.xml?r1=1.4&r2=1.5&diff_format=u Index: phpdoc/en/reference/mssql/constants.xml diff -u phpdoc/en/reference/mssql/constants.xml:1.4 phpdoc/en/reference/mssql/constants.xml:1.5 --- phpdoc/en/reference/mssql/constants.xml:1.4 Wed Dec 26 13:57:52 2007 +++ phpdoc/en/reference/mssql/constants.xml Wed Oct 8 18:29:22 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.4 $ --> +<!-- $Revision: 1.5 $ --> <appendix xml:id="mssql.constants" xmlns="http://docbook.org/ns/docbook"> &reftitle.constants; &extension.constants; @@ -11,7 +11,9 @@ </term> <listitem> <simpara> - + Return an associative array. Used on + <function>mssql_fetch_array</function>'s + <literal>result_type</literal> parameter. </simpara> </listitem> </varlistentry> @@ -22,7 +24,9 @@ </term> <listitem> <simpara> - + Return an array with numeric keys. Used on + <function>mssql_fetch_array</function>'s + <literal>result_type</literal> parameter. </simpara> </listitem> </varlistentry> @@ -33,7 +37,10 @@ </term> <listitem> <simpara> - + Return an array with both numeric keys and + keys with their field name. This is the + default value for <function>mssql_fetch_array</function>'s + <literal>result_type</literal> parameter. </simpara> </listitem> </varlistentry> @@ -44,7 +51,9 @@ </term> <listitem> <simpara> - + Indicates the 'TEXT' type in MSSQL, used by + <function>mssql_bind</function>'s <literal>type</literal> + parameter. </simpara> </listitem> </varlistentry> @@ -55,7 +64,9 @@ </term> <listitem> <simpara> - + Indicates the 'VARCHAR' type in MSSQL, used by + <function>mssql_bind</function>'s <literal>type</literal> + parameter. </simpara> </listitem> </varlistentry> @@ -66,7 +77,9 @@ </term> <listitem> <simpara> - + Indicates the 'CHAR' type in MSSQL, used by + <function>mssql_bind</function>'s <literal>type</literal> + parameter. </simpara> </listitem> </varlistentry> @@ -77,7 +90,7 @@ </term> <listitem> <simpara> - + Represents one byte, with a range of -128 to 127. </simpara> </listitem> </varlistentry> @@ -88,7 +101,8 @@ </term> <listitem> <simpara> - + Represents two bytes, with a range of -32768 + to 32767. </simpara> </listitem> </varlistentry> @@ -99,7 +113,8 @@ </term> <listitem> <simpara> - + Represents four bytes, with a range if -2147483648 + to 2147483647. </simpara> </listitem> </varlistentry> @@ -110,7 +125,9 @@ </term> <listitem> <simpara> - + Indicates the 'BIT' type in MSSQL, used by + <function>mssql_bind</function>'s <literal>type</literal> + parameter. </simpara> </listitem> </varlistentry> @@ -121,7 +138,7 @@ </term> <listitem> <simpara> - + Represents an eight byte float. </simpara> </listitem> </varlistentry> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/ini.xml?r1=1.6&r2=1.7&diff_format=u Index: phpdoc/en/reference/mssql/ini.xml diff -u phpdoc/en/reference/mssql/ini.xml:1.6 phpdoc/en/reference/mssql/ini.xml:1.7 --- phpdoc/en/reference/mssql/ini.xml:1.6 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/ini.xml Wed Oct 8 18:29:22 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <section xml:id="mssql.configuration" xmlns="http://docbook.org/ns/docbook"> &reftitle.runtime; &extension.runtime; @@ -100,6 +100,12 @@ <entry>PHP_INI_ALL</entry> <entry>Available since PHP 4.3.0.</entry> </row> + <row> + <entry>mssql.charset</entry> + <entry>""</entry> + <entry>PHP_INI_ALL</entry> + <entry>Available since PHP 5.1.2 when built with FreeTDS.</entry> + </row> </tbody> </tgroup> </table> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/setup.xml?r1=1.5&r2=1.6&diff_format=u Index: phpdoc/en/reference/mssql/setup.xml diff -u phpdoc/en/reference/mssql/setup.xml:1.5 phpdoc/en/reference/mssql/setup.xml:1.6 --- phpdoc/en/reference/mssql/setup.xml:1.5 Tue Oct 7 07:31:57 2008 +++ phpdoc/en/reference/mssql/setup.xml Wed Oct 8 18:29:22 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <chapter xml:id="mssql.setup" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> &reftitle.setup; @@ -32,7 +32,7 @@ </para> <note> <para> - In Windows, the DBLIB from Microsoft is used. Functions that return a + On Windows, the DBLIB from Microsoft is used. Functions that return a column name are based on the <literal>dbcolname()</literal> function in DBLIB. DBLIB was developed for SQL Server 6.x where the max identifier length is 30. For this reason, the maximum column length @@ -43,10 +43,12 @@ <note> <para> On Windows, if you're using MSSQL 2005 or greater you must copy the - ntwdblib.dll into the directory where you have installed php and overwrite - the one thats already in there. This is due to the version distributed is - old and outdated. Alternatively you can use the <link linkend="book.uodbc"> - ODBC extension</link>, to talk to MSSQL. + <literal>ntwdblib.dll</literal> into the directory where you have + installed php and overwrite the one thats already in there. This is + due to the version distributed is old and outdated. Alternatively you + can use the <link linkend="book.uodbc">ODBC extension</link>, + <link linkend="ref.pdo-dblib">PDO_DBLIB</link> or + <link linkend="ref.pdo-odbc">PDO_ODBC</link>, to talk to MSSQL. </para> </note> </section> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-bind.xml?r1=1.14&r2=1.15&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-bind.xml diff -u phpdoc/en/reference/mssql/functions/mssql-bind.xml:1.14 phpdoc/en/reference/mssql/functions/mssql-bind.xml:1.15 --- phpdoc/en/reference/mssql/functions/mssql-bind.xml:1.14 Tue Oct 7 02:34:38 2008 +++ phpdoc/en/reference/mssql/functions/mssql-bind.xml Wed Oct 8 18:29:22 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.14 $ --> +<!-- $Revision: 1.15 $ --> <refentry xml:id='function.mssql-bind' xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_bind</refname> @@ -117,22 +117,27 @@ &reftitle.examples; <para> <example> - <title><function>mssql_bind</function> Example</title> + <title><function>mssql_bind</function> example</title> <programlisting role="php"> <![CDATA[ <?php +// Connect to MSSQL +mssql_connect('KALLESPC\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php'); + +// Create a new stored prodecure +$stmt = mssql_init('NewUserRecord'); + +// Bind the field names +mssql_bind($stmt, '@username', 'Kalle', SQLVARCHAR, false, false, 60); +mssql_bind($stmt, '@name', 'Kalle', SQLVARCHAR, false, false, 60); +mssql_bind($stmt, '@age', 19, SQLINT1, false, false, 3); -$cn = mssql_connect($DBSERVER, $DBUSER, $DBPASS); -mssql_select_db($DB, $cn); - -$sp = mssql_init("WDumpAdd"); // stored proc name - -mssql_bind($sp, "@productname", stripslashes($newproduct), SQLVARCHAR, false, false, 150); -mssql_bind($sp, "@quantity", stripslashes($newquantity), SQLVARCHAR, false, false, 50); - -mssql_execute($sp); -mssql_close($cn); +// Execute +mssql_execute($stmt); +// Free statement +mssql_free_statement($stmt); ?> ]]> </programlisting> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-connect.xml?r1=1.10&r2=1.11&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-connect.xml diff -u phpdoc/en/reference/mssql/functions/mssql-connect.xml:1.10 phpdoc/en/reference/mssql/functions/mssql-connect.xml:1.11 --- phpdoc/en/reference/mssql/functions/mssql-connect.xml:1.10 Tue Oct 7 02:34:38 2008 +++ phpdoc/en/reference/mssql/functions/mssql-connect.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.10 $ --> +<!-- $Revision: 1.11 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.mssql-connect"> <refnamediv> <refname>mssql_connect</refname> @@ -112,7 +112,8 @@ <programlisting role="php"> <![CDATA[ <?php -// Server in the this format: <computer>\<instance name> +// Server in the this format: <computer>\<instance name> or +// <server>,<port> when using a non default port number $server = 'KALLESPC\SQLEXPRESS'; $link = mssql_connect($server, 'sa', 'phpfi'); http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-data-seek.xml?r1=1.8&r2=1.9&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-data-seek.xml diff -u phpdoc/en/reference/mssql/functions/mssql-data-seek.xml:1.8 phpdoc/en/reference/mssql/functions/mssql-data-seek.xml:1.9 --- phpdoc/en/reference/mssql/functions/mssql-data-seek.xml:1.8 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-data-seek.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <refentry xml:id="function.mssql-data-seek" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_data_seek</refname> @@ -52,6 +52,47 @@ &return.success; </para> </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_fetch_array</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect to MSSQL +$link = mssql_connect('MANGO\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php', $link); + +// Select all people +$result = mssql_query('SELECT [name], [age] FROM [persons] WHERE [age] >= 13'); + +if(!$result) +{ + die('Query failed.'); +} + +// Select every 4th student in the results +for($i = mssql_num_rows($result) - 1; $i % 4; $i++) +{ + if(!mssql_data_seek($result, $i)) + { + continue; + } + + // Fetch the row ... +} + +// Free the query result +mssql_free_result($result); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-execute.xml?r1=1.10&r2=1.11&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-execute.xml diff -u phpdoc/en/reference/mssql/functions/mssql-execute.xml:1.10 phpdoc/en/reference/mssql/functions/mssql-execute.xml:1.11 --- phpdoc/en/reference/mssql/functions/mssql-execute.xml:1.10 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-execute.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.10 $ --> +<!-- $Revision: 1.11 $ --> <refentry xml:id='function.mssql-execute' xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_execute</refname> @@ -41,6 +41,39 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_execute</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Create a new statement +$stmt = mssql_init('NewBlogEntry'); + +// Some data strings +$title = 'Test of blogging system'; +$content = 'If you can read this, then the new system is compatible with MSSQL'; + +// Bind values +mssql_bind($stmt, '@author', 'Felipe Pena', SQLVARCHAR, false, false, 60); +mssql_bind($stmt, '@date', '08/10/2008', SQLVARCHAR, false, false, 20); +mssql_bind($stmt, '@title', $title, SQLVARCHAR, false, false, 60); +mssql_bind($stmt, '@content', $content, SQLTEXT); + +// Execute the statement +mssql_execute($stmt); + +// And we can free it like so: +mssql_free_statement($stmt); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; <note> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-fetch-array.xml?r1=1.10&r2=1.11&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-fetch-array.xml diff -u phpdoc/en/reference/mssql/functions/mssql-fetch-array.xml:1.10 phpdoc/en/reference/mssql/functions/mssql-fetch-array.xml:1.11 --- phpdoc/en/reference/mssql/functions/mssql-fetch-array.xml:1.10 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-fetch-array.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.10 $ --> +<!-- $Revision: 1.11 $ --> <refentry xml:id="function.mssql-fetch-array" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_fetch_array</refname> @@ -63,6 +63,43 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_fetch_array</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Send a select query to MSSQL +$query = mssql_query('SELECT [username], [name] FROM [php].[dbo].[userlist]'); + +// Check if there were any records +if(!mssql_num_rows($query)) +{ + echo 'No records found'; +} +else +{ + // The follow is equal to the code below: + // + // while($row = mssql_fetch_row($query)) + + while($row = mssql_fetch_array($query, MSSQL_NUM)) + { + // ... + } +} + +// Free the query result +mssql_free_result($query); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; &database.field-case; http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-fetch-assoc.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-fetch-assoc.xml diff -u phpdoc/en/reference/mssql/functions/mssql-fetch-assoc.xml:1.7 phpdoc/en/reference/mssql/functions/mssql-fetch-assoc.xml:1.8 --- phpdoc/en/reference/mssql/functions/mssql-fetch-assoc.xml:1.7 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-fetch-assoc.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <refentry xml:id='function.mssql-fetch-assoc' xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_fetch_assoc</refname> @@ -37,6 +37,46 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_fetch_assoc</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Send a select query to MSSQL +$query = mssql_query('SELECT [username], [name] FROM [php].[dbo].[userlist]'); + +// Check if there were any records +if(!mssql_num_rows($query)) +{ + echo 'No records found'; +} +else +{ + // Print a nice list of users in the format of + // name (username) + + echo '<ul>'; + + while($row = mssql_fetch_assoc($query)) + { + echo '<li>' . $row['name'] . ' (' . $row['username'] . ')</li>'; + } + + echo '</ul>'; +} + +// Free the query result +mssql_free_result($query); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-fetch-batch.xml?r1=1.8&r2=1.9&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-fetch-batch.xml diff -u phpdoc/en/reference/mssql/functions/mssql-fetch-batch.xml:1.8 phpdoc/en/reference/mssql/functions/mssql-fetch-batch.xml:1.9 --- phpdoc/en/reference/mssql/functions/mssql-fetch-batch.xml:1.8 Tue Nov 6 21:46:00 2007 +++ phpdoc/en/reference/mssql/functions/mssql-fetch-batch.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <refentry xml:id='function.mssql-fetch-batch' xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_fetch_batch</refname> @@ -45,20 +45,32 @@ &reftitle.examples; <para> <example> - <title><function>mssql_fetch_batch</function> Example</title> + <title><function>mssql_fetch_batch</function> example</title> <programlisting role="php"> <![CDATA[ <?php -$resDb = mssql_connect('localhost', 'user', 'name'); -$result = mssql_query('SELECT * FROM MYTABLE', $resDb, 10000); +// Connect to MSSQL +$link = mssql_connect('MANGO\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php', $link); + +// Send a query +$result = mssql_query('SELECT * FROM [php].[dbo].[people]', $link, 100); +$records = 10; + +while(($records - 1) != -1) +{ + while($row = mssql_fetch_assoc($result)) + { + // Do stuff ... + } -$intNumRows = mssql_num_rows($result); + --$records; +} -while ($intNumRows > 0) { - while ($arrRow = mssql_fetch_assoc($result)) { - // Do stuff ... - } - $intNumRows = mssql_fetch_batch($result); +if($batchsize = mssql_fetch_batch($result)) +{ + // $batchsize is the number of records left + // in the result, but not shown above } ?> ]]> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-fetch-field.xml?r1=1.6&r2=1.7&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-fetch-field.xml diff -u phpdoc/en/reference/mssql/functions/mssql-fetch-field.xml:1.6 phpdoc/en/reference/mssql/functions/mssql-fetch-field.xml:1.7 --- phpdoc/en/reference/mssql/functions/mssql-fetch-field.xml:1.6 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-fetch-field.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <refentry xml:id="function.mssql-fetch-field" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_fetch_field</refname> @@ -85,6 +85,62 @@ </itemizedlist> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_fetch_field</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect MSSQL +mssql_connect('MANGO\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php'); + +// Send a select query to MSSQL +$query = mssql_query('SELECT * FROM [php].[dbo].[persons]'); + +// Construct table +echo '<h3>Table structure for \'persons\'</h3>'; +echo '<table border="1">'; + +// Table header +echo '<thead>'; +echo '<tr>'; +echo '<td>Field name</td>'; +echo '<td>Data type</td>'; +echo '<td>Max length</td>'; +echo '</tr>'; +echo '</thead>'; + +// Dump all fields +echo '<tbody>'; + +for($i = 0; $i < mssql_num_fields($query); ++$i) +{ + // Fetch the field information + $field = mssql_fetch_field($query, $i); + + // Print the row + echo '<tr>'; + echo '<td>' . $field->name . '</td>'; + echo '<td>' . strtoupper($field->type) . '</td>'; + echo '<td>' . $field->max_length . '</td>'; + echo '</tr>'; +} + +echo '</tbody>'; +echo '</table>'; + +// Free the query result +mssql_free_result($query); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-fetch-object.xml?r1=1.10&r2=1.11&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-fetch-object.xml diff -u phpdoc/en/reference/mssql/functions/mssql-fetch-object.xml:1.10 phpdoc/en/reference/mssql/functions/mssql-fetch-object.xml:1.11 --- phpdoc/en/reference/mssql/functions/mssql-fetch-object.xml:1.10 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-fetch-object.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.10 $ --> +<!-- $Revision: 1.11 $ --> <refentry xml:id="function.mssql-fetch-object" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_fetch_object</refname> @@ -52,6 +52,46 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_fetch_object</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Send a select query to MSSQL +$query = mssql_query('SELECT [username], [name] FROM [php].[dbo].[userlist]'); + +// Check if there were any records +if(!mssql_num_rows($query)) +{ + echo 'No records found'; +} +else +{ + // Print a nice list of users in the format of + // name (username) + + echo '<ul>'; + + while($row = mssql_fetch_object($query)) + { + echo '<li>' . $row->name . ' (' . $row->username . ')</li>'; + } + + echo '</ul>'; +} + +// Free the query result +mssql_free_result($query); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; &database.field-case; http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-fetch-row.xml?r1=1.10&r2=1.11&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-fetch-row.xml diff -u phpdoc/en/reference/mssql/functions/mssql-fetch-row.xml:1.10 phpdoc/en/reference/mssql/functions/mssql-fetch-row.xml:1.11 --- phpdoc/en/reference/mssql/functions/mssql-fetch-row.xml:1.10 Tue Nov 6 23:17:10 2007 +++ phpdoc/en/reference/mssql/functions/mssql-fetch-row.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.10 $ --> +<!-- $Revision: 1.11 $ --> <refentry xml:id="function.mssql-fetch-row" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_fetch_row</refname> @@ -50,6 +50,45 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_field_row</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect to server and database +$link = mssql_connect('MANGO\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php', $link); + +// Query to execute +$query = mssql_query('SELECT [id], [quote] FROM [quotes] WHERE [id] = \'42\'', $link); + +// Did the query failed? +if(!$query) +{ + die('MSSQL error: ' . mssql_get_last_message()); +} + +// Fetch the row +$row = mssql_fetch_row($query); + +// Print the 'quote' +echo 'Quote #' . $row[0] . ': "' . $row[1] . '"'; +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ +Quote #42: "The answer to everything..." +]]> + </screen> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; &database.fetch-null; http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-field-length.xml?r1=1.8&r2=1.9&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-field-length.xml diff -u phpdoc/en/reference/mssql/functions/mssql-field-length.xml:1.8 phpdoc/en/reference/mssql/functions/mssql-field-length.xml:1.9 --- phpdoc/en/reference/mssql/functions/mssql-field-length.xml:1.8 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-field-length.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <refentry xml:id="function.mssql-field-length" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_field_length</refname> @@ -51,14 +51,48 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_field_length</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect MSSQL +mssql_connect('MANGO\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php'); + +// Send a select query to MSSQL +$query = mssql_query('SELECT [name], [age] FROM [php].[dbo].[persons]'); + +// Print the field type and length +echo 'The field \'age\' has a data length of ' . mssql_field_length($query, 1); + +// Free the query result +mssql_free_result($query); +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ +The field 'age' has a data length of 4 +]]> + </screen> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; <note> - <title>Note to Win32 Users</title> + <title>Note to Windows Users</title> <para> - Due to a limitation in the underlying API used by PHP (MS DbLib C API), - the length of VARCHAR fields is limited to <emphasis>255</emphasis>. If - you need to store more data, use a TEXT field instead. + Due to a limitation in the underlying API used by PHP (MS DBLib C API), + the length of <literal>VARCHAR</literal> fields is limited to + <emphasis>255</emphasis>. If you need to store more data, use a + <literal>TEXT</literal> field instead. </para> </note> </refsect1> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-field-name.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-field-name.xml diff -u phpdoc/en/reference/mssql/functions/mssql-field-name.xml:1.7 phpdoc/en/reference/mssql/functions/mssql-field-name.xml:1.8 --- phpdoc/en/reference/mssql/functions/mssql-field-name.xml:1.7 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-field-name.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <refentry xml:id="function.mssql-field-name" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_field_name</refname> @@ -51,6 +51,43 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_field_name</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Send a select query to MSSQL +$query = mssql_query('SELECT [username], [name], [email] FROM [php].[dbo].[userlist]'); + +echo 'Result set contains the following field(s):', PHP_EOL; + +// Dump all field names in result +for($i = 0; $i < mssql_num_fields($query); ++$i) +{ + echo ' - ' . mssql_field_name($query, $i), PHP_EOL; +} + +// Free the query result +mssql_free_result($query); +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ +Result set contains the following field(s): + - username + - name + - email +]]> + </screen> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-field-seek.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-field-seek.xml diff -u phpdoc/en/reference/mssql/functions/mssql-field-seek.xml:1.7 phpdoc/en/reference/mssql/functions/mssql-field-seek.xml:1.8 --- phpdoc/en/reference/mssql/functions/mssql-field-seek.xml:1.7 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-field-seek.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <refentry xml:id="function.mssql-field-seek" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_field_seek</refname> @@ -52,6 +52,68 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Using <function>mssql_field_type</function> on the example for <function>mssql_fetch_field</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect MSSQL +mssql_connect('MANGO\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php'); + +// Send a select query to MSSQL +$query = mssql_query('SELECT * FROM [php].[dbo].[persons]'); + +// Construct table +echo '<h3>Table structure for \'persons\'</h3>'; +echo '<table border="1">'; + +// Table header +echo '<thead>'; +echo '<tr>'; +echo '<td>Field name</td>'; +echo '<td>Data type</td>'; +echo '<td>Max length</td>'; +echo '</tr>'; +echo '</thead>'; + +// Dump all fields +echo '<tbody>'; + +for($i = 0; $i < mssql_num_fields($query); ++$i) +{ + // Fetch the field information, notice the + // field_offset parameter is not set. See + // the mssql_field_seek call below + $field = mssql_fetch_field($query); + + // Print the row + echo '<tr>'; + echo '<td>' . $field->name . '</td>'; + echo '<td>' . strtoupper($field->type) . '</td>'; + echo '<td>' . $field->max_length . '</td>'; + echo '</tr>'; + + // Move the internal seek pointer to the next + // row in the result set + mssql_field_seek($query, $i + 1); +} + +echo '</tbody>'; +echo '</table>'; + +// Free the query result +mssql_free_result($query); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-field-type.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-field-type.xml diff -u phpdoc/en/reference/mssql/functions/mssql-field-type.xml:1.7 phpdoc/en/reference/mssql/functions/mssql-field-type.xml:1.8 --- phpdoc/en/reference/mssql/functions/mssql-field-type.xml:1.7 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-field-type.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <refentry xml:id="function.mssql-field-type" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_field_type</refname> @@ -51,6 +51,41 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_field_type</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect MSSQL +mssql_connect('MANGO\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php'); + +// Send a select query to MSSQL +$query = mssql_query('SELECT [name] FROM [php].[dbo].[persons]'); + +// Print the field type and length +echo '\'' . mssql_field_name($query, 0) . '\' is a type of ' . + strtoupper(mssql_field_type($query, 0)) . + '(' . mssql_field_length($query, 0) . ')'; + +// Free the query result +mssql_free_result($query); +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ +'name' is a type of CHAR(50) +]]> + </screen> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-free-result.xml?r1=1.6&r2=1.7&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-free-result.xml diff -u phpdoc/en/reference/mssql/functions/mssql-free-result.xml:1.6 phpdoc/en/reference/mssql/functions/mssql-free-result.xml:1.7 --- phpdoc/en/reference/mssql/functions/mssql-free-result.xml:1.6 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-free-result.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <refentry xml:id="function.mssql-free-result" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_free_result</refname> @@ -45,6 +45,38 @@ &return.success; </para> </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_free_result</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Select some data from a table +$query = mssql_query('SELECT * FROM [php].[dbo].[persons]', $link); + +// Handle query result here + +// When we're done we free the result by calling +// mssql_free_result like so: +mssql_free_result($query); +]]> + </programlisting> + </example> + </para> + </refsect1> + + <refsect1 role="seealso"> + &reftitle.seealso; + <para> + <simplelist> + <member><function>mssql_free_statement</function></member> + </simplelist> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-free-statement.xml?r1=1.6&r2=1.7&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-free-statement.xml diff -u phpdoc/en/reference/mssql/functions/mssql-free-statement.xml:1.6 phpdoc/en/reference/mssql/functions/mssql-free-statement.xml:1.7 --- phpdoc/en/reference/mssql/functions/mssql-free-statement.xml:1.6 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-free-statement.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <refentry xml:id="function.mssql-free-statement" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_free_statement</refname> @@ -45,6 +45,29 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_free_statement</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Create a new statement +$stmt = mssql_init('test'); + +// Bind values here and execute statement + +// once we're done, we clear it from the memory +// using mssql_free_statement like so: +mssql_free_statement($stmt); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> @@ -52,6 +75,7 @@ <member><function>mssql_bind</function></member> <member><function>mssql_execute</function></member> <member><function>mssql_init</function></member> + <member><function>mssql_free_result</function></member> </simplelist> </para> </refsect1> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-get-last-message.xml?r1=1.6&r2=1.7&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-get-last-message.xml diff -u phpdoc/en/reference/mssql/functions/mssql-get-last-message.xml:1.6 phpdoc/en/reference/mssql/functions/mssql-get-last-message.xml:1.7 --- phpdoc/en/reference/mssql/functions/mssql-get-last-message.xml:1.6 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-get-last-message.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <refentry xml:id="function.mssql-get-last-message" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_get_last_message</refname> @@ -10,11 +10,68 @@ &reftitle.description; <methodsynopsis> <type>string</type><methodname>mssql_get_last_message</methodname> - <void/> + <void /> </methodsynopsis> + <para> + Gets the last message from the MS-SQL server + </para> + </refsect1> + + <refsect1 role="parameters"> + &reftitle.parameters; + &no.function.parameters; + </refsect1> + + <refsect1 role="returnvalues"> + &reftitle.returnvalues; + <para> + Returns last error message from server, or an empty string if + no error messages are returned from MSSQL. + </para> + </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_get_last_message</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect to MSSQL +mssql_connect('KALLESPC\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php'); - &warn.undocumented.func; +// Make a query that will fail +$query = @mssql_query('SELECT * FROM [php].[dbo].[not-found]'); + +if(!$query) +{ + // The query has failed, print a nice error message + // using mssql_get_last_message() + die('MSSQL error: ' . mssql_get_last_error()); +} +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +MSSQL error: Invalid object name 'php.dbo.not-found'. +]]> + </screen> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> + &reftitle.seealso; + <para> + <simplelist> + <member><function>mssql_min_error_severity</function></member> + <member><function>mssql_min_message_Severity</function></member> + </simplelist> + </para> </refsect1> </refentry> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-guid-string.xml?r1=1.8&r2=1.9&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-guid-string.xml diff -u phpdoc/en/reference/mssql/functions/mssql-guid-string.xml:1.8 phpdoc/en/reference/mssql/functions/mssql-guid-string.xml:1.9 --- phpdoc/en/reference/mssql/functions/mssql-guid-string.xml:1.8 Tue Oct 7 07:55:11 2008 +++ phpdoc/en/reference/mssql/functions/mssql-guid-string.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <refentry xml:id='function.mssql-guid-string' xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_guid_string</refname> @@ -34,7 +34,7 @@ <term><parameter>short_format</parameter></term> <listitem> <para> - ... + Whenever to use short to use short format, defaults to &false; </para> </listitem> </varlistentry> @@ -49,6 +49,32 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_guid_string</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +$binary = '19555081977808608437941339997619274330352755554827939936'; + +var_dump(mssql_guid_string($binary)); +var_dump(mssql_guid_string($binary, true)); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +string(36) "35353931-3035-3138-3937-373830383630" +string(32) "31393535353038313937373830383630" +]]> + </screen> + </example> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-init.xml?r1=1.10&r2=1.11&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-init.xml diff -u phpdoc/en/reference/mssql/functions/mssql-init.xml:1.10 phpdoc/en/reference/mssql/functions/mssql-init.xml:1.11 --- phpdoc/en/reference/mssql/functions/mssql-init.xml:1.10 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-init.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.10 $ --> +<!-- $Revision: 1.11 $ --> <refentry xml:id='function.mssql-init' xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_init</refname> @@ -53,6 +53,42 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_init</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect to MSSQL +mssql_connect('KALLESPC\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php'); + +// Create a new statement +$stmt = mssql_init('StatementTest', $link); + +// Bind values here + +// Once values are binded we execute our statement +// using mssql_execute: +mssql_execute($stmt); + +// And we can free it like so: +mssql_free_statement($stmt); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +MSSQL error: Invalid object name 'php.dbo.not-found'. +]]> + </screen> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-min-error-severity.xml?r1=1.6&r2=1.7&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-min-error-severity.xml diff -u phpdoc/en/reference/mssql/functions/mssql-min-error-severity.xml:1.6 phpdoc/en/reference/mssql/functions/mssql-min-error-severity.xml:1.7 --- phpdoc/en/reference/mssql/functions/mssql-min-error-severity.xml:1.6 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-min-error-severity.xml Wed Oct 8 18:29:23 2008 @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <refentry xml:id="function.mssql-min-error-severity" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_min_error_severity</refname> - <refpurpose>Sets the lower error severity</refpurpose> + <refpurpose>Sets the minimum error severity</refpurpose> </refnamediv> <refsect1 role="description"> @@ -12,9 +12,9 @@ <type>void</type><methodname>mssql_min_error_severity</methodname> <methodparam><type>int</type><parameter>severity</parameter></methodparam> </methodsynopsis> - - &warn.undocumented.func; - + <para> + Sets the minimum error severity. + </para> </refsect1> <refsect1 role="parameters"> @@ -25,6 +25,7 @@ <term><parameter>severity</parameter></term> <listitem> <para> + The new error severity. </para> </listitem> </varlistentry> @@ -38,6 +39,40 @@ &return.void; </para> </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_min_message_severity</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect to MSSQL +mssql_connect('KALLESPC\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php'); + +// Set the minimum error severity to not include SQL +// syntax errors by setting it to something greater than +// or equal to 1. +mssql_min_error_severity(1); + +// Send a query we know that will cause an syntax error, in +// this case we use the MySQL quote signs instead of wrapping +// square brackets around the field and table names. +$query = mssql_query('SELECT `syntax`, `error` FROM `MSSQL`'); + +if(!$query) +{ + // Custom error handler ... +} +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-min-message-severity.xml?r1=1.6&r2=1.7&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-min-message-severity.xml diff -u phpdoc/en/reference/mssql/functions/mssql-min-message-severity.xml:1.6 phpdoc/en/reference/mssql/functions/mssql-min-message-severity.xml:1.7 --- phpdoc/en/reference/mssql/functions/mssql-min-message-severity.xml:1.6 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-min-message-severity.xml Wed Oct 8 18:29:23 2008 @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <refentry xml:id="function.mssql-min-message-severity" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_min_message_severity</refname> - <refpurpose>Sets the lower message severity</refpurpose> + <refpurpose>Sets the minimum message severity</refpurpose> </refnamediv> <refsect1 role="description"> @@ -12,9 +12,9 @@ <type>void</type><methodname>mssql_min_message_severity</methodname> <methodparam><type>int</type><parameter>severity</parameter></methodparam> </methodsynopsis> - - &warn.undocumented.func; - + <para> + Sets the minimum message severity. + </para> </refsect1> <refsect1 role="parameters"> @@ -25,6 +25,7 @@ <term><parameter>severity</parameter></term> <listitem> <para> + The new message severity. </para> </listitem> </varlistentry> @@ -38,6 +39,38 @@ &return.void; </para> </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_min_message_severity</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect to MSSQL +mssql_connect('KALLESPC\SQLEXPRESS', 'sa', 'phpfi'); + +// Set the minimum message severity to 17, this +// will not show any messages issued by the underlaying +// API when we select a non-existent database below +mssql_min_message_severity(17); + +// Select a non-existent database +mssql_select_db('THIS_DATABASE_DOES_NOT_EXISTS'); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +mssql_select_db(): Unable to select database: THIS_DATABASE_DOES_NOT_EXISTS +]]> + </screen> + </example> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-next-result.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-next-result.xml diff -u phpdoc/en/reference/mssql/functions/mssql-next-result.xml:1.7 phpdoc/en/reference/mssql/functions/mssql-next-result.xml:1.8 --- phpdoc/en/reference/mssql/functions/mssql-next-result.xml:1.7 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-next-result.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <refentry xml:id="function.mssql-next-result" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_next_result</refname> @@ -55,15 +55,26 @@ <programlisting role="php"> <![CDATA[ <?php -$link = mssql_connect("localhost", "userid", "secret"); -mssql_select_db("MyDB", $link); -$sql = "Select * from table1 select * from table2"; -$rs = mssql_query($sql, $link); -do { - while ($row = mssql_fetch_row($rs)) { - } -} while (mssql_next_result($rs)); -mssql_free_result($rs); +// Connect MSSQL +$link = mssql_connect('MANGO\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php', $link); + +// Send a query to MSSQL +$sql = 'SELECT [name], [age] FROM [php].[dbo].[persons]'; +$query = mssql_query($sql, $link); + +// Iterate through returned records +do +{ + while($row = mssql_fetch_row($query)) + { + // Handle record ... + } +} +while(mssql_next_result($query)); + +// Clean up +mssql_free_result($query); mssql_close($link); ?> ]]> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-num-fields.xml?r1=1.8&r2=1.9&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-num-fields.xml diff -u phpdoc/en/reference/mssql/functions/mssql-num-fields.xml:1.8 phpdoc/en/reference/mssql/functions/mssql-num-fields.xml:1.9 --- phpdoc/en/reference/mssql/functions/mssql-num-fields.xml:1.8 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-num-fields.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <refentry xml:id="function.mssql-num-fields" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_num_fields</refname> @@ -42,6 +42,72 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_num_fields</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect to MSSQL +$link = mssql_connect('KALLESPC\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php', $link); + +// Select some data from our database +$data = mssql_query('SELECT [name], [age] FROM [php].[dbo].[persons]'); + +// Construct a table +echo '<table border="1">'; + +$header = false; + +// Iterate through returned results +while($row = mssql_fetch_array($data)) +{ + // Build the table header + if(!$header) + { + echo '<thead>'; + echo '<tr>'; + + for($i = 1; ($i + 1) <= mssql_num_fields($data); ++$i) + { + echo '<td>' . ucfirst($row[$i]) . '</td>'; + } + + echo '</tr>'; + echo '</thead>'; + echo '<tbody>'; + + $header = true; + } + + // Build the row + echo '<tr>'; + + foreach($row as $value) + { + echo '<td>' . $value . '</td>'; + } + + echo '</tr>'; +} + +// Close table +echo '</tbody>'; +echo '</table>'; + +// Clean up +mssql_free_result($data); +mssql_close($link); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-pconnect.xml?r1=1.8&r2=1.9&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-pconnect.xml diff -u phpdoc/en/reference/mssql/functions/mssql-pconnect.xml:1.8 phpdoc/en/reference/mssql/functions/mssql-pconnect.xml:1.9 --- phpdoc/en/reference/mssql/functions/mssql-pconnect.xml:1.8 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-pconnect.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <refentry xml:id="function.mssql-pconnect" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_pconnect</refname> @@ -90,6 +90,29 @@ &false; on error. </para> </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_pconnect</function> using the <parameter>new_link</parameter> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect to the database server +$link1 = mssql_pconnect('MANGO\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php', $link1); + +// Create a new link +$link2 = mssql_pconnect('MANGO\SQLEXPRESS', 'sa', 'phpfi', true); +mssql_select_db('random', $link2); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-query.xml?r1=1.12&r2=1.13&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-query.xml diff -u phpdoc/en/reference/mssql/functions/mssql-query.xml:1.12 phpdoc/en/reference/mssql/functions/mssql-query.xml:1.13 --- phpdoc/en/reference/mssql/functions/mssql-query.xml:1.12 Tue Oct 7 02:34:38 2008 +++ phpdoc/en/reference/mssql/functions/mssql-query.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.12 $ --> +<!-- $Revision: 1.13 $ --> <refentry xml:id="function.mssql-query" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_query</refname> @@ -77,8 +77,12 @@ <![CDATA[ <?php // Connect to MSSQL -$link = mssql_connect('KALLESPC\SQLEXPRESS', 'sa', 'phpfi') or die('Unable to connect MSSQL'); -mssql_select_db('php', $link) or die('Unable to select database'); +$link = mssql_connect('KALLESPC\SQLEXPRESS', 'sa', 'phpfi'); + +if(!$link || !mssql_select_db('php', $link)) +{ + die('Unable to connect or select database!'); +} // Do a simple query, select the version of // MSSQL and print it. http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-result.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-result.xml diff -u phpdoc/en/reference/mssql/functions/mssql-result.xml:1.7 phpdoc/en/reference/mssql/functions/mssql-result.xml:1.8 --- phpdoc/en/reference/mssql/functions/mssql-result.xml:1.7 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-result.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <refentry xml:id="function.mssql-result" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_result</refname> @@ -71,6 +71,77 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_result</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Send a select query to MSSQL +$query = mssql_query('SELECT [username] FROM [php].[dbo].[userlist]'); + +// Check if there were any records +if(!mssql_num_rows($query)) +{ + echo 'No records found'; +} +else +{ + for($i = 0; $i < mssql_num_rows($query); ++$i) + { + echo mssql_result($query, $i, 'username'), PHP_EOL; + } +} + +// Free the query result +mssql_free_result($query); +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ +Kalle +Felipe +Emil +Ross +]]> + </screen> + </example> + </para> + <para> + <example> + <title>Faster alternative to above example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Send a select query to MSSQL +$query = mssql_query('SELECT [username] FROM [php].[dbo].[userlist]'); + +// Check if there were any records +if(!mssql_num_rows($query)) +{ + echo 'No records found'; +} +else +{ + while($row = mssql_fetch_array($query)) + { + echo $row['username'], PHP_EOL; + } +} + +// Free the query result +mssql_free_result($query); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; <note> @@ -90,6 +161,7 @@ <simplelist> <member><function>mssql_fetch_row</function></member> <member><function>mssql_fetch_array</function></member> + <member><function>mssql_fetch_assoc</function></member> <member><function>mssql_fetch_object</function></member> </simplelist> </para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-rows-affected.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-rows-affected.xml diff -u phpdoc/en/reference/mssql/functions/mssql-rows-affected.xml:1.7 phpdoc/en/reference/mssql/functions/mssql-rows-affected.xml:1.8 --- phpdoc/en/reference/mssql/functions/mssql-rows-affected.xml:1.7 Tue Oct 7 02:34:38 2008 +++ phpdoc/en/reference/mssql/functions/mssql-rows-affected.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <refentry xml:id='function.mssql-rows-affected' xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_rows_affected</refname> @@ -49,7 +49,7 @@ <title><function>mssql_rows_affected</function> example</title> <programlisting role="php"> <![CDATA[ -<?php´ +<?php // Delete all rows in a table mssql_query('TRUNCATE TABLE [php].[dbo].[persons]');
http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/constants.xml?r1=1.4&r2=1.5&diff_format=u Index: phpdoc/en/reference/mssql/constants.xml diff -u phpdoc/en/reference/mssql/constants.xml:1.4 phpdoc/en/reference/mssql/constants.xml:1.5 --- phpdoc/en/reference/mssql/constants.xml:1.4 Wed Dec 26 13:57:52 2007 +++ phpdoc/en/reference/mssql/constants.xml Wed Oct 8 18:29:22 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.4 $ --> +<!-- $Revision: 1.5 $ --> <appendix xml:id="mssql.constants" xmlns="http://docbook.org/ns/docbook"> &reftitle.constants; &extension.constants; @@ -11,7 +11,9 @@ </term> <listitem> <simpara> - + Return an associative array. Used on + <function>mssql_fetch_array</function>'s + <literal>result_type</literal> parameter. </simpara> </listitem> </varlistentry> @@ -22,7 +24,9 @@ </term> <listitem> <simpara> - + Return an array with numeric keys. Used on + <function>mssql_fetch_array</function>'s + <literal>result_type</literal> parameter. </simpara> </listitem> </varlistentry> @@ -33,7 +37,10 @@ </term> <listitem> <simpara> - + Return an array with both numeric keys and + keys with their field name. This is the + default value for <function>mssql_fetch_array</function>'s + <literal>result_type</literal> parameter. </simpara> </listitem> </varlistentry> @@ -44,7 +51,9 @@ </term> <listitem> <simpara> - + Indicates the 'TEXT' type in MSSQL, used by + <function>mssql_bind</function>'s <literal>type</literal> + parameter. </simpara> </listitem> </varlistentry> @@ -55,7 +64,9 @@ </term> <listitem> <simpara> - + Indicates the 'VARCHAR' type in MSSQL, used by + <function>mssql_bind</function>'s <literal>type</literal> + parameter. </simpara> </listitem> </varlistentry> @@ -66,7 +77,9 @@ </term> <listitem> <simpara> - + Indicates the 'CHAR' type in MSSQL, used by + <function>mssql_bind</function>'s <literal>type</literal> + parameter. </simpara> </listitem> </varlistentry> @@ -77,7 +90,7 @@ </term> <listitem> <simpara> - + Represents one byte, with a range of -128 to 127. </simpara> </listitem> </varlistentry> @@ -88,7 +101,8 @@ </term> <listitem> <simpara> - + Represents two bytes, with a range of -32768 + to 32767. </simpara> </listitem> </varlistentry> @@ -99,7 +113,8 @@ </term> <listitem> <simpara> - + Represents four bytes, with a range if -2147483648 + to 2147483647. </simpara> </listitem> </varlistentry> @@ -110,7 +125,9 @@ </term> <listitem> <simpara> - + Indicates the 'BIT' type in MSSQL, used by + <function>mssql_bind</function>'s <literal>type</literal> + parameter. </simpara> </listitem> </varlistentry> @@ -121,7 +138,7 @@ </term> <listitem> <simpara> - + Represents an eight byte float. </simpara> </listitem> </varlistentry> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/ini.xml?r1=1.6&r2=1.7&diff_format=u Index: phpdoc/en/reference/mssql/ini.xml diff -u phpdoc/en/reference/mssql/ini.xml:1.6 phpdoc/en/reference/mssql/ini.xml:1.7 --- phpdoc/en/reference/mssql/ini.xml:1.6 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/ini.xml Wed Oct 8 18:29:22 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <section xml:id="mssql.configuration" xmlns="http://docbook.org/ns/docbook"> &reftitle.runtime; &extension.runtime; @@ -100,6 +100,12 @@ <entry>PHP_INI_ALL</entry> <entry>Available since PHP 4.3.0.</entry> </row> + <row> + <entry>mssql.charset</entry> + <entry>""</entry> + <entry>PHP_INI_ALL</entry> + <entry>Available since PHP 5.1.2 when built with FreeTDS.</entry> + </row> </tbody> </tgroup> </table> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/setup.xml?r1=1.5&r2=1.6&diff_format=u Index: phpdoc/en/reference/mssql/setup.xml diff -u phpdoc/en/reference/mssql/setup.xml:1.5 phpdoc/en/reference/mssql/setup.xml:1.6 --- phpdoc/en/reference/mssql/setup.xml:1.5 Tue Oct 7 07:31:57 2008 +++ phpdoc/en/reference/mssql/setup.xml Wed Oct 8 18:29:22 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <chapter xml:id="mssql.setup" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> &reftitle.setup; @@ -32,7 +32,7 @@ </para> <note> <para> - In Windows, the DBLIB from Microsoft is used. Functions that return a + On Windows, the DBLIB from Microsoft is used. Functions that return a column name are based on the <literal>dbcolname()</literal> function in DBLIB. DBLIB was developed for SQL Server 6.x where the max identifier length is 30. For this reason, the maximum column length @@ -43,10 +43,12 @@ <note> <para> On Windows, if you're using MSSQL 2005 or greater you must copy the - ntwdblib.dll into the directory where you have installed php and overwrite - the one thats already in there. This is due to the version distributed is - old and outdated. Alternatively you can use the <link linkend="book.uodbc"> - ODBC extension</link>, to talk to MSSQL. + <literal>ntwdblib.dll</literal> into the directory where you have + installed php and overwrite the one thats already in there. This is + due to the version distributed is old and outdated. Alternatively you + can use the <link linkend="book.uodbc">ODBC extension</link>, + <link linkend="ref.pdo-dblib">PDO_DBLIB</link> or + <link linkend="ref.pdo-odbc">PDO_ODBC</link>, to talk to MSSQL. </para> </note> </section> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-bind.xml?r1=1.14&r2=1.15&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-bind.xml diff -u phpdoc/en/reference/mssql/functions/mssql-bind.xml:1.14 phpdoc/en/reference/mssql/functions/mssql-bind.xml:1.15 --- phpdoc/en/reference/mssql/functions/mssql-bind.xml:1.14 Tue Oct 7 02:34:38 2008 +++ phpdoc/en/reference/mssql/functions/mssql-bind.xml Wed Oct 8 18:29:22 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.14 $ --> +<!-- $Revision: 1.15 $ --> <refentry xml:id='function.mssql-bind' xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_bind</refname> @@ -117,22 +117,27 @@ &reftitle.examples; <para> <example> - <title><function>mssql_bind</function> Example</title> + <title><function>mssql_bind</function> example</title> <programlisting role="php"> <![CDATA[ <?php +// Connect to MSSQL +mssql_connect('KALLESPC\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php'); + +// Create a new stored prodecure +$stmt = mssql_init('NewUserRecord'); + +// Bind the field names +mssql_bind($stmt, '@username', 'Kalle', SQLVARCHAR, false, false, 60); +mssql_bind($stmt, '@name', 'Kalle', SQLVARCHAR, false, false, 60); +mssql_bind($stmt, '@age', 19, SQLINT1, false, false, 3); -$cn = mssql_connect($DBSERVER, $DBUSER, $DBPASS); -mssql_select_db($DB, $cn); - -$sp = mssql_init("WDumpAdd"); // stored proc name - -mssql_bind($sp, "@productname", stripslashes($newproduct), SQLVARCHAR, false, false, 150); -mssql_bind($sp, "@quantity", stripslashes($newquantity), SQLVARCHAR, false, false, 50); - -mssql_execute($sp); -mssql_close($cn); +// Execute +mssql_execute($stmt); +// Free statement +mssql_free_statement($stmt); ?> ]]> </programlisting> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-connect.xml?r1=1.10&r2=1.11&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-connect.xml diff -u phpdoc/en/reference/mssql/functions/mssql-connect.xml:1.10 phpdoc/en/reference/mssql/functions/mssql-connect.xml:1.11 --- phpdoc/en/reference/mssql/functions/mssql-connect.xml:1.10 Tue Oct 7 02:34:38 2008 +++ phpdoc/en/reference/mssql/functions/mssql-connect.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.10 $ --> +<!-- $Revision: 1.11 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.mssql-connect"> <refnamediv> <refname>mssql_connect</refname> @@ -112,7 +112,8 @@ <programlisting role="php"> <![CDATA[ <?php -// Server in the this format: <computer>\<instance name> +// Server in the this format: <computer>\<instance name> or +// <server>,<port> when using a non default port number $server = 'KALLESPC\SQLEXPRESS'; $link = mssql_connect($server, 'sa', 'phpfi'); http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-data-seek.xml?r1=1.8&r2=1.9&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-data-seek.xml diff -u phpdoc/en/reference/mssql/functions/mssql-data-seek.xml:1.8 phpdoc/en/reference/mssql/functions/mssql-data-seek.xml:1.9 --- phpdoc/en/reference/mssql/functions/mssql-data-seek.xml:1.8 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-data-seek.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <refentry xml:id="function.mssql-data-seek" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_data_seek</refname> @@ -52,6 +52,47 @@ &return.success; </para> </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_fetch_array</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect to MSSQL +$link = mssql_connect('MANGO\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php', $link); + +// Select all people +$result = mssql_query('SELECT [name], [age] FROM [persons] WHERE [age] >= 13'); + +if(!$result) +{ + die('Query failed.'); +} + +// Select every 4th student in the results +for($i = mssql_num_rows($result) - 1; $i % 4; $i++) +{ + if(!mssql_data_seek($result, $i)) + { + continue; + } + + // Fetch the row ... +} + +// Free the query result +mssql_free_result($result); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-execute.xml?r1=1.10&r2=1.11&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-execute.xml diff -u phpdoc/en/reference/mssql/functions/mssql-execute.xml:1.10 phpdoc/en/reference/mssql/functions/mssql-execute.xml:1.11 --- phpdoc/en/reference/mssql/functions/mssql-execute.xml:1.10 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-execute.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.10 $ --> +<!-- $Revision: 1.11 $ --> <refentry xml:id='function.mssql-execute' xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_execute</refname> @@ -41,6 +41,39 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_execute</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Create a new statement +$stmt = mssql_init('NewBlogEntry'); + +// Some data strings +$title = 'Test of blogging system'; +$content = 'If you can read this, then the new system is compatible with MSSQL'; + +// Bind values +mssql_bind($stmt, '@author', 'Felipe Pena', SQLVARCHAR, false, false, 60); +mssql_bind($stmt, '@date', '08/10/2008', SQLVARCHAR, false, false, 20); +mssql_bind($stmt, '@title', $title, SQLVARCHAR, false, false, 60); +mssql_bind($stmt, '@content', $content, SQLTEXT); + +// Execute the statement +mssql_execute($stmt); + +// And we can free it like so: +mssql_free_statement($stmt); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; <note> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-fetch-array.xml?r1=1.10&r2=1.11&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-fetch-array.xml diff -u phpdoc/en/reference/mssql/functions/mssql-fetch-array.xml:1.10 phpdoc/en/reference/mssql/functions/mssql-fetch-array.xml:1.11 --- phpdoc/en/reference/mssql/functions/mssql-fetch-array.xml:1.10 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-fetch-array.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.10 $ --> +<!-- $Revision: 1.11 $ --> <refentry xml:id="function.mssql-fetch-array" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_fetch_array</refname> @@ -63,6 +63,43 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_fetch_array</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Send a select query to MSSQL +$query = mssql_query('SELECT [username], [name] FROM [php].[dbo].[userlist]'); + +// Check if there were any records +if(!mssql_num_rows($query)) +{ + echo 'No records found'; +} +else +{ + // The follow is equal to the code below: + // + // while($row = mssql_fetch_row($query)) + + while($row = mssql_fetch_array($query, MSSQL_NUM)) + { + // ... + } +} + +// Free the query result +mssql_free_result($query); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; &database.field-case; http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-fetch-assoc.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-fetch-assoc.xml diff -u phpdoc/en/reference/mssql/functions/mssql-fetch-assoc.xml:1.7 phpdoc/en/reference/mssql/functions/mssql-fetch-assoc.xml:1.8 --- phpdoc/en/reference/mssql/functions/mssql-fetch-assoc.xml:1.7 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-fetch-assoc.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <refentry xml:id='function.mssql-fetch-assoc' xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_fetch_assoc</refname> @@ -37,6 +37,46 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_fetch_assoc</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Send a select query to MSSQL +$query = mssql_query('SELECT [username], [name] FROM [php].[dbo].[userlist]'); + +// Check if there were any records +if(!mssql_num_rows($query)) +{ + echo 'No records found'; +} +else +{ + // Print a nice list of users in the format of + // name (username) + + echo '<ul>'; + + while($row = mssql_fetch_assoc($query)) + { + echo '<li>' . $row['name'] . ' (' . $row['username'] . ')</li>'; + } + + echo '</ul>'; +} + +// Free the query result +mssql_free_result($query); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-fetch-batch.xml?r1=1.8&r2=1.9&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-fetch-batch.xml diff -u phpdoc/en/reference/mssql/functions/mssql-fetch-batch.xml:1.8 phpdoc/en/reference/mssql/functions/mssql-fetch-batch.xml:1.9 --- phpdoc/en/reference/mssql/functions/mssql-fetch-batch.xml:1.8 Tue Nov 6 21:46:00 2007 +++ phpdoc/en/reference/mssql/functions/mssql-fetch-batch.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <refentry xml:id='function.mssql-fetch-batch' xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_fetch_batch</refname> @@ -45,20 +45,32 @@ &reftitle.examples; <para> <example> - <title><function>mssql_fetch_batch</function> Example</title> + <title><function>mssql_fetch_batch</function> example</title> <programlisting role="php"> <![CDATA[ <?php -$resDb = mssql_connect('localhost', 'user', 'name'); -$result = mssql_query('SELECT * FROM MYTABLE', $resDb, 10000); +// Connect to MSSQL +$link = mssql_connect('MANGO\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php', $link); + +// Send a query +$result = mssql_query('SELECT * FROM [php].[dbo].[people]', $link, 100); +$records = 10; + +while(($records - 1) != -1) +{ + while($row = mssql_fetch_assoc($result)) + { + // Do stuff ... + } -$intNumRows = mssql_num_rows($result); + --$records; +} -while ($intNumRows > 0) { - while ($arrRow = mssql_fetch_assoc($result)) { - // Do stuff ... - } - $intNumRows = mssql_fetch_batch($result); +if($batchsize = mssql_fetch_batch($result)) +{ + // $batchsize is the number of records left + // in the result, but not shown above } ?> ]]> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-fetch-field.xml?r1=1.6&r2=1.7&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-fetch-field.xml diff -u phpdoc/en/reference/mssql/functions/mssql-fetch-field.xml:1.6 phpdoc/en/reference/mssql/functions/mssql-fetch-field.xml:1.7 --- phpdoc/en/reference/mssql/functions/mssql-fetch-field.xml:1.6 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-fetch-field.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <refentry xml:id="function.mssql-fetch-field" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_fetch_field</refname> @@ -85,6 +85,62 @@ </itemizedlist> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_fetch_field</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect MSSQL +mssql_connect('MANGO\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php'); + +// Send a select query to MSSQL +$query = mssql_query('SELECT * FROM [php].[dbo].[persons]'); + +// Construct table +echo '<h3>Table structure for \'persons\'</h3>'; +echo '<table border="1">'; + +// Table header +echo '<thead>'; +echo '<tr>'; +echo '<td>Field name</td>'; +echo '<td>Data type</td>'; +echo '<td>Max length</td>'; +echo '</tr>'; +echo '</thead>'; + +// Dump all fields +echo '<tbody>'; + +for($i = 0; $i < mssql_num_fields($query); ++$i) +{ + // Fetch the field information + $field = mssql_fetch_field($query, $i); + + // Print the row + echo '<tr>'; + echo '<td>' . $field->name . '</td>'; + echo '<td>' . strtoupper($field->type) . '</td>'; + echo '<td>' . $field->max_length . '</td>'; + echo '</tr>'; +} + +echo '</tbody>'; +echo '</table>'; + +// Free the query result +mssql_free_result($query); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-fetch-object.xml?r1=1.10&r2=1.11&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-fetch-object.xml diff -u phpdoc/en/reference/mssql/functions/mssql-fetch-object.xml:1.10 phpdoc/en/reference/mssql/functions/mssql-fetch-object.xml:1.11 --- phpdoc/en/reference/mssql/functions/mssql-fetch-object.xml:1.10 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-fetch-object.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.10 $ --> +<!-- $Revision: 1.11 $ --> <refentry xml:id="function.mssql-fetch-object" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_fetch_object</refname> @@ -52,6 +52,46 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_fetch_object</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Send a select query to MSSQL +$query = mssql_query('SELECT [username], [name] FROM [php].[dbo].[userlist]'); + +// Check if there were any records +if(!mssql_num_rows($query)) +{ + echo 'No records found'; +} +else +{ + // Print a nice list of users in the format of + // name (username) + + echo '<ul>'; + + while($row = mssql_fetch_object($query)) + { + echo '<li>' . $row->name . ' (' . $row->username . ')</li>'; + } + + echo '</ul>'; +} + +// Free the query result +mssql_free_result($query); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; &database.field-case; http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-fetch-row.xml?r1=1.10&r2=1.11&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-fetch-row.xml diff -u phpdoc/en/reference/mssql/functions/mssql-fetch-row.xml:1.10 phpdoc/en/reference/mssql/functions/mssql-fetch-row.xml:1.11 --- phpdoc/en/reference/mssql/functions/mssql-fetch-row.xml:1.10 Tue Nov 6 23:17:10 2007 +++ phpdoc/en/reference/mssql/functions/mssql-fetch-row.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.10 $ --> +<!-- $Revision: 1.11 $ --> <refentry xml:id="function.mssql-fetch-row" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_fetch_row</refname> @@ -50,6 +50,45 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_field_row</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect to server and database +$link = mssql_connect('MANGO\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php', $link); + +// Query to execute +$query = mssql_query('SELECT [id], [quote] FROM [quotes] WHERE [id] = \'42\'', $link); + +// Did the query failed? +if(!$query) +{ + die('MSSQL error: ' . mssql_get_last_message()); +} + +// Fetch the row +$row = mssql_fetch_row($query); + +// Print the 'quote' +echo 'Quote #' . $row[0] . ': "' . $row[1] . '"'; +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ +Quote #42: "The answer to everything..." +]]> + </screen> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; &database.fetch-null; http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-field-length.xml?r1=1.8&r2=1.9&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-field-length.xml diff -u phpdoc/en/reference/mssql/functions/mssql-field-length.xml:1.8 phpdoc/en/reference/mssql/functions/mssql-field-length.xml:1.9 --- phpdoc/en/reference/mssql/functions/mssql-field-length.xml:1.8 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-field-length.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <refentry xml:id="function.mssql-field-length" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_field_length</refname> @@ -51,14 +51,48 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_field_length</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect MSSQL +mssql_connect('MANGO\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php'); + +// Send a select query to MSSQL +$query = mssql_query('SELECT [name], [age] FROM [php].[dbo].[persons]'); + +// Print the field type and length +echo 'The field \'age\' has a data length of ' . mssql_field_length($query, 1); + +// Free the query result +mssql_free_result($query); +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ +The field 'age' has a data length of 4 +]]> + </screen> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; <note> - <title>Note to Win32 Users</title> + <title>Note to Windows Users</title> <para> - Due to a limitation in the underlying API used by PHP (MS DbLib C API), - the length of VARCHAR fields is limited to <emphasis>255</emphasis>. If - you need to store more data, use a TEXT field instead. + Due to a limitation in the underlying API used by PHP (MS DBLib C API), + the length of <literal>VARCHAR</literal> fields is limited to + <emphasis>255</emphasis>. If you need to store more data, use a + <literal>TEXT</literal> field instead. </para> </note> </refsect1> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-field-name.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-field-name.xml diff -u phpdoc/en/reference/mssql/functions/mssql-field-name.xml:1.7 phpdoc/en/reference/mssql/functions/mssql-field-name.xml:1.8 --- phpdoc/en/reference/mssql/functions/mssql-field-name.xml:1.7 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-field-name.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <refentry xml:id="function.mssql-field-name" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_field_name</refname> @@ -51,6 +51,43 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_field_name</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Send a select query to MSSQL +$query = mssql_query('SELECT [username], [name], [email] FROM [php].[dbo].[userlist]'); + +echo 'Result set contains the following field(s):', PHP_EOL; + +// Dump all field names in result +for($i = 0; $i < mssql_num_fields($query); ++$i) +{ + echo ' - ' . mssql_field_name($query, $i), PHP_EOL; +} + +// Free the query result +mssql_free_result($query); +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ +Result set contains the following field(s): + - username + - name + - email +]]> + </screen> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-field-seek.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-field-seek.xml diff -u phpdoc/en/reference/mssql/functions/mssql-field-seek.xml:1.7 phpdoc/en/reference/mssql/functions/mssql-field-seek.xml:1.8 --- phpdoc/en/reference/mssql/functions/mssql-field-seek.xml:1.7 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-field-seek.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <refentry xml:id="function.mssql-field-seek" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_field_seek</refname> @@ -52,6 +52,68 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Using <function>mssql_field_type</function> on the example for <function>mssql_fetch_field</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect MSSQL +mssql_connect('MANGO\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php'); + +// Send a select query to MSSQL +$query = mssql_query('SELECT * FROM [php].[dbo].[persons]'); + +// Construct table +echo '<h3>Table structure for \'persons\'</h3>'; +echo '<table border="1">'; + +// Table header +echo '<thead>'; +echo '<tr>'; +echo '<td>Field name</td>'; +echo '<td>Data type</td>'; +echo '<td>Max length</td>'; +echo '</tr>'; +echo '</thead>'; + +// Dump all fields +echo '<tbody>'; + +for($i = 0; $i < mssql_num_fields($query); ++$i) +{ + // Fetch the field information, notice the + // field_offset parameter is not set. See + // the mssql_field_seek call below + $field = mssql_fetch_field($query); + + // Print the row + echo '<tr>'; + echo '<td>' . $field->name . '</td>'; + echo '<td>' . strtoupper($field->type) . '</td>'; + echo '<td>' . $field->max_length . '</td>'; + echo '</tr>'; + + // Move the internal seek pointer to the next + // row in the result set + mssql_field_seek($query, $i + 1); +} + +echo '</tbody>'; +echo '</table>'; + +// Free the query result +mssql_free_result($query); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-field-type.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-field-type.xml diff -u phpdoc/en/reference/mssql/functions/mssql-field-type.xml:1.7 phpdoc/en/reference/mssql/functions/mssql-field-type.xml:1.8 --- phpdoc/en/reference/mssql/functions/mssql-field-type.xml:1.7 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-field-type.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <refentry xml:id="function.mssql-field-type" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_field_type</refname> @@ -51,6 +51,41 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_field_type</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect MSSQL +mssql_connect('MANGO\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php'); + +// Send a select query to MSSQL +$query = mssql_query('SELECT [name] FROM [php].[dbo].[persons]'); + +// Print the field type and length +echo '\'' . mssql_field_name($query, 0) . '\' is a type of ' . + strtoupper(mssql_field_type($query, 0)) . + '(' . mssql_field_length($query, 0) . ')'; + +// Free the query result +mssql_free_result($query); +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ +'name' is a type of CHAR(50) +]]> + </screen> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-free-result.xml?r1=1.6&r2=1.7&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-free-result.xml diff -u phpdoc/en/reference/mssql/functions/mssql-free-result.xml:1.6 phpdoc/en/reference/mssql/functions/mssql-free-result.xml:1.7 --- phpdoc/en/reference/mssql/functions/mssql-free-result.xml:1.6 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-free-result.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <refentry xml:id="function.mssql-free-result" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_free_result</refname> @@ -45,6 +45,38 @@ &return.success; </para> </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_free_result</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Select some data from a table +$query = mssql_query('SELECT * FROM [php].[dbo].[persons]', $link); + +// Handle query result here + +// When we're done we free the result by calling +// mssql_free_result like so: +mssql_free_result($query); +]]> + </programlisting> + </example> + </para> + </refsect1> + + <refsect1 role="seealso"> + &reftitle.seealso; + <para> + <simplelist> + <member><function>mssql_free_statement</function></member> + </simplelist> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-free-statement.xml?r1=1.6&r2=1.7&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-free-statement.xml diff -u phpdoc/en/reference/mssql/functions/mssql-free-statement.xml:1.6 phpdoc/en/reference/mssql/functions/mssql-free-statement.xml:1.7 --- phpdoc/en/reference/mssql/functions/mssql-free-statement.xml:1.6 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-free-statement.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <refentry xml:id="function.mssql-free-statement" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_free_statement</refname> @@ -45,6 +45,29 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_free_statement</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Create a new statement +$stmt = mssql_init('test'); + +// Bind values here and execute statement + +// once we're done, we clear it from the memory +// using mssql_free_statement like so: +mssql_free_statement($stmt); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> @@ -52,6 +75,7 @@ <member><function>mssql_bind</function></member> <member><function>mssql_execute</function></member> <member><function>mssql_init</function></member> + <member><function>mssql_free_result</function></member> </simplelist> </para> </refsect1> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-get-last-message.xml?r1=1.6&r2=1.7&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-get-last-message.xml diff -u phpdoc/en/reference/mssql/functions/mssql-get-last-message.xml:1.6 phpdoc/en/reference/mssql/functions/mssql-get-last-message.xml:1.7 --- phpdoc/en/reference/mssql/functions/mssql-get-last-message.xml:1.6 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-get-last-message.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <refentry xml:id="function.mssql-get-last-message" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_get_last_message</refname> @@ -10,11 +10,68 @@ &reftitle.description; <methodsynopsis> <type>string</type><methodname>mssql_get_last_message</methodname> - <void/> + <void /> </methodsynopsis> + <para> + Gets the last message from the MS-SQL server + </para> + </refsect1> + + <refsect1 role="parameters"> + &reftitle.parameters; + &no.function.parameters; + </refsect1> + + <refsect1 role="returnvalues"> + &reftitle.returnvalues; + <para> + Returns last error message from server, or an empty string if + no error messages are returned from MSSQL. + </para> + </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_get_last_message</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect to MSSQL +mssql_connect('KALLESPC\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php'); - &warn.undocumented.func; +// Make a query that will fail +$query = @mssql_query('SELECT * FROM [php].[dbo].[not-found]'); + +if(!$query) +{ + // The query has failed, print a nice error message + // using mssql_get_last_message() + die('MSSQL error: ' . mssql_get_last_error()); +} +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +MSSQL error: Invalid object name 'php.dbo.not-found'. +]]> + </screen> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> + &reftitle.seealso; + <para> + <simplelist> + <member><function>mssql_min_error_severity</function></member> + <member><function>mssql_min_message_Severity</function></member> + </simplelist> + </para> </refsect1> </refentry> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-guid-string.xml?r1=1.8&r2=1.9&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-guid-string.xml diff -u phpdoc/en/reference/mssql/functions/mssql-guid-string.xml:1.8 phpdoc/en/reference/mssql/functions/mssql-guid-string.xml:1.9 --- phpdoc/en/reference/mssql/functions/mssql-guid-string.xml:1.8 Tue Oct 7 07:55:11 2008 +++ phpdoc/en/reference/mssql/functions/mssql-guid-string.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <refentry xml:id='function.mssql-guid-string' xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_guid_string</refname> @@ -34,7 +34,7 @@ <term><parameter>short_format</parameter></term> <listitem> <para> - ... + Whenever to use short to use short format, defaults to &false; </para> </listitem> </varlistentry> @@ -49,6 +49,32 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_guid_string</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +$binary = '19555081977808608437941339997619274330352755554827939936'; + +var_dump(mssql_guid_string($binary)); +var_dump(mssql_guid_string($binary, true)); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +string(36) "35353931-3035-3138-3937-373830383630" +string(32) "31393535353038313937373830383630" +]]> + </screen> + </example> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-init.xml?r1=1.10&r2=1.11&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-init.xml diff -u phpdoc/en/reference/mssql/functions/mssql-init.xml:1.10 phpdoc/en/reference/mssql/functions/mssql-init.xml:1.11 --- phpdoc/en/reference/mssql/functions/mssql-init.xml:1.10 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-init.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.10 $ --> +<!-- $Revision: 1.11 $ --> <refentry xml:id='function.mssql-init' xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_init</refname> @@ -53,6 +53,42 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_init</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect to MSSQL +mssql_connect('KALLESPC\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php'); + +// Create a new statement +$stmt = mssql_init('StatementTest', $link); + +// Bind values here + +// Once values are binded we execute our statement +// using mssql_execute: +mssql_execute($stmt); + +// And we can free it like so: +mssql_free_statement($stmt); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +MSSQL error: Invalid object name 'php.dbo.not-found'. +]]> + </screen> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-min-error-severity.xml?r1=1.6&r2=1.7&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-min-error-severity.xml diff -u phpdoc/en/reference/mssql/functions/mssql-min-error-severity.xml:1.6 phpdoc/en/reference/mssql/functions/mssql-min-error-severity.xml:1.7 --- phpdoc/en/reference/mssql/functions/mssql-min-error-severity.xml:1.6 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-min-error-severity.xml Wed Oct 8 18:29:23 2008 @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <refentry xml:id="function.mssql-min-error-severity" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_min_error_severity</refname> - <refpurpose>Sets the lower error severity</refpurpose> + <refpurpose>Sets the minimum error severity</refpurpose> </refnamediv> <refsect1 role="description"> @@ -12,9 +12,9 @@ <type>void</type><methodname>mssql_min_error_severity</methodname> <methodparam><type>int</type><parameter>severity</parameter></methodparam> </methodsynopsis> - - &warn.undocumented.func; - + <para> + Sets the minimum error severity. + </para> </refsect1> <refsect1 role="parameters"> @@ -25,6 +25,7 @@ <term><parameter>severity</parameter></term> <listitem> <para> + The new error severity. </para> </listitem> </varlistentry> @@ -38,6 +39,40 @@ &return.void; </para> </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_min_message_severity</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect to MSSQL +mssql_connect('KALLESPC\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php'); + +// Set the minimum error severity to not include SQL +// syntax errors by setting it to something greater than +// or equal to 1. +mssql_min_error_severity(1); + +// Send a query we know that will cause an syntax error, in +// this case we use the MySQL quote signs instead of wrapping +// square brackets around the field and table names. +$query = mssql_query('SELECT `syntax`, `error` FROM `MSSQL`'); + +if(!$query) +{ + // Custom error handler ... +} +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-min-message-severity.xml?r1=1.6&r2=1.7&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-min-message-severity.xml diff -u phpdoc/en/reference/mssql/functions/mssql-min-message-severity.xml:1.6 phpdoc/en/reference/mssql/functions/mssql-min-message-severity.xml:1.7 --- phpdoc/en/reference/mssql/functions/mssql-min-message-severity.xml:1.6 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-min-message-severity.xml Wed Oct 8 18:29:23 2008 @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <refentry xml:id="function.mssql-min-message-severity" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_min_message_severity</refname> - <refpurpose>Sets the lower message severity</refpurpose> + <refpurpose>Sets the minimum message severity</refpurpose> </refnamediv> <refsect1 role="description"> @@ -12,9 +12,9 @@ <type>void</type><methodname>mssql_min_message_severity</methodname> <methodparam><type>int</type><parameter>severity</parameter></methodparam> </methodsynopsis> - - &warn.undocumented.func; - + <para> + Sets the minimum message severity. + </para> </refsect1> <refsect1 role="parameters"> @@ -25,6 +25,7 @@ <term><parameter>severity</parameter></term> <listitem> <para> + The new message severity. </para> </listitem> </varlistentry> @@ -38,6 +39,38 @@ &return.void; </para> </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_min_message_severity</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect to MSSQL +mssql_connect('KALLESPC\SQLEXPRESS', 'sa', 'phpfi'); + +// Set the minimum message severity to 17, this +// will not show any messages issued by the underlaying +// API when we select a non-existent database below +mssql_min_message_severity(17); + +// Select a non-existent database +mssql_select_db('THIS_DATABASE_DOES_NOT_EXISTS'); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +mssql_select_db(): Unable to select database: THIS_DATABASE_DOES_NOT_EXISTS +]]> + </screen> + </example> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-next-result.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-next-result.xml diff -u phpdoc/en/reference/mssql/functions/mssql-next-result.xml:1.7 phpdoc/en/reference/mssql/functions/mssql-next-result.xml:1.8 --- phpdoc/en/reference/mssql/functions/mssql-next-result.xml:1.7 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-next-result.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <refentry xml:id="function.mssql-next-result" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_next_result</refname> @@ -55,15 +55,26 @@ <programlisting role="php"> <![CDATA[ <?php -$link = mssql_connect("localhost", "userid", "secret"); -mssql_select_db("MyDB", $link); -$sql = "Select * from table1 select * from table2"; -$rs = mssql_query($sql, $link); -do { - while ($row = mssql_fetch_row($rs)) { - } -} while (mssql_next_result($rs)); -mssql_free_result($rs); +// Connect MSSQL +$link = mssql_connect('MANGO\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php', $link); + +// Send a query to MSSQL +$sql = 'SELECT [name], [age] FROM [php].[dbo].[persons]'; +$query = mssql_query($sql, $link); + +// Iterate through returned records +do +{ + while($row = mssql_fetch_row($query)) + { + // Handle record ... + } +} +while(mssql_next_result($query)); + +// Clean up +mssql_free_result($query); mssql_close($link); ?> ]]> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-num-fields.xml?r1=1.8&r2=1.9&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-num-fields.xml diff -u phpdoc/en/reference/mssql/functions/mssql-num-fields.xml:1.8 phpdoc/en/reference/mssql/functions/mssql-num-fields.xml:1.9 --- phpdoc/en/reference/mssql/functions/mssql-num-fields.xml:1.8 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-num-fields.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <refentry xml:id="function.mssql-num-fields" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_num_fields</refname> @@ -42,6 +42,72 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_num_fields</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect to MSSQL +$link = mssql_connect('KALLESPC\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php', $link); + +// Select some data from our database +$data = mssql_query('SELECT [name], [age] FROM [php].[dbo].[persons]'); + +// Construct a table +echo '<table border="1">'; + +$header = false; + +// Iterate through returned results +while($row = mssql_fetch_array($data)) +{ + // Build the table header + if(!$header) + { + echo '<thead>'; + echo '<tr>'; + + for($i = 1; ($i + 1) <= mssql_num_fields($data); ++$i) + { + echo '<td>' . ucfirst($row[$i]) . '</td>'; + } + + echo '</tr>'; + echo '</thead>'; + echo '<tbody>'; + + $header = true; + } + + // Build the row + echo '<tr>'; + + foreach($row as $value) + { + echo '<td>' . $value . '</td>'; + } + + echo '</tr>'; +} + +// Close table +echo '</tbody>'; +echo '</table>'; + +// Clean up +mssql_free_result($data); +mssql_close($link); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-pconnect.xml?r1=1.8&r2=1.9&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-pconnect.xml diff -u phpdoc/en/reference/mssql/functions/mssql-pconnect.xml:1.8 phpdoc/en/reference/mssql/functions/mssql-pconnect.xml:1.9 --- phpdoc/en/reference/mssql/functions/mssql-pconnect.xml:1.8 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-pconnect.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <refentry xml:id="function.mssql-pconnect" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_pconnect</refname> @@ -90,6 +90,29 @@ &false; on error. </para> </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_pconnect</function> using the <parameter>new_link</parameter> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Connect to the database server +$link1 = mssql_pconnect('MANGO\SQLEXPRESS', 'sa', 'phpfi'); +mssql_select_db('php', $link1); + +// Create a new link +$link2 = mssql_pconnect('MANGO\SQLEXPRESS', 'sa', 'phpfi', true); +mssql_select_db('random', $link2); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-query.xml?r1=1.12&r2=1.13&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-query.xml diff -u phpdoc/en/reference/mssql/functions/mssql-query.xml:1.12 phpdoc/en/reference/mssql/functions/mssql-query.xml:1.13 --- phpdoc/en/reference/mssql/functions/mssql-query.xml:1.12 Tue Oct 7 02:34:38 2008 +++ phpdoc/en/reference/mssql/functions/mssql-query.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.12 $ --> +<!-- $Revision: 1.13 $ --> <refentry xml:id="function.mssql-query" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_query</refname> @@ -77,8 +77,12 @@ <![CDATA[ <?php // Connect to MSSQL -$link = mssql_connect('KALLESPC\SQLEXPRESS', 'sa', 'phpfi') or die('Unable to connect MSSQL'); -mssql_select_db('php', $link) or die('Unable to select database'); +$link = mssql_connect('KALLESPC\SQLEXPRESS', 'sa', 'phpfi'); + +if(!$link || !mssql_select_db('php', $link)) +{ + die('Unable to connect or select database!'); +} // Do a simple query, select the version of // MSSQL and print it. http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-result.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-result.xml diff -u phpdoc/en/reference/mssql/functions/mssql-result.xml:1.7 phpdoc/en/reference/mssql/functions/mssql-result.xml:1.8 --- phpdoc/en/reference/mssql/functions/mssql-result.xml:1.7 Wed Jun 20 22:24:59 2007 +++ phpdoc/en/reference/mssql/functions/mssql-result.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <refentry xml:id="function.mssql-result" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_result</refname> @@ -71,6 +71,77 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mssql_result</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Send a select query to MSSQL +$query = mssql_query('SELECT [username] FROM [php].[dbo].[userlist]'); + +// Check if there were any records +if(!mssql_num_rows($query)) +{ + echo 'No records found'; +} +else +{ + for($i = 0; $i < mssql_num_rows($query); ++$i) + { + echo mssql_result($query, $i, 'username'), PHP_EOL; + } +} + +// Free the query result +mssql_free_result($query); +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ +Kalle +Felipe +Emil +Ross +]]> + </screen> + </example> + </para> + <para> + <example> + <title>Faster alternative to above example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Send a select query to MSSQL +$query = mssql_query('SELECT [username] FROM [php].[dbo].[userlist]'); + +// Check if there were any records +if(!mssql_num_rows($query)) +{ + echo 'No records found'; +} +else +{ + while($row = mssql_fetch_array($query)) + { + echo $row['username'], PHP_EOL; + } +} + +// Free the query result +mssql_free_result($query); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; <note> @@ -90,6 +161,7 @@ <simplelist> <member><function>mssql_fetch_row</function></member> <member><function>mssql_fetch_array</function></member> + <member><function>mssql_fetch_assoc</function></member> <member><function>mssql_fetch_object</function></member> </simplelist> </para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/mssql/functions/mssql-rows-affected.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/mssql/functions/mssql-rows-affected.xml diff -u phpdoc/en/reference/mssql/functions/mssql-rows-affected.xml:1.7 phpdoc/en/reference/mssql/functions/mssql-rows-affected.xml:1.8 --- phpdoc/en/reference/mssql/functions/mssql-rows-affected.xml:1.7 Tue Oct 7 02:34:38 2008 +++ phpdoc/en/reference/mssql/functions/mssql-rows-affected.xml Wed Oct 8 18:29:23 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <refentry xml:id='function.mssql-rows-affected' xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mssql_rows_affected</refname> @@ -49,7 +49,7 @@ <title><function>mssql_rows_affected</function> example</title> <programlisting role="php"> <![CDATA[ -<?php´ +<?php // Delete all rows in a table mssql_query('TRUNCATE TABLE [php].[dbo].[persons]');