0
I am new to SQL server and I need to create an SP that does the processing of certain tables and save changes and after giving me the result of these changes as a table-value Function for PHP. tried that :
create procedure auto_fill_teste
as
begin
DECLARE @temp_table table(qtd int);
insert into @temp_table
SELECT COUNT(*) FROM sysobjects;
insert into @temp_table
SELECT COUNT(*) FROM sysindexes;
SELECT * FROM @temp_table;
end
and in php I have the following codes
<?
class MsSQLConnection {
protected $MSconn;
protected $serverName = 'localhost';
protected $connectionOptions = array("Database" => "master", "UID" => "as", "PWD" => "123456");
public $query;
function conecta_MSSQL() {
$this->MSconn = sqlsrv_connect($this->serverName, $this->connectionOptions);
if (!$this->MSconn) {
var_dump(sqlsrv_errors());
die;
}
}
function executar($sql,$params = array(),$options = array("Scrollable" => "buffered")) {
if (!$this->MSconn) {
$this->conecta_MSSQL();
}
$this->query=sqlsrv_prepare($this->MSconn, $sql, $params, $options);
sqlsrv_execute( $this->query );
}
function arrayx($a = null) {
if (empty($a))
$a = $this->query;
return sqlsrv_fetch_array($a, SQLSRV_FETCH_BOTH);
}
}
$conexao = new MsSQLConnection();
$conexao->conecta_MSSQL();
$conexao->executar("Exec dbo.auto_fill_teste");
while($row = $conexao->arrayx(NULL)){
print_r("$row <br>");
}
?>
Yet nothing is returned; already if I run the command in manager studio it returns the resultset from temp_table as expected.
In management studio it returns what? 3 selects? What changes from normal queries to SP is that you need to handle multiple returns.
– rray
returns only 1 resultset with two lines
– HagaHood
something like that https://1drv.ms/f/s! Aphqippehrqggsy3hecz7jq0bzv7
– HagaHood