本文整理汇总了PHP中sqlsrv_execute函数的典型用法代码示例。如果您正苦于以下问题:PHP sqlsrv_execute函数的具体用法?PHP sqlsrv_execute怎么用?PHP sqlsrv_execute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sqlsrv_execute函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SaveLecturerMarks
function SaveLecturerMarks($marks)
{
$status = array();
include_once 'db_Connection.php';
$conn = sqlsrv_connect($serverName, $connectionInfo);
if ($conn) {
$login = "0";
$subjectid = 0;
$subjtype = 0;
$lectid = 0;
$qid = 0;
$mark = 0;
$ldescription = "0";
$sqlstr = " insert into [dbo].[MarkLecturer] ([Login],[subjid],[subjtype],[lectid],[qid],[mark],[ldescription]) " . " values (?,?,?,?,?,?,?) ";
$params = array(&$login, &$subjectid, &$subjtype, &$lectid, &$qid, &$mark, &$ldescription);
$stmt = sqlsrv_prepare($conn, $sqlstr, $params);
if ($stmt) {
foreach ($marks as &$data) {
$login = $data->login;
$subjectid = $data->subjectid;
$subjtype = $data->subjtype;
$lectid = $data->lectid;
$qid = $data->qid;
$mark = $data->mark;
$ldescription = $data->description;
if (!sqlsrv_execute($stmt)) {
array_push($status, "not inserted-L" . $login . "-S" . $subjectid . "-T" . $subjtype . "-L" . $lectid . "-Q" . $qid);
}
}
}
sqlsrv_close($conn);
}
return $status;
}
示例2: processWalking
function processWalking($results, $fileRow)
{
global $csvData;
global $sqlDB;
global $plat;
//this is where I'm going to do things
foreach ($results as $result) {
$startDate = $result['DateBegan'];
$endDate = $result['DateStopped'];
$diff = date_diff($startDate, $endDate);
$days = $diff->format("%a");
$currentDate = $result['DateBegan'];
$formattedDate = date_format($currentDate, 'm/d/y');
$tempData = array();
while ($currentDate <= $endDate) {
$dayDate = $formattedDate . ' ' . "00:00:00";
$endDay = $formattedDate . ' ' . "23:59:59";
$querry = "SELECT TOP 1 RecID FROM vPhoneData1\n\t\t\t\tWHERE (TaskSetName = '1 PING' or TaskSetName =\n\t\t\t\t '3 REPORT CGI_OR_H2RL') AND LocalTimetag1 > ? and\n\t\t\t\t LocalTimetag1 < ? and cast(FORMDATA as varchar(max)) like\n\t\t\t\t '%" . $plat . "%'";
$stmt = sqlsrv_prepare($sqlDB, $querry, array(&$dayDate, &$endDay));
sqlsrv_execute($stmt);
$fetched = sqlsrv_fetch_array($stmt);
if (!empty($fetched)) {
$formattedDate = date_format($currentDate, 'm/d/y');
$fileRow['Survey Dt'] = $formattedDate;
$fileRow['Completed By'] = $result['TechName'];
$fileRow['Instrument'] = $result['Instrument'];
$fileRow['Rate'] = $result['RateCode'];
$fileRow['Survey Method'] = 'WALK';
$tempData[] = $fileRow;
}
$currentDate = date_add($currentDate, date_interval_create_from_date_string('1 days'));
$formattedDate = date_format($currentDate, 'm/d/y');
$fetched = null;
}
if (!empty($tempData)) {
$daycount = count($tempData);
if ($result[6] > 0) {
$dailyTotal = floor($result[6] / $daycount);
$firstTotal = $dailyTotal + $result[6] % $daycount;
$isFirst = TRUE;
} else {
$dailyTotal = 0;
}
foreach ($tempData as $tempRow) {
if ($isFirst === TRUE) {
$tempRow['Quantity'] = $firstTotal;
$isFirst = FALSE;
} elseif ($dailyTotal > 0) {
$tempRow['Quantity'] = $dailyTotal;
} else {
$tempRow['Quantity'] = 0;
}
if ($tempRow['Quantity'] > 0) {
$csvData[] = $tempRow;
}
}
}
}
}
示例3: execute
public static function execute($psql, $prm = null)
{
$ret = false;
if ($psql) {
$ret = sqlsrv_execute($psql);
}
return $ret;
}
示例4: executePreparedStatement
/**
* (non-PHPdoc)
* @see PreparedStatement::executePreparedStatement()
*/
public function executePreparedStatement(array $data, $msg = '')
{
if (!$this->prepareStatementData($data, count($this->fieldDefs), $msg)) {
return false;
}
$res = sqlsrv_execute($this->stmt);
return $this->finishStatement($res, $msg);
}
示例5: query
public function query($sql)
{
$this->curStmt = sqlsrv_prepare($this->linkID, $query, array());
return sqlsrv_execute($this->curStmt);
}
示例6: array
$adres = $_POST['adres'];
$town = $_POST['town'];
$zip = $_POST['zip'];
$land = $_POST['land'];
$birthdate = $_POST['birthdate'];
$email = $_POST['email'];
$username = $_SESSION['username'];
$sql = "SELECT * FROM GEBRUIKER WHERE GEBRUIKERSNAAM='{$username}'";
$params = array();
$options = array("Scrollable" => SQLSRV_CURSOR_KEYSET);
$stmt = sqlsrv_query($conn, $sql, $params, $options);
$rowCount = sqlsrv_num_rows($stmt);
if ($rowCount == 1) {
$sqlUpdate = "UPDATE GEBRUIKER SET Voornaam='{$name}', Achternaam='{$lastname}', Adresregel='{$adres}', Postcode='{$zip}', Plaatsnaam='{$town}', Land='{$land}', GeboorteDag='{$birthdate}', Mailbox='{$email}' WHERE GEBRUIKERSNAAM='{$username}'";
$stmtUpdate = sqlsrv_prepare($conn, $sqlUpdate);
sqlsrv_execute($stmtUpdate);
header('location: profiel.php');
}
}
sqlsrv_close($conn);
} else {
die(print_r(sqlsrv_errors(), true));
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="stylesheet.css"/>
<meta charset="utf-8">
<title>Eenmaal Andermaal</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
示例7: p_query
public function p_query($sql, $params)
{
$prep_params = array();
for ($x = 0; $x < count($params); $x++) {
$prep_params[] =& $params[$x];
}
$stmt = sqlsrv_prepare($this->dbh, $sql, $prep_params);
if ($stmt === false) {
return false;
}
return sqlsrv_execute($stmt);
}
示例8: execute
/**
* Execute
*
* @param array|ParameterContainer $parameters
* @throws Exception\RuntimeException
* @return Result
*/
public function execute($parameters = null)
{
/** END Standard ParameterContainer Merging Block */
if (!$this->isPrepared) {
$this->prepare();
}
/** START Standard ParameterContainer Merging Block */
if (!$this->parameterContainer instanceof ParameterContainer) {
if ($parameters instanceof ParameterContainer) {
$this->parameterContainer = $parameters;
$parameters = null;
} else {
$this->parameterContainer = new ParameterContainer();
}
}
if (is_array($parameters)) {
$this->parameterContainer->setFromArray($parameters);
}
if ($this->parameterContainer->count() > 0) {
$this->bindParametersFromContainer();
}
if ($this->profiler) {
$this->profiler->profilerStart($this);
}
$resultValue = sqlsrv_execute($this->resource);
if ($this->profiler) {
$this->profiler->profilerFinish();
}
if ($resultValue === false) {
$errors = sqlsrv_errors();
// ignore general warnings
if ($errors[0]['SQLSTATE'] != '01000') {
throw new Exception\RuntimeException($errors[0]['message']);
}
}
$result = $this->driver->createResult($this->resource);
return $result;
}
示例9: doQuery
/**
* @param string $sql
* @return bool|MssqlResult
* @throws DBUnexpectedError
*/
protected function doQuery($sql)
{
global $wgDebugDumpSql;
if ($wgDebugDumpSql) {
wfDebug("SQL: [{$sql}]\n");
}
$this->offset = 0;
// several extensions seem to think that all databases support limits
// via LIMIT N after the WHERE clause well, MSSQL uses SELECT TOP N,
// so to catch any of those extensions we'll do a quick check for a
// LIMIT clause and pass $sql through $this->LimitToTopN() which parses
// the limit clause and passes the result to $this->limitResult();
if (preg_match('/\\bLIMIT\\s*/i', $sql)) {
// massage LIMIT -> TopN
$sql = $this->LimitToTopN($sql);
}
// MSSQL doesn't have EXTRACT(epoch FROM XXX)
if (preg_match('#\\bEXTRACT\\s*?\\(\\s*?EPOCH\\s+FROM\\b#i', $sql, $matches)) {
// This is same as UNIX_TIMESTAMP, we need to calc # of seconds from 1970
$sql = str_replace($matches[0], "DATEDIFF(s,CONVERT(datetime,'1/1/1970'),", $sql);
}
// perform query
// SQLSRV_CURSOR_STATIC is slower than SQLSRV_CURSOR_CLIENT_BUFFERED (one of the two is
// needed if we want to be able to seek around the result set), however CLIENT_BUFFERED
// has a bug in the sqlsrv driver where wchar_t types (such as nvarchar) that are empty
// strings make php throw a fatal error "Severe error translating Unicode"
if ($this->mScrollableCursor) {
$scrollArr = array('Scrollable' => SQLSRV_CURSOR_STATIC);
} else {
$scrollArr = array();
}
if ($this->mPrepareStatements) {
// we do prepare + execute so we can get its field metadata for later usage if desired
$stmt = sqlsrv_prepare($this->mConn, $sql, array(), $scrollArr);
$success = sqlsrv_execute($stmt);
} else {
$stmt = sqlsrv_query($this->mConn, $sql, array(), $scrollArr);
$success = (bool) $stmt;
}
if ($this->mIgnoreDupKeyErrors) {
// ignore duplicate key errors, but nothing else
// this emulates INSERT IGNORE in MySQL
if ($success === false) {
$errors = sqlsrv_errors(SQLSRV_ERR_ERRORS);
$success = true;
foreach ($errors as $err) {
if ($err['SQLSTATE'] == '23000' && $err['code'] == '2601') {
continue;
// duplicate key error
} elseif ($err['SQLSTATE'] == '01000' && $err['code'] == '3621') {
continue;
// generic "the statement has been terminated" error
}
$success = false;
// getting here means we got an error we weren't expecting
break;
}
if ($success) {
$this->mAffectedRows = 0;
return true;
}
}
}
if ($success === false) {
return false;
}
// remember number of rows affected
$this->mAffectedRows = sqlsrv_rows_affected($stmt);
return $stmt;
}
示例10: execute
public function execute($bind_params = false)
{
$ret_val = false;
$arg_list = func_get_args();
$lazy = isset($arg_list[1]) && $arg_list[1] ? true : false;
//----------------------------------------------
// Prepare SQL Statement
//----------------------------------------------
$prepare_status = $this->_prepare($this->curr_query, $bind_params, $lazy);
if (!$prepare_status) {
if ($this->check_and_print_error()) {
return false;
}
$this->print_error('Query prepare failed.');
return false;
}
if (!$this->stmt) {
return false;
}
//----------------------------------------------
// Execute Query
//----------------------------------------------
$exec_status = @sqlsrv_execute($this->stmt);
if (!$exec_status) {
if ($this->check_and_print_error()) {
return false;
}
$this->print_error('Query execution failed.');
return false;
}
//----------------------------------------------
// Create Data Result Object if Necessary
//----------------------------------------------
if ($this->stmt && gettype($this->stmt) != 'boolean') {
//----------------------------------------------
// Affected Rows
//----------------------------------------------
$this->affected_rows = sqlsrv_rows_affected($this->stmt);
$ret_val = $this->affected_rows;
//----------------------------------------------
// Create Data Result Object
//----------------------------------------------
$has_rows = sqlsrv_has_rows($this->stmt);
$this->data_result = new data_result($this->stmt, $this->data_src);
//----------------------------------------------
// Last Insert ID
//----------------------------------------------
$this->last_id = null;
}
//----------------------------------------------
// Return Data Result Object if it exists
//----------------------------------------------
if ($this->data_result) {
$this->num_rows = $this->data_result->num_rows();
$this->num_fields = $this->data_result->num_fields();
$ret_val = $this->data_result;
}
//----------------------------------------------
// Check for Errors
//----------------------------------------------
if ($this->check_and_print_error()) {
return false;
}
return $ret_val;
}
示例11: execute
/**
* Execute the prepared SQL query.
*
* @throws \Pop\Db\Adapter\Exception
* @return void
*/
public function execute()
{
if (null === $this->statement) {
throw new Exception('Error: The database statement resource is not currently set.');
}
sqlsrv_execute($this->statement);
}
示例12: META_RECURSO
$consulta = " INSERT INTO META_RECURSO (RECU_TITULO,RECU_TEMA,RECU_DESC,RECU_FUENTE,RECU_LENGUAJE,RECU_RELACION,RECU_COBERTURA,DOCU_ID) \n\t\tVALUES ('{$titulo}','{$tema}','{$desc}','{$fuente}','{$lenguaje}','{$relacion}','{$cobertura}',{$idDoc}) ";
$recurso = sqlsrv_prepare($conn, $consulta);
//$ejecutar_con = sqlsrv_query( $conn, $consulta);
if (sqlsrv_execute($recurso)) {
$mensaje = ":)";
} else {
echo "CTM!!";
}
$consulta = " INSERT INTO META_INSTANCIA ( INST_FECHA,INST_TIPO,INST_FORMATO,INST_IDENTIFICADOR,DOCU_ID) \n\t\tVALUES ('{$fecha}','{$tipo}','{$formato}','{$ident}',{$idDoc}) ";
$recurso = sqlsrv_prepare($conn, $consulta);
//$ejecutar_con = sqlsrv_query( $conn, $consulta);
if (sqlsrv_execute($recurso)) {
$mensaje = ":)";
}
$consulta = " INSERT INTO META_PROPIEDAD ( PROP_AUTOR,PROP_EDITOR,PROP_COLABORADOR,PROP_DEPARTAMENTO,PROP_DERECHOS,DOCU_ID) \n\t\tVALUES ('{$autor}','{$editor}','{$colaborador}','{$departamento}','{$derechos}',{$idDoc}) ";
$recurso = sqlsrv_prepare($conn, $consulta);
//$ejecutar_con = sqlsrv_query( $conn, $consulta);
if (sqlsrv_execute($recurso)) {
$mensaje = ":)";
sqlsrv_close($conn);
header("Location: ../../index.php?op=meta&{$mensaje}");
}
} else {
sqlsrv_close($conn);
$mensaje = "Ya se ingreso el documento";
//header("Location: ../../index.php?op=meta&$mensaje");
}
?>
示例13: __query
/**
* Execute the query
* this method is private
* @param string $query
* @param resource $connection
* @return resource|boolean Returns a statement resource on success and FALSE if an error occurred.
*/
function __query($query, $connection)
{
$_param = array();
if (count($this->param)) {
foreach ($this->param as $k => $o) {
if ($o->isColumnName()) {
continue;
}
if ($o->getType() == 'number') {
$value = $o->getUnescapedValue();
if (is_array($value)) {
$_param = array_merge($_param, $value);
} else {
$_param[] = $o->getUnescapedValue();
}
} else {
$value = $o->getUnescapedValue();
if (is_array($value)) {
foreach ($value as $v) {
$_param[] = array($v, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8'));
}
} else {
$_param[] = array($value, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8'));
}
}
}
}
// Run the query statement
$result = false;
if (count($_param)) {
$args = $this->_getParametersByReference($_param);
$stmt = sqlsrv_prepare($connection, $query, $args);
} else {
$stmt = sqlsrv_prepare($connection, $query);
}
if (!$stmt) {
$result = false;
} else {
$result = sqlsrv_execute($stmt);
}
// Error Check
if (!$result) {
$this->setError(print_r(sqlsrv_errors(), true));
}
$this->param = array();
return $stmt;
}
示例14: array
<tr>
<?php
//telefoon gebruiker
$sqlTel = "SELECT * FROM Gebruikerstelefoon where Gebruiker='{$user}'";
$paramsTel = array();
$optionsTel = array("Scrollable" => SQLSRV_CURSOR_KEYSET);
$stmtTel = sqlsrv_query($conn, $sqlTel, $paramsTel, $optionsTel);
$rowCountTel = sqlsrv_num_rows($stmtTel);
$actual_link = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
$getFirstEnd = end(explode('?', $actual_link));
$getSecondEnd = substr($getFirstEnd, 0, 6);
if ($getSecondEnd == 'remove') {
$end = end(explode('?remove=', $actual_link));
$sqlDelete = "DELETE FROM Gebruikerstelefoon WHERE Telefoonnummer = '{$end}' AND Gebruiker = '{$user}'";
$stmtDelete = sqlsrv_prepare($conn, $sqlDelete);
sqlsrv_execute($stmtDelete);
}
while ($rowTel = sqlsrv_fetch_array($stmtTel, SQLSRV_FETCH_ASSOC)) {
$Teltel = $rowTel['Telefoonnummer'];
echo '<tr> </td><td><td><input type="text" name="telefoon" placeholder="' . $Teltel . '" disabled><a style="float: right;" href="?remove=' . $Teltel . '">Verwijder </a></td></tr>';
//$counter ++;
//if ($counter == $rowCountTel || $counter <= 1){
//}
}
echo '<tr><td> </td><td><a class="right" href="addPhoneNumber.php">Telefoonnummer toevoegen</a></td></tr>';
?>
</tr>
</table>
</div>
<div class="omschrijving">
示例15: array
private function &callWithSqlSrv($qry)
{
$connectionInfo = array("UID" => $this->username, "PWD" => $this->password, "Database" => $this->dbname);
$conn = sqlsrv_connect($this->servername, $connectionInfo);
$params = array();
foreach ($this->params as $param) {
$params[] =& $param[0];
}
if (!($stmt = sqlsrv_prepare($conn, $qry, $params))) {
throw new Exception(sqlsrv_errors());
return false;
}
if (!sqlsrv_execute($stmt)) {
throw new Exception(sqlsrv_errors());
return false;
}
return $stmt;
if (!sqlsrv_fetch($stmt)) {
return false;
}
foreach ($this->columnBindings as $k => $col) {
if ($col[1]) {
$col[0] = sqlsrv_get_field($stmt, $k, SQLSRV_PHPTYPE_STREAM($col[1]));
} else {
$col[0] = sqlsrv_get_field($stmt, $k);
}
}
// successfully created connection and executed query, return true.
// the user should now be calling "movenext"
$this->sqlsrvConnection =& $conn;
$this->sqlsrvStatement =& $stmt;
return true;
}