You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The PDO_SQLSRV driver lets you create scrollable result sets with one of several cursors.
19
-
20
-
For information on how to specify a cursor using the PDO_SQLSRV driver, and for code samples, see [PDO::prepare](../../connect/php/pdo-prepare.md).
21
-
22
-
## PDO_SQLSRV and Server-Side Cursors
23
-
Prior to version 3.0 of the [!INCLUDE[ssDriverPHP](../../includes/ssdriverphp_md.md)], the PDO_SQLSRV driver allowed you to create a result set with a server-side forward-only or static cursor. Beginning in version 3.0 of the [!INCLUDE[ssDriverPHP](../../includes/ssdriverphp_md.md)], keyset and dynamic cursors are also available.
24
-
25
-
You can indicate the type of server-side cursor by using PDO::prepare or PDOStatement::setAttribute to select either cursor type:
26
-
27
-
- PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY
28
-
29
-
- PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL
30
-
31
-
You can request a keyset or dynamic cursor by specifying PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL and then pass the appropriate value to PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE. Possible values that you can pass to PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE are:
32
-
33
-
- PDO::SQLSRV_CURSOR_BUFFERED
34
-
35
-
- PDO::SQLSRV_CURSOR_DYNAMIC
36
-
37
-
- PDO::SQLSRV_CURSOR_KEYSET_DRIVEN
38
-
39
-
- PDO::SQLSRV_CURSOR_STATIC
40
-
41
-
## PDO_SQLSRV and Client-Side Cursors
42
-
Client-side cursors were added in version 3.0 of the [!INCLUDE[ssDriverPHP](../../includes/ssdriverphp_md.md)] that allows you to cache an entire result set in memory. One advantage is that row count is available after a query is executed.
43
-
44
-
Client-side cursors should be used for small- to medium-sized result sets. Large result sets should use server-side cursors.
45
-
46
-
A query will return false if the buffer is not large enough to hold an entire result set when using a client-side cursor. You can increase the buffer size up to the PHP memory limit.
47
-
48
-
You can configure the size of the buffer that holds the result set with the PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE attribute of [PDO::setAttribute](../../connect/php/pdo-setattribute.md) or [PDOStatement::setAttribute](../../connect/php/pdostatement-setattribute.md). You can also set the maximum buffer size in the php.ini file with pdo_sqlsrv.client_buffer_max_kb_size (for example, pdo_sqlsrv.client_buffer_max_kb_size = 1024).
49
-
50
-
You indicate that you want a client-side cursor by using PDO::prepare or PDOStatement::setAttribute and select the PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL cursor type. You then specify PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED.
[Specifying a Cursor Type and Selecting Rows](../../connect/php/specifying-a-cursor-type-and-selecting-rows.md)
92
-
18
+
The PDO_SQLSRV driver lets you create scrollable result sets with one of several cursors.
19
+
20
+
For information on how to specify a cursor using the PDO_SQLSRV driver, and for code samples, see [PDO::prepare](../../connect/php/pdo-prepare.md).
21
+
22
+
## PDO_SQLSRV and Server-Side Cursors
23
+
Prior to version 3.0 of the [!INCLUDE[ssDriverPHP](../../includes/ssdriverphp_md.md)], the PDO_SQLSRV driver allowed you to create a result set with a server-side forward-only or static cursor. Beginning in version 3.0 of the [!INCLUDE[ssDriverPHP](../../includes/ssdriverphp_md.md)], keyset and dynamic cursors are also available.
24
+
25
+
You can indicate the type of server-side cursor by using [PDO::prepare](../../connect/php/pdo-prepare.md)to select one of the following cursor types:
26
+
27
+
-`PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY`
28
+
29
+
-`PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL`
30
+
31
+
You can request a dynamic, static, or keyset cursor by specifying `PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL` and then passing the appropriate value to `PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE`. Possible values that you can pass to `PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE` for server-side cursors are:
32
+
33
+
-`PDO::SQLSRV_CURSOR_DYNAMIC`
34
+
35
+
-`PDO::SQLSRV_CURSOR_STATIC`
36
+
37
+
-`PDO::SQLSRV_CURSOR_KEYSET_DRIVEN`
38
+
39
+
## PDO_SQLSRV and Client-Side Cursors
40
+
Client-side cursors were added in version 3.0 of the [!INCLUDE[ssDriverPHP](../../includes/ssdriverphp_md.md)] and allow you to cache an entire result set in memory. One advantage is that the row count is available after a query is executed.
41
+
42
+
Client-side cursors should be used for small- to medium-sized result sets. Large result sets should use server-side cursors.
43
+
44
+
A query will return false if the buffer is not large enough to hold an entire result set when using a client-side cursor. You can increase the buffer size up to the PHP memory limit.
45
+
46
+
You can configure the size of the buffer that holds the result set with the `PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE` attribute of [PDO::setAttribute](../../connect/php/pdo-setattribute.md) or [PDOStatement::setAttribute](../../connect/php/pdostatement-setattribute.md). You can also set the maximum buffer size in the php.ini file with pdo_sqlsrv.client_buffer_max_kb_size (for example, pdo_sqlsrv.client_buffer_max_kb_size = 1024).
47
+
48
+
You can request a client-side cursor by using [PDO::prepare](../../connect/php/pdo-prepare.md), specifying the `PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL` cursor type, and then specifying `PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED`.
49
+
50
+
## Example
51
+
The following example shows how to specify a buffered cursor.
0 commit comments