Skip to content

Instantly share code, notes, and snippets.

@statgeek
Forked from FriedEgg/SasAdoDBExample.ps1
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save statgeek/c649ff0e18cab8d403ed to your computer and use it in GitHub Desktop.
Save statgeek/c649ff0e18cab8d403ed to your computer and use it in GitHub Desktop.
<?php
$conn = new COM("ADODB.Connection");
$conn->Open('Provider=sas.IOMProvider.9.3;User ID=user;Password=pass;Data Source="";SAS Machine DNS Name=my.server.com;SAS Port=8591;SAS Protocol=2');
$cmd = new COM("ADODB.Command");
$cmd->ActiveConnection = $conn;
$cmd->CommandType = 1;
$cmd->CommandText = 'libname foo "/my/path"';
$cmd->Execute();
$recordSet = $conn->Execute("select * from foo.my_table");
$recordSet->MoveFirst();
do {
for ($i=0; $i < $recordSet->Fields->Count; $i++) {
echo $recordSet->Fields->Item($i)->Name . ": " . $recordSet->Fields->Item($i)->Value . "\n";
}
echo "\n\n";
$recordSet->MoveNext();
} while ($recordSet->EOF == FALSE);
$recordSet->Close();
$conn->Close();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment