{"action":"closed","issue":{"url":"https://api.github.com/repos/Azure/msphpsql/issues/48","labels_url":"https://api.github.com/repos/Azure/msphpsql/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/Azure/msphpsql/issues/48/comments","events_url":"https://api.github.com/repos/Azure/msphpsql/issues/48/events","html_url":"https://github.com/Azure/msphpsql/issues/48","id":72660960,"number":48,"title":"Impossible to use local temporary tables","user":{"login":"david-garcia-garcia","id":9599352,"avatar_url":"https://avatars.githubusercontent.com/u/9599352?v=3","gravatar_id":"","url":"https://api.github.com/users/david-garcia-garcia","html_url":"https://github.com/david-garcia-garcia","followers_url":"https://api.github.com/users/david-garcia-garcia/followers","following_url":"https://api.github.com/users/david-garcia-garcia/following{/other_user}","gists_url":"https://api.github.com/users/david-garcia-garcia/gists{/gist_id}","starred_url":"https://api.github.com/users/david-garcia-garcia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/david-garcia-garcia/subscriptions","organizations_url":"https://api.github.com/users/david-garcia-garcia/orgs","repos_url":"https://api.github.com/users/david-garcia-garcia/repos","events_url":"https://api.github.com/users/david-garcia-garcia/events{/privacy}","received_events_url":"https://api.github.com/users/david-garcia-garcia/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-02T15:30:01Z","updated_at":"2015-05-04T12:11:05Z","closed_at":"2015-05-04T12:11:05Z","body":"Using the PDO driver it is imposible to use local temporary tables (global temporary tables work).\r\n\r\nSee sample script. The first part of the script (local) fails, the scond (global) works.\r\n\r\nI guess this is probably by design because I read the PDO uses internally connection pooling instead of persistent connections, effectively refreshing the connection scope on every statement.\r\n\r\n<?php\r\n\r\n// Connection to use throughout the test.\r\n$cnn = new PDO('sqlsrv:Server=localhost;Database=database', 'sa' ,'pwd');\r\n$cnn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);\r\n$cnn->transactionSupport = TRUE;\r\n$cnn->transactionalDDLSupport = TRUE;\r\n\r\n// Clear a local temporary table.\r\n$cnn->query('CREATE TABLE #TEMP1  (COL1 int)');\r\n$cnn->query('INSERT INTO #TEMP1 VALUES(1)');\r\n$cnn->query('INSERT INTO #TEMP1 VALUES(2)');\r\n$cnn->query('INSERT INTO #TEMP1 VALUES(3)');\r\n$q = $cnn->query('SELECT COUNT(*) FROM #TEMP1');\r\n$q->execute();\r\n$r = $q->fetchAll();\r\n\r\n// Create a global temporary table.\r\n$cnn->query('CREATE TABLE ##TEMP2  (COL1 int)');\r\n$cnn->query('INSERT INTO ##TEMP2 VALUES(1)');\r\n$cnn->query('INSERT INTO ##TEMP2 VALUES(2)');\r\n$cnn->query('INSERT INTO ##TEMP2 VALUES(3)');\r\n$q = $cnn->query('SELECT COUNT(*) FROM ##TEMP2');\r\n$q->execute();\r\n$r = $q->fetchAll();"}}