当前位置: 首页>>代码示例>>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;未经允许,请勿转载。