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 }
function Parameter(&$stmt, &$var, $name, $isOutput = false, $maxLen = 4000, $type = false) { if (!$this->_has_mssql_init) { ADOConnection::outp("Parameter: mssql_bind only available since PHP 4.1.0"); return $sql; } $isNull = is_null($var); // php 4.0.4 and above... if ($type === false) { switch (gettype($var)) { default: case 'string': $type = SQLCHAR; break; case 'double': $type = SQLFLT8; break; case 'integer': $type = SQLINT4; break; case 'boolean': $type = SQLINT1; break; # SQLBIT not supported in 4.1.0 } } if ($this->debug) { $prefix = $isOutput ? 'Out' : 'In'; $ztype = empty($type) ? 'false' : $type; ADOConnection::outp("{$prefix}Parameter(\$stmt, \$php_var='{$var}', \$name='{$name}', \$maxLen={$maxLen}, \$type={$ztype});"); } /* See http://phplens.com/lens/lensforum/msgs.php?id=7231 RETVAL is HARD CODED into php_mssql extension: The return value (a long integer value) is treated like a special OUTPUT parameter, called "RETVAL" (without the @). See the example at mssql_execute to see how it works. - type: one of this new supported PHP constants. SQLTEXT, SQLVARCHAR,SQLCHAR, SQLINT1,SQLINT2, SQLINT4, SQLBIT,SQLFLT8 */ if ($name !== 'RETVAL') { $name = '@' . $name; } return mssql_bind($stmt[1], $name, $var, $type, $isOutput, $isNull, $maxLen); }
} echo "retval = {$retval}\n"; if ($retval != 3) { echo "Expected retval 3\n"; $err = TRUE; } } // 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";
function Parameter(&$stmt, &$var, $name, $isOutput = false, $maxLen = 4000, $type = false) { if (!$this->_has_mssql_init) { ADOConnection::outp("Parameter: mssql_bind only available since PHP 4.1.0"); return $sql; } $isNull = is_null($var); // php 4.0.4 and above... if ($type === false) { switch (gettype($var)) { default: case 'string': $type = SQLCHAR; break; case 'double': $type = SQLFLT8; break; case 'integer': $type = SQLINT4; break; case 'boolean': $type = SQLINT1; break; # SQLBIT not supported in 4.1.0 } } if ($this->debug) { ADOConnection::outp("Parameter(\$stmt, \$php_var='{$var}', \$name='{$name}'); (type={$type})"); } return mssql_bind($stmt[1], '@' . $name, $var, $type, $isOutput, $isNull, $maxLen); }
/** * @see CallableStatement::setTimestamp() */ function setTimestamp($paramIndex, $value, $out = false) { if ($out) { $this->boundOutVars[$paramIndex] =& $value; } // reference means that changes to value, will be reflected if ($value === null) { $this->setNull($paramIndex); } else { if (is_numeric($value)) { $value = date('Y-m-d H:i:s', $value); } mssql_bind($this->stmt, $paramIndex, $value, SQLVARCHAR, $out); } }
function BindByReference($ParameterName, &$Variable, $Type = null, $Length = null) { if ($Type === null) { $Type = "VARCHAR"; } if (is_string($Type)) { $Type = strtoupper($Type); if (!array_key_exists($Type, DBAL_MSSQL_StoredProcedure::$Types)) { throw new Exception("Unknown SQL Server type in list."); } $Type = DBAL_MSSQL_StoredProcedure::$Types[$Type]; } if ($Length) { mssql_bind($this->Handle, $ParameterName, $Variable, $Type, false, $Variable == null, $Length); } else { mssql_bind($this->Handle, $ParameterName, $Variable, $Type, false, $Variable == null); } }
$community = $_POST['community']; $school = $_POST['school']; /* echo "<p>LocID:</p>"; echo $LocID; echo "<p>SiteKey: </p>"; echo $SiteKey; echo "<p>Copy Type Key</p>"; echo $CopyTypeKey; echo "<p>Short:</p>"; echo $short; echo "<p>Location: </p>"; echo $location; echo "<p>about: </p>"; echo $about; echo "<p>community: </p>"; echo $community; echo "<p>school; </p>"; echo $school; */ mssql_bind($Copyproc, '@LocID', $LocID, SQLINT4, false, false, 10); mssql_bind($Copyproc, '@SiteKey', $SiteKey, SQLINT4, false, false, 1); mssql_bind($Copyproc, '@CopyTypeKey', $CopyTypeKey, SQLINT1, false, false, 1); mssql_bind($Copyproc, '@short', $short, SQLTEXT, false, false, 255); mssql_bind($Copyproc, '@location', $location, SQLTEXT, false, false, 255); mssql_bind($Copyproc, '@about', $about, SQLTEXT, false, false, 255); mssql_bind($Copyproc, '@community', $community, SQLTEXT, false, false, 255); mssql_bind($Copyproc, '@school', $school, SQLTEXT, false, false, 255); mssql_execute($Copyproc); mssql_close(); header("Location: http://toolkit.empire-dev.com/copy.php");
public function Execute(){ if ($this->commandtype == self::C_CMDTEXT) { //Returns a TRecordset object return $this->activeconnection->Execute($this->commandtext); } elseif ($this->commandtype == self::C_CMDSTOREDPROC) { try { //Call Stored Procedure $this->stmt = @mssql_init($this->commandtext, $this->activeconnection->connection_id); //If can't call Stored Procedure if (!$this->stmt) throw new TException(TCustomMessage::GetMessage(5009, $this->commandtext), 5009); //Add the SQL Parameters to the Stored Procedure if it exists for ($x = 0; $x < $this->parameters->count; $x ++) { //Add SQL Parameter $k = @mssql_bind($this->stmt, $this->parameters->parameter($x)->name, &$this->parameters->parameter($x)->value, $this->parameters->parameter($x)->type, $this->parameters->parameter($x)->is_output, $this->parameters->parameter($x)->is_null, $this->parameters->parameter($x)->maxlen); //If can't add SQL Parameter if (!$k) throw new TException(TCustomMessage::GetMessage(5010, $this->commandtext), 5010); } //Execute Stored Procedure $this->result_id = @mssql_execute($this->stmt); //If can't execute Stored Procedure if (!$this->result_id) throw new TException(TCustomMessage::GetMessage(5011, $this->commandtext), 5011); //Returns a TRecordset object return new TRecordset($this->result_id, $this->activeconnection); } catch (TException $e) { //Set the exception $this->activeconnection->err = $e; //TCommand::Execute() failed, returns false return false; } } }
<?php //Connect to Poolparty include_once '../includes/connection.php'; // Create a new statement $stmt = mssql_init('Classstartproc'); // Some data strings $ClassStartSchedulesID = $_POST['ClassStartSchedulesID']; $LocID = $_POST['LocID']; $ScheduleID = $_POST['ScheduleID']; // Bind values mssql_bind($stmt, '@ClassStartSchedulesID', $ClassStartSchedulesID, SQLINT1, false, false, 20); mssql_bind($stmt, '@LocID', $LocID, SQLINT1, false, false, 20); mssql_bind($stmt, '@ScheduleID', $ScheduleID, SQLTEXT, false, false, 50); // Execute the statement $result = mssql_execute($stmt); echo $result; // // And we can free it like so: // mssql_free_statement($stmt); // // echo $stmt; header("Location: http://54.209.36.245/programs.php"); exit;
<?php //Connect to Poolparty include_once '../includes/connection.php'; // Create a new statement $stmt = mssql_init('updatecatalog'); // Some data strings $SchoolInfoKey = $_POST['SchoolInfoKey']; $LocID = $_POST['LocID']; $CatalogURL = $_POST['CatalogURL']; // Bind values mssql_bind($stmt, '@SchoolInfoKey', $SchoolInfoKey, SQLINT4, false, false, 20); mssql_bind($stmt, '@LocID', $LocID, SQLINT4, false, false, 20); mssql_bind($stmt, '@CatalogURL', $CatalogURL, SQLTEXT, false, false, 500); // Execute the statement $result = mssql_execute($stmt); echo $result; // // And we can free it like so: // mssql_free_statement($stmt); // // echo $stmt; header("Location: http://54.209.36.245/programs.php"); exit;
/** * Binds a parameter to the specified variable name. * * @param mixed $parameter Name the parameter, either integer or string. * @param mixed $variable Reference to PHP variable containing the value. * @param mixed $type OPTIONAL Datatype of SQL parameter. * @param mixed $length OPTIONAL Length of SQL parameter. * @param mixed $options OPTIONAL Other options. * @return bool * @throws Zend_Db_Statement_Exception */ protected function _bindParam($parameter, &$variable, $type = null, $length = null, $options = null) { $is_output = $is_null = null; if (isset($options['is_null'])) { $is_null = $options['is_null']; } if (isset($options['is_output'])) { $is_output = $options['is_output']; } if ($length === NULL) { $length = -1; } if ($is_output === NULL) { $is_output = false; } if ($is_null === NULL) { $is_null = false; } try { if ($type === null) { if (is_bool($variable)) { $type = SQLINT1; } elseif ($variable === null) { $type = SQLCHAR; } elseif (is_integer($variable)) { $type = SQLINT4; } elseif (mb_strlen($variable) > 255) { $type = SQLTEXT; } else { $type = SQLVARCHAR; } } return mssql_bind($this->_stmt, $parameter, $variable, $type, $is_output, $is_null, $length); } catch (Exception $e) { throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e); } }
function func_mssql_query($query, $sess, &$bin, &$biVal, &$biLen, &$biRes, &$biType) { if (count($bin) >= 1) { $res = mssql_init($query); for ($i = 0; $i < count($bin); $i++) { $TypeParam = TRUE; $biRes[$i] = $biVal[$i]; if ($biLen[$i] == -1) { $TypeParam = FALSE; } if ($biType[$i] == 1) { $msType = SQLVARCHAR; } if ($biType[$i] == 2) { $msType = SQLINT4; } if ($biType[$i] == 3) { $msType = SQLFLT8; } if ($biType[$i] == 4) { $msType = SQLVARCHAR; } mssql_bind($res, $bin[$i], $biRes[$i], $msType, $TypeParam); } $resExec = mssql_execute($res); while (mssql_next_result($resExec)) { } } else { $resExec = mssql_query($query); if (!$resExec) { ErreurExecutionMSSQL(); } } return $resExec; }
/** * 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; } }
$City = $_POST['City']; $State = $_POST['State']; $StateID = $_POST['StateID']; $IsTitle4 = $_POST['IsTitle4']; $PageH1 = $_POST['PageH1']; $IsTablet = $_POST['IsTablet']; $isAndroidTablet = $_POST['isAndroidTablet']; // Bind values mssql_bind($info, '@LocID', $LocID, SQLINT4, false, false, 60); mssql_bind($info, '@DmaID', $DmaID, SQLINT4, false, false, 60); mssql_bind($info, '@RegionID', $RegionID, SQLINT4, false, false, 60); mssql_bind($info, '@ZipID', $ZipID, SQLINT4, false, false, 60); mssql_bind($info, '@Lat', $Lat, SQLINT4, false, false, 100); mssql_bind($info, '@Lon', $Lon, SQLINT4, false, false, 100); mssql_bind($info, '@School', $School, SQLVARCHAR, false, false, 255); mssql_bind($info, '@Brand', $Brand, SQLVARCHAR, false, false, 255); mssql_bind($info, '@Email', $Email, SQLVARCHAR, false, false, 255); mssql_bind($info, '@Address', $Address, SQLVARCHAR, false, false, 255); mssql_bind($info, '@Phone', $Phone, SQLVARCHAR, false, false, 12); mssql_bind($info, '@URL', $URL, SQLVARCHAR, false, false, 255); mssql_bind($info, '@City', $City, SQLVARCHAR, false, false, 255); mssql_bind($info, '@State', $State, SQLVARCHAR, false, false, 50); mssql_bind($info, '@StateID', $StateID, SQLINT2, false, false, 2); mssql_bind($info, '@IsTitle4', $IsTitle4, SQLINT1, false, false, 1); mssql_bind($info, '@PageH1', $PageH1, SQLVARCHAR, false, false, 255); mssql_bind($info, '@IsTablet ', $IsTablet, SQLINT1, false, false, 1); mssql_bind($info, '@isAndroidTablet', $isAndroidTablet, SQLINT1, false, false, 1); // Execute the statement mssql_execute($info); mssql_close(); header("Location: http://toolkit.empire-dev.com/schools.php");