function ReaPaises($nIdPais) { $sp = mssql_init('REAPAISES'); //SP //Parámetros SP mssql_bind($sp, '@nIdPais', $nIdPais, SQLINT4); $resultado = mssql_execute($sp); //Ejecución SP $i = 0; while ($row = mssql_fetch_array($resultado)) { $html[$i]['id_pais'] = $row[0]; $html[$i]['nombre'] = $row[1]; $i++; } return $html; mssql_free_result($resultado); //Liberación del recurso mssql_free_statement($sp); //Liberación del recurso }
<?php set_time_limit(10000); require "../config/main.php"; $mdir = opendir("updates"); while ($arr = readdir($mdir)) { if (strstr(strtolower($arr), ".sql")) { $dbms_schema = 'updates/' . $arr; $sql_query = file_get_contents($dbms_schema); mssql_execute($sql_query, true); mssql_free_statement($stmt); } } echo "Se han actualizado " . $upt * 1 . " consultas en la base de datos"; function remove_comments(&$output) { $lines = explode("\n", $output); $output = ""; // try to keep mem. use down $linecount = count($lines); $in_comment = false; for ($i = 0; $i < $linecount; $i++) { if (preg_match("/^\\/\\*/", preg_quote($lines[$i]))) { $in_comment = true; } if (!$in_comment) { $output .= $lines[$i] . "\n"; } if (preg_match("/\\*\\/\$/", preg_quote($lines[$i]))) { $in_comment = false; }
// Test 4, SQLVARCHAR output // $proc = mssql_init("sp_php_test4", $conn); $test1 = ""; $retval = 0; // Bind the parameters mssql_bind($proc, "@test1", &$test1, SQLVARCHAR, TRUE, FALSE, 13); // Bind the return value mssql_bind($proc, "RETVAL", &$retval, SQLINT4); $result = mssql_execute($proc); if (!$result) { echo "Last message from SQL : " . mssql_get_last_message() . "\n"; $err = TRUE; mssql_free_statement($proc); } else { mssql_free_statement($proc); echo "test1 = >{$test1}<\n"; if ($test1 != 'xyz45678') { echo "Expected test1 >xyz45678<\n"; $err = TRUE; } echo "retval = {$retval}\n"; if ($retval != 4) { echo "Expected retval 4\n"; $err = TRUE; } } # cleanup mssql_query("drop proc sp_php_test4"); mssql_query("drop proc sp_php_test3"); mssql_query("drop proc sp_php_test2");
/** * @see CallableStatement::close() */ function close() { @mssql_free_statement($this->stmt); $this->rsFetchCount = 0; }
function _mssql_assign_grants($db, $the_host, $db_name, $login, $passwd) { // $stmt = $db->db->PrepareSP('SP_GRANTDBACCESS'); // $db->db->InParameter($stmt,$login,'loginame'); // $result=$db->db->Execute($stmt); // mssql_free_statement($stmt[1]); // $db_role = 'db_owner'; $stmt = $db->db->PrepareSP('SP_ADDUSER'); $db->db->InParameter($stmt, $login, 'loginame'); $db->db->InParameter($stmt, $login, 'name_in_db'); $db->db->InParameter($stmt, $db_role, 'grpname'); $result = $db->db->Execute($stmt); mssql_free_statement($stmt[1]); $op->status_ok = true; $op->msg = 'ok - grant assignment'; return $op; }
function __destruct() { if ($this->Handle) { mssql_free_statement($this->Handle); } }
/** * Closes the cursor, allowing the statement to be executed again. * * @return bool */ public function closeCursor() { if (!$this->_stmt) { return false; } mssql_free_statement($this->_stmt); $this->_stmt = false; return true; }
/** * method to deal with the execution of MS SQL stored proceedured * @param $string $procName The name of the proceedure to execute * @param array $paramArray An array containing entries for each paramneeded but the stored proceedure see the exampel in the code below */ function exeStoredProc($procName, $paramArray = false, $skip_results = false) { // example param array // $paramArray = array ('LocationName' => array ('VALUE' => 'the clients host name', 'TYPE' => 'SQLVARCHAR', 'ISOUTPUT' => 'false', 'IS_NULL' =>'false', 'MAXLEN' => '255' ) ); // each element in the paramArray must idetify a paramiter required by the stored proceedure and can tain an array of settings from that paramiter // see http://php.net/manual/en/function.mssql-bind.php for information on the values for these paramiters // initiate the stored proceedure $stmt = mssql_init($procName, $this->linkid); // bind paramiters if ($paramArray) { foreach ($paramArray as $paramName => $values) { mssql_bind($stmt, $paramName, $values['VALUE'], $values['TYPE'], $values['ISOUTPUT'], $values['IS_NULL'], $values['MAXLEN']); } } // execute the stored proceedure $results = mssql_execute($stmt); // if we do not get anu results return false if (!$results) { return false; // if we get results then put them in to an array and return it } else { // define the array to return $resultArray = array(); // loop throught he result set and place each result to the resultArray do { while ($row = mssql_fetch_row($stmt)) { $resultArray[] = $row; } } while (mssql_next_result($stmt)); // clean up the statment ready for the next useexec SELLING_GetLocation @LocationName='it-leigh.skilouise.com' mssql_free_statement($stmt); //returnt he result array return $resultArray; } }