當前位置: 首頁>>代碼示例>>PHP>>正文


PHP sqlsrv_errors函數代碼示例

本文整理匯總了PHP中sqlsrv_errors函數的典型用法代碼示例。如果您正苦於以下問題:PHP sqlsrv_errors函數的具體用法?PHP sqlsrv_errors怎麽用?PHP sqlsrv_errors使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了sqlsrv_errors函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: dbcall

function dbcall()
{
    session_start();
    $seubid = (string) session_id();
    $server = "bamsql2";
    $options = array("UID" => "genes", "PWD" => "Genes12", "Database" => "genes");
    $conn = sqlsrv_connect($server, $options);
    if ($conn === false) {
        die("<pre>" . print_r(sqlsrv_errors(), true));
    }
    $rno = $_POST['Rnumber'];
    $name = $_POST['name'];
    $email = $_POST['email'];
    $gender = $_POST['gender'];
    $sql = "insert INTO dbo.contactinfo values('{$rno}','{$name}','{$email}','{$gender}')";
    $query = sqlsrv_query($conn, $sql);
    if ($query === false) {
        exit("<pre>" . print_r(sqlsrv_errors(), true));
    }
    #while ($row = sqlsrv_fetch_array($query))
    # {  echo "<p>Hello, $row[ascore]!</p>";
    #}
    sqlsrv_free_stmt($query);
    sqlsrv_close($conn);
}
開發者ID:vivek8943,項目名稱:RawlsGACode,代碼行數:25,代碼來源:Guessdemo.php

示例2: query

 public function query($sql)
 {
     LogMaster::log($sql);
     if ($this->start_from) {
         $res = sqlsrv_query($this->connection, $sql, array(), array("Scrollable" => SQLSRV_CURSOR_STATIC));
     } else {
         $res = sqlsrv_query($this->connection, $sql);
     }
     if ($res === false) {
         $errors = sqlsrv_errors();
         $message = array();
         foreach ($errors as $error) {
             $message[] = $error["SQLSTATE"] . $error["code"] . $error["message"];
         }
         throw new Exception("SQLSrv operation failed\n" . implode("\n\n", $message));
     }
     if ($this->insert_operation) {
         sqlsrv_next_result($res);
         $last = sqlsrv_fetch_array($res);
         $this->last_id = $last["dhx_id"];
         sqlsrv_free_stmt($res);
     }
     if ($this->start_from) {
         $data = sqlsrv_fetch($res, SQLSRV_SCROLL_ABSOLUTE, $this->start_from - 1);
     }
     return $res;
 }
開發者ID:rokkit,項目名稱:temp,代碼行數:27,代碼來源:db_sqlsrv.php

示例3: dbGetErrorMsg

function dbGetErrorMsg()
{
    $retVal = sqlsrv_errors();
    $retVal = $retVal[0]["message"];
    $retVal = preg_replace('/\\[Microsoft]\\[SQL Server Native Client [0-9]+.[0-9]+](\\[SQL Server\\])?/', '', $retVal);
    return $retVal;
}
開發者ID:beingsane,項目名稱:ClashOfClans-1,代碼行數:7,代碼來源:Functions.inc.php

示例4: existeTabla

/**
 *
 * @param resource $conn
 *        	Recurso que contiene la conexión SQL.
 * @param string $tabla        	
 * @param boolean $comprobar
 *        	Si está a true (valor por defecto) siempre hace la comprobación.
 *        	Si se pone el valor a false sólo hace la comprobación cuando es
 *        	día 1.
 * @return mixed array si hay un error SQL. Si la tabla no existe false. Si la
 *         tabla existe true.
 */
function existeTabla($conn, $tabla, $comprobarTabla = 1)
{
    $hoy = getdate();
    if ($hoy["mday"] == 1 or $comprobarTabla) {
        global $respError;
        $sql = "select * from dbo.sysobjects where id = object_id(N'{$tabla}')";
        // Ejecutar una consulta SQL para saber si existe la tabla de auditoría
        //////////////////////////////////////////////////////
        $stmt = sqlsrv_query($conn, $sql);
        if ($stmt === false) {
            if (($errors = sqlsrv_errors()) != null) {
                $SQLSTATE = $errors[0]["SQLSTATE"];
                $Cerror = $errors[0]["code"];
                $Merror = utf8_encode($errors[0]["message"]);
                if ($farmacia == FARMACIA_DEBUG or strlen(FARMACIA_DEBUG) == 0) {
                    if (DEBUG & DEBUG_ERROR_SQL) {
                        $mensaje = "--[" . date("c") . "] código: {$Cerror} mensaje: {$Merror} \n";
                        $mensaje .= "--Error en el fichero: " . __FILE__ . ", en la línea: " . __LINE__;
                        error_log($mensaje . $sql . "\r\n", 3, DIRECTORIO_LOG . __FUNCTION__ . "_" . date("YmdH") . ".log");
                    }
                }
                // Error al hacer la consulta
                return $respError->errorSQL($SQLSTATE, $Cerror, $Merror);
            }
        }
        if (sqlsrv_has_rows($stmt) === false) {
            // La tabla no existe.
            return false;
        }
    }
    // La tabla existe o no hay que comprobarlo
    return true;
}
開發者ID:Veridata,項目名稱:servidorSoapHTTPS,代碼行數:45,代碼來源:existeTabla.php

示例5: AttemptConnection

 public function AttemptConnection()
 {
     if (empty($this->type)) {
         return false;
     } elseif ($this->type == "MySQL") {
         $this->connection = mysqli_connect($this->address, $this->username, $this->password, $this->database);
         if (!$this->connection) {
             $this->lastErrorMessage = "Error: Unable to connect to MySQL." . PHP_EOL . "Debugging errno: " . mysqli_connect_errno() . PHP_EOL . "Debugging error: " . mysqli_connect_error() . PHP_EOL;
             return false;
         }
         //SQL Server
     } elseif ($this->type == "MSSQL") {
         $connectionInfo = array("Database" => $this->database, "UID" => $this->username, "PWD" => $this->password);
         $this->connection = sqlsrv_connect($this->address, $connectionInfo);
         if (!$this->connection) {
             $errorString = "";
             if (($errors = sqlsrv_errors()) != null) {
                 foreach ($errors as $error) {
                     $errorString .= PHP_EOL . "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" . PHP_EOL;
                     $errorString .= "SQLSTATE: " . $error['SQLSTATE'] . PHP_EOL;
                     $errorString .= "code: " . $error['code'] . PHP_EOL;
                     $errorString .= "message: " . $error['message'] . PHP_EOL;
                 }
             }
             $this->lastErrorMessage = "Error: Unable to connect to SQL Server." . PHP_EOL . "Debugging error: " . $errorString . PHP_EOL;
             $this->lastError = $errorString;
             return false;
         }
     }
     return $this->connection;
 }
開發者ID:Blue-Kachina,項目名稱:Helping-Developers-With-Class,代碼行數:31,代碼來源:DBConnection.php

示例6: begin_trans

 function begin_trans()
 {
     if (sqlsrv_begin_transaction($this->conn) == false) {
         echo "Could not begin transaction.\n";
         die(print_r(sqlsrv_errors(), true));
     }
     $this->in_trans = true;
 }
開發者ID:alucard263096,項目名稱:AMK,代碼行數:8,代碼來源:sqlsrv.cls.php

示例7: begin_trans

 function begin_trans()
 {
     if (mysql_query("BEGIN") == false) {
         echo "Could not begin transaction.\n";
         die(print_r(sqlsrv_errors(), true));
     }
     $this->in_trans = true;
 }
開發者ID:iwarsong,項目名稱:NCMI,代碼行數:8,代碼來源:mysql.cls.php

示例8: query

 /**
  * Enviar query para servidor SQL
  *
  * @param string $query sql query
  *
  * @return void
  */
 public function query($query)
 {
     $query = filter_var($query, FILTER_SANITIZE_STRING);
     $this->_query = sqlsrv_query($this->conn, $query);
     if (!$this->_query) {
         die(print_r(sqlsrv_errors(), true));
     }
 }
開發者ID:PPAmani,項目名稱:sqlsrv_class,代碼行數:15,代碼來源:sqlsrv_class.php

示例9: errors

 /**
  * Returns all errors as a string
  *
  * @return  string
  */
 protected function errors()
 {
     $string = '';
     foreach (sqlsrv_errors() as $error) {
         $string .= '[' . $error[0] . ':' . $error[1] . ']: ' . $error[2] . ', ';
     }
     return substr($string, 0, -2);
 }
開發者ID:Gamepay,項目名稱:xp-framework,代碼行數:13,代碼來源:SqlSrvConnection.class.php

示例10: query

 public function query($sql)
 {
     $this->connect();
     $this->stmt = sqlsrv_query($this->conn, $sql);
     if ($this->stmt === false) {
         die(print_r(sqlsrv_errors(), true));
     }
 }
開發者ID:arodriguezcnmc,項目名稱:test,代碼行數:8,代碼來源:db_sqlsrv.php

示例11: loadEventsByLocation

 public function loadEventsByLocation(int $location)
 {
     $query = 'SELECT event.name AS name, event.description AS description FROM event INNER JOIN location ON event.fk_location = location.id_location WHERE location.id_location = ?';
     $stmt = sqlsrv_query($this->connection, $query, [$location]);
     if (sqlsrv_errors()) {
         http_response_code(500);
     }
     return $stmt;
 }
開發者ID:PascalHonegger,項目名稱:M151,代碼行數:9,代碼來源:EventModel.php

示例12: __construct

 public function __construct($dbName = "ecs")
 {
     $dbHost = ".";
     $connectionInfo = array("Database" => $dbName, "UID" => "sa", "PWD" => "sa");
     $this->conn = sqlsrv_connect($dbHost, $connectionInfo);
     if (!$this->conn) {
         exit('Connect Error (' . sqlsrv_errors() . ') ' . sqlsrv_errors());
     }
 }
開發者ID:brianvargas,項目名稱:hello-world,代碼行數:9,代碼來源:db.php

示例13: loadLocationsByIdAndName

 /**
  * Lädt die Orte, welche den mitgegebenen String im Namen enthalten.
  * Offset: Beim wievielten Datensatz das Laden beginnt
  * Rows: Wie viele Datensätze geladen werden
  * @param int $offset
  * @param int $rows
  * @param string $location
  * @return bool|resource
  */
 public function loadLocationsByIdAndName(int $offset, int $rows, string $location)
 {
     $query = "SELECT \n                    id_location AS id_location,\n                    name AS name, \n                    description AS description\n                    FROM location\n                    WHERE location.name LIKE ?\n                    ORDER BY id_location\n                    OFFSET {$offset} ROWS \n                    FETCH NEXT {$rows} ROWS ONLY";
     $stmt = sqlsrv_query(Database::getConnection(), $query, ['%' . $location . '%']);
     if (sqlsrv_errors()) {
         http_response_code(500);
     }
     return $stmt;
 }
開發者ID:PascalHonegger,項目名稱:M151,代碼行數:18,代碼來源:LocationModel.php

示例14: query

 /**
  * Executes the SQL query.
  * @param  string      SQL statement.
  * @return IDibiResultDriver|NULL
  * @throws DibiDriverException
  */
 public function query($sql)
 {
     $this->resultSet = sqlsrv_query($this->connection, $sql);
     if ($this->resultSet === FALSE) {
         $info = sqlsrv_errors();
         throw new DibiDriverException($info[0]['message'], $info[0]['code'], $sql);
     }
     return is_resource($this->resultSet) ? clone $this : NULL;
 }
開發者ID:jaroslavlibal,項目名稱:MDW,代碼行數:15,代碼來源:mssql2005.php

示例15: getErrors

 /**
  * Get SQL errors
  *
  * @return string
  */
 public function getErrors()
 {
     $errors = null;
     $errorAry = sqlsrv_errors();
     foreach ($errorAry as $key => $value) {
         $errors .= 'SQLSTATE: ' . $value['SQLSTATE'] . ', CODE: ' . $value['code'] . ' => ' . stripslashes($value['message']) . PHP_EOL;
     }
     return $errors;
 }
開發者ID:akinyeleolubodun,項目名稱:PhireCMS2,代碼行數:14,代碼來源:Sqlsrv.php


注:本文中的sqlsrv_errors函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。