示例#1
46
 function RetrieveEmployeesByPosition($employeePosition1 = null, $employeePosition2 = null, $employeePosition3 = null)
 {
     $dtoArray = array();
     $subQuery = "SELECT posId FROM OHPS";
     if (!empty($employeePosition1)) {
         $subQuery = $subQuery . " WHERE name LIKE '%" . $employeePosition1 . "%'";
     }
     if (!empty($employeePosition2)) {
         $subQuery = $subQuery . " OR name LIKE '%" . $employeePosition2 . "%'";
     }
     if (!empty($employeePosition3)) {
         $subQuery = $subQuery . " OR name LIKE '%" . $employeePosition3 . "%'";
     }
     $query = "SELECT empID, firstName, middleName, lastName FROM OHEM WHERE position IN (" . $subQuery . ") ORDER BY firstName DESC";
     $recordSet = sqlsrv_query($this->sqlserverConnection, $query);
     $index = 0;
     while ($record = sqlsrv_fetch_array($recordSet, SQLSRV_FETCH_ASSOC)) {
         $dto = new EmployeeDTO();
         $dto->empID = $record["empID"];
         $dto->firstName = $record["firstName"];
         $dto->middleName = $record["middleName"];
         $dto->lastName = $record["lastName"];
         $dtoArray[$index] = $dto;
         $index++;
     }
     sqlsrv_free_stmt($recordSet);
     return $dtoArray;
 }
示例#2
30
 function RetrieveRecordArray($filter = null)
 {
     $dtoArray = array();
     // Procura na tabela OCRD (Partner Card)
     $query = "SELECT CardCode, CardName, CardFName, frozenFor, CntctPrsn, Phone1, IndustryC FROM OCRD WHERE " . $filter;
     if (empty($filter)) {
         $query = "SELECT CardCode, CardName, CardFName, frozenFor, CntctPrsn, Phone1, IndustryC FROM OCRD WHERE CardName IS NOT NULL ORDER BY cardName";
     }
     $recordSet = sqlsrv_query($this->sqlserverConnection, $query);
     $index = 0;
     while ($record = sqlsrv_fetch_array($recordSet, SQLSRV_FETCH_ASSOC)) {
         $dto = new BusinessPartnerDTO();
         $dto->cardCode = $record['CardCode'];
         $dto->cardName = $record['CardName'];
         $dto->cardFName = $record['CardFName'];
         $dto->inactive = $record['frozenFor'];
         $dto->contactPerson = $record['CntctPrsn'];
         $dto->telephoneNumber = $record['Phone1'];
         $dto->industry = $record['IndustryC'];
         $dtoArray[$index] = $dto;
         $index++;
     }
     sqlsrv_free_stmt($recordSet);
     return $dtoArray;
 }
示例#3
1
 public function Query($Procedimiento, $RetornaDatos, $arrayValores = "")
 {
     $parametros = array();
     $NombreServidor = constant("sqlHost");
     $InfoConexion = array("UID" => constant("sqlUsuario"), "PWD" => constant("sqlContrasena"), "Database" => $this->NombreBaseDatos);
     $conn = sqlsrv_connect($NombreServidor, $InfoConexion);
     if (is_array($arrayValores)) {
         $stringInterrogacion = "(?";
         for ($i = 1; $i < count($arrayValores); $i++) {
             $stringInterrogacion .= ",?";
         }
         $stringInterrogacion .= ")";
         $Procedimiento = "{call " . $Procedimiento . " " . $stringInterrogacion . "}";
         for ($i = 0; $i < count($arrayValores); $i++) {
             array_push($parametros, array($arrayValores[$i], SQLSRV_PARAM_IN));
         }
     } else {
         $Procedimiento = "{call " . $Procedimiento . "}";
     }
     $stmt3 = sqlsrv_query($conn, $Procedimiento, $parametros);
     if ($RetornaDatos) {
         $array = array();
         while ($obj = sqlsrv_fetch_array($stmt3, SQLSRV_FETCH_ASSOC)) {
             $array[] = $obj;
         }
         return $array;
         sqlsrv_free_stmt($stmt3);
     }
     sqlsrv_close($conn);
 }
示例#4
1
 function sql_query($sqltype, $query, $con)
 {
     if ($sqltype == 'mysql') {
         if (class_exists('mysqli')) {
             return $con->query($query);
         } elseif (function_exists('mysql_query')) {
             return mysql_query($query);
         }
     } elseif ($sqltype == 'mssql') {
         if (function_exists('sqlsrv_query')) {
             return sqlsrv_query($con, $query);
         } elseif (function_exists('mssql_query')) {
             return mssql_query($query);
         }
     } elseif ($sqltype == 'pgsql') {
         return pg_query($query);
     } elseif ($sqltype == 'oracle') {
         return oci_execute(oci_parse($con, $query));
     } elseif ($sqltype == 'sqlite3') {
         return $con->query($query);
     } elseif ($sqltype == 'sqlite') {
         return sqlite_query($con, $query);
     } elseif ($sqltype == 'odbc') {
         return odbc_exec($con, $query);
     } elseif ($sqltype == 'pdo') {
         return $con->query($query);
     }
 }
示例#5
0
文件: db_sqlsrv.php 项目: rokkit/temp
 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;
 }
示例#6
0
function get_count($MID)
{
    $query = "SELECT * FROM riot4.users WHERE logged_MID = ?";
    $params = array($MID);
    $statement = sqlsrv_query($conn, $query, $params);
    return sqlsrv_num_rows($statement);
}
 function RetrieveOther($filter = null)
 {
     $dtoArray = array();
     $query = "SELECT OINV.Serial, INV1.Usage, OINV.CardCode, OINV.CardName, OINV.DocTotal, ORCT.CashSum, ORCT.CheckSum, ORCT.TrsfrSum, ORCT.DocDueDate, OSLP.SlpCode, OSLP.SlpName, OINV.U_demFaturamento FROM ORCT ";
     $query .= "JOIN RCT2 ON RCT2.DocNum = ORCT.DocEntry ";
     $query .= "JOIN OINV ON OINV.DocEntry = RCT2.DocEntry ";
     $query .= "JOIN INV1 ON INV1.DocEntry = OINV.DocEntry ";
     $query .= "JOIN OSLP ON OSLP.SlpCode = OINV.SlpCode ";
     if (!empty($filter)) {
         $query .= " WHERE " . $filter;
     }
     $recordSet = sqlsrv_query($this->sqlserverConnection, $query);
     $index = 0;
     while ($record = sqlsrv_fetch_array($recordSet, SQLSRV_FETCH_ASSOC)) {
         $dto = new InvoicePaymentDTO();
         $dto->serial = $record['Serial'];
         $dto->tipo = $record['Usage'];
         $dto->cardCode = $record['CardCode'];
         $dto->cardName = $record['CardName'];
         $dto->valorNotaFiscal = $record['DocTotal'];
         $dto->valorDinheiro = $record['CashSum'];
         $dto->valorCheque = $record['CheckSum'];
         $dto->valorDeposito = $record['TrsfrSum'];
         $dto->date = $record['DocDueDate'];
         $dto->slpCode = $record['SlpCode'];
         $dto->slpName = $record['SlpName'];
         $dto->demFaturamento = $record['U_demFaturamento'];
         $dtoArray[$index] = $dto;
         $index++;
     }
     sqlsrv_free_stmt($recordSet);
     return $dtoArray;
 }
 function RetrieveRecordArray($filter = null)
 {
     $dtoArray = array();
     $query = "SELECT Address, AddrType, Street, StreetNo, Building, ZipCode, Block, City, State, Country, U_Secretaria FROM CRD1 WHERE " . $filter;
     if (empty($filter)) {
         $query = "SELECT Address, AddrType, Street, StreetNo, Building, ZipCode, Block, City, State, Country, U_Secretaria FROM CRD1 WHERE Address IS NOT NULL";
     }
     $recordSet = sqlsrv_query($this->sqlserverConnection, $query);
     $index = 0;
     while ($record = sqlsrv_fetch_array($recordSet, SQLSRV_FETCH_ASSOC)) {
         $dto = new PartnerAddressDTO();
         $dto->addressLabel = $record["Address"];
         $dto->addrType = $record["AddrType"];
         $dto->street = $record["Street"];
         $dto->streetNo = $record["StreetNo"];
         $dto->building = $record["Building"];
         $dto->zipCode = $record["ZipCode"];
         $dto->block = $record["Block"];
         $dto->city = $record["City"];
         $dto->state = $record["State"];
         $dto->country = $record["Country"];
         $dto->locationRef = $record["U_Secretaria"];
         $dtoArray[$index] = $dto;
         $index++;
     }
     sqlsrv_free_stmt($recordSet);
     return $dtoArray;
 }
/**
 *
 * @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;
}
示例#10
0
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);
}
 public function execute_query($sql, $cursortype = SQLSRV_CURSOR_FORWARD)
 {
     $sqldirective = strtoupper(substr($sql, 0, strpos($sql, ' ')));
     switch ($sqldirective) {
         case 'SELECT':
             $type = SQL_QUERY_SELECT;
             break;
         case 'INSERT':
             $type = SQL_QUERY_INSERT;
             break;
         case 'UPDATE':
             $type = SQL_QUERY_UPDATE;
             break;
         case 'DELETE':
             $type = SQL_QUERY_UPDATE;
             break;
         default:
             print_error('unknownsqldirective', 'block_vmoodle');
             return false;
     }
     $this->query_start($sql, null, $type);
     $result = sqlsrv_query($this->sqlsrv, $sql, null, array('Scrollable' => $cursortype));
     $this->query_end($result);
     return $result;
 }
示例#12
0
 function RetrieveRecordArray($filter = null)
 {
     $dtoArray = array();
     $query = "SELECT * FROM ( ";
     $query .= "SELECT EQP.customer AS codigoCliente, CLI.cardName + ' (' + CLI.cardCode + ')' AS nomeCliente, EQP.insID AS codigoEquipamento, EQP.manufSN AS serieEquipamento, MDL.id AS codigoModelo, MDL.modelo AS tagModelo, ";
     $query .= "FAB.FirmName AS fabricante, CHAM.id AS numeroChamado, CHAM.tempoAtendimento, MONTH(CHAM.dataAtendimento) AS mesReferencia, YEAR(CHAM.dataAtendimento) AS anoReferencia ";
     $query .= "FROM MYSQL...chamadoServico CHAM ";
     $query .= "JOIN OINS EQP ON CHAM.cartaoEquipamento = EQP.insID ";
     $query .= "JOIN OCRD CLI ON EQP.customer = CLI.cardCode ";
     $query .= "JOIN MYSQL...modeloEquipamento MDL ON EQP.U_Model = MDL.id ";
     $query .= "JOIN OMRC FAB ON MDL.fabricante = FAB.FirmCode ";
     $query .= "              ) LABOREXPENSES ";
     if (isset($filter) && !empty($filter)) {
         $query = $query . " WHERE " . $filter;
     }
     $recordSet = sqlsrv_query($this->sqlserverConnection, $query . " ORDER BY nomeCliente, serieEquipamento");
     $index = 0;
     while ($record = sqlsrv_fetch_array($recordSet, SQLSRV_FETCH_ASSOC)) {
         $dto = new LaborExpenseDTO();
         $dto->codigoCliente = $record["codigoCliente"];
         $dto->nomeCliente = $record["nomeCliente"];
         $dto->codigoEquipamento = $record["codigoEquipamento"];
         $dto->serieEquipamento = $record["serieEquipamento"];
         $dto->codigoModelo = $record["codigoModelo"];
         $dto->tagModelo = $record["tagModelo"];
         $dto->fabricante = $record["fabricante"];
         $dto->numeroChamado = $record["numeroChamado"];
         $dto->tempoAtendimento = $record["tempoAtendimento"];
         $dtoArray[$index] = $dto;
         $index++;
     }
     sqlsrv_free_stmt($recordSet);
     return $dtoArray;
 }
示例#13
0
 public function checkUserSession()
 {
     if (!isset($this->SessionID)) {
         return array(false, "Session key empty");
     }
     $SessionID = $this->SessionID;
     $sql = "SELECT Email FROM Sessions WHERE SessionID = ?";
     $params = array($SessionID);
     global $conn;
     if ($conn) {
         $stmt = sqlsrv_query($conn, $sql, $params);
         if ($stmt === false) {
             return array(false, "Connection to server failed.");
         } else {
             if (sqlsrv_has_rows($stmt) > 0) {
                 $email = '';
                 while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
                     $email = $row['Email'];
                 }
                 return array(true, $email);
             } else {
                 return array(false, "Failed to authenticate");
             }
         }
     }
 }
示例#14
0
function GetFacultyQuestions($groupid)
{
    include_once 'db_Connection.php';
    $conn = sqlsrv_connect($serverName, $connectionInfo);
    $questionvalues = array();
    $questions = array();
    $faculty = array();
    $facultyquestions = array();
    if ($conn) {
        //----get acadyear-------------------
        $acid = 0;
        $sqlstr = " SELECT [AcadYearID] FROM [dbo].[Groups] where [groupid]=? ";
        $params = array($groupid);
        $sqlquery = sqlsrv_query($conn, $sqlstr, $params);
        if ($sqlquery) {
            while ($row = sqlsrv_fetch_array($sqlquery, SQLSRV_FETCH_ASSOC)) {
                $acid = $row['AcadYearID'];
            }
            sqlsrv_free_stmt($sqlquery);
        }
        $sqlstr = " SELECT [questionTypeId],[value],[text] " . " FROM [dbo].[QuestionValues] " . " order by questionTypeId ";
        //  $params = array ($acid);
        $sqlquery = sqlsrv_query($conn, $sqlstr);
        if ($sqlquery) {
            while ($row = sqlsrv_fetch_object($sqlquery)) {
                $questionvalues[] = $row;
            }
            sqlsrv_free_stmt($sqlquery);
        }
        //----get question array-------------------
        $sqlstr = " SELECT [QuestionID],[QueastionText],[questionType],[maxmark],-1 as mark,'' as description " . " FROM [dbo].[Questions] " . " where [QuestionLecturer]=0 " . " and [Acadyear]=? ";
        $params = array($acid);
        $sqlquery = sqlsrv_query($conn, $sqlstr, $params);
        if ($sqlquery) {
            while ($row = sqlsrv_fetch_object($sqlquery)) {
                $row->questionValues = array();
                foreach ($questionvalues as &$questValue) {
                    if ($questValue->questionTypeId === $row->questionType) {
                        array_push($row->questionValues, $questValue);
                    }
                }
                $questions[] = $row;
            }
            sqlsrv_free_stmt($sqlquery);
        }
        //----get faculty-------------------
        $sqlstr = " SELECT [FacultyID],[FacultyName] FROM [dbo].[Groups] " . " where [groupid]=? ";
        $params = array($groupid);
        $sqlquery = sqlsrv_query($conn, $sqlstr, $params);
        if ($sqlquery) {
            while ($row = sqlsrv_fetch_object($sqlquery)) {
                $row->quests = $questions;
                $faculty[] = $row;
            }
            $facultyquestions = array("result" => 0, "data" => $faculty);
        }
        sqlsrv_close($conn);
    }
    return $facultyquestions;
}
示例#15
0
文件: template.php 项目: bciv/COMS
function TemplateLevel($templateid, $Location, $NationalLevel, $TemplateOwner)
{
    include "dbitcon.php";
    //Insert into Template Availability
    $tempaval = "INSERT INTO Template_Availability (TemplateID,Location,NationalLevel,TemplateOwner) VALUES ('{$templateid}',{$Location},'{$NationalLevel}',{$TemplateOwner})";
    $InsertTemplateAvailability = sqlsrv_query($conn, $tempaval);
}
示例#16
0
 public function exec($query, $security = NULL)
 {
     if (empty($query)) {
         return false;
     }
     return sqlsrv_query($this->connect, $query);
 }
示例#17
0
 public function query($sql)
 {
     $this->connect();
     $this->stmt = sqlsrv_query($this->conn, $sql);
     if ($this->stmt === false) {
         die(print_r(sqlsrv_errors(), true));
     }
 }
示例#18
0
 /**
  * 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));
     }
 }
示例#19
0
 public function insert_id()
 {
     if ($this->lnk) {
         $result = sqlsrv_fetch_array(sqlsrv_query($this->lnk, "select @@IDENTITY as id"), SQLSRV_FETCH_ASSOC);
         return $result['id'];
     }
     return false;
 }
示例#20
0
 /**
  * @param $idLocation
  * @return bool|resource
  */
 public function getImages(int $idLocation)
 {
     $query = 'SELECT id_image from image where fk_location = ?';
     $stmt = sqlsrv_query(Database::getConnection(), $query, array($idLocation));
     if (sqlsrv_errors()) {
         http_response_code(500);
     }
     return $stmt;
 }
示例#21
0
 function getAll($sql)
 {
     $result = sqlsrv_query($this->con, $sql);
     $arr = array();
     while ($row = sqlsrv_fetch_array($result)) {
         $arr[] = $row;
     }
     return $arr;
 }
示例#22
0
 /**
  * Executes the passed sql and returns the result set.
  *
  * @param $sql
  * @return bool|resource: a statement resource on success and FALSE if an error occurred.
  */
 function dbQuery($sql)
 {
     if (empty($sql)) {
         return false;
     }
     $result = sqlsrv_query(Database::getConnection(), $sql);
     // Prepares and executes a Transact-SQL query.
     return $result;
 }
示例#23
0
 /**
  * Prepares and executes a single SQL Server query
  * @param string $sql
  * @param array  $params Values to bind to placeholders in the query string
  * @return Statement
  * @throws SqlException if an error occurs
  */
 public function query($sql, array $params = [])
 {
     if (!($stmt = sqlsrv_query($this->connection, $sql, $params))) {
         throw new SqlException('Query failed', sqlsrv_errors(), $sql, $params);
     }
     $statement = new Statement($stmt, false, $sql, $params);
     $statement->execute();
     return $statement;
 }
function db_exec($qstring, $conn)
{
    global $strLastSQL, $dDebug;
    if ($dDebug === true) {
        echo $qstring . "<br>";
    }
    $strLastSQL = $qstring;
    return sqlsrv_query($conn, $qstring);
}
示例#25
0
 /**
  * Executes the passed Stored Procedure and returns the result set.
  *
  * @param $sql
  * @param $params - IN & OUT parameters
  * @return bool|resource: a statement resource on success and FALSE if an error occurred.
  */
 function dbCallSP($storedProcedure, $params)
 {
     if (empty($storedProcedure)) {
         return false;
     }
     $result = sqlsrv_query(Database::getInstance()->getConnection(), $storedProcedure, $params);
     // Prepares and executes a Stored Procedure.
     return $result;
 }
示例#26
0
 /**
  * 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;
 }
 public function testStatementExecuteWithParams()
 {
     $products = $this->_db->quoteIdentifier('zfproducts');
     // Make IDENTITY column accept explicit value.
     // This can be done in only one table in a given session.
     sqlsrv_query($this->_db->getConnection(), "SET IDENTITY_INSERT {$products} ON");
     parent::testStatementExecuteWithParams();
     sqlsrv_query($this->_db->getConnection(), "SET IDENTITY_INSERT {$products} OFF");
 }
示例#28
0
 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;
 }
示例#29
-1
 private function executeQuery()
 {
     $return = false;
     if ($this->queryType == 'other') {
         if (sqlsrv_query($this->link, $this->query) !== false) {
             $return = true;
             $this->error = sqlsrv_errors();
         }
     } else {
         if ($stmt = sqlsrv_query($this->link, $this->query)) {
             // Conteo de registros
             if ($this->queryType == 'insert' || $this->queryType == 'update' || $this->queryType == 'delete') {
                 $this->numRows = sqlsrv_rows_affected($stmt);
                 $return = true;
             } else {
                 $this->numRows = sqlsrv_num_rows($stmt);
                 $fetchType = SQLSRV_FETCH_NUMERIC;
                 if ($this->queryReturn == 'assoc') {
                     $fetchType = SQLSRV_FETCH_ASSOC;
                 } elseif ($this->queryReturn == 'both') {
                     $fetchType = SQLSRV_FETCH_BOTH;
                 }
                 $return = array();
                 while ($row = sqlsrv_fetch_array($stmt, $fetchType)) {
                     array_push($return, $row);
                 }
             }
             $this->error = sqlsrv_errors();
             sqlsrv_free_stmt($stmt);
         } else {
             $this->error = sqlsrv_errors();
         }
     }
     return $return;
 }
示例#30
-1
 /**
  * Connect to the database.
  *
  * @throws     <b>AgaviDatabaseException</b> If a connection could not be 
  *                                           created.
  *
  * @author     David Zülke <*****@*****.**>
  * @since      1.0.4
  */
 protected function connect()
 {
     $serverName = $this->getParameter('server_name');
     if ($serverName == null) {
         // missing required server_name parameter
         $error = 'Database configuration is missing "server_name" parameter';
         throw new AgaviDatabaseException($error);
     }
     if ($this->hasParameter('settings')) {
         foreach ((array) $this->getParameter('settings') as $key => $value) {
             if (!sqlsrv_configure($key, is_string($value) && strpos($value, 'SQLSRV_') === 0 && defined($value) ? constant($value) : (is_numeric($value) ? (int) $value : $value))) {
                 throw new AgaviDatabaseException(sprintf('Unsupported key or value for setting "%s".', $key));
             }
         }
     }
     $connectionInfo = $this->getParameter('connection_info');
     foreach ($connectionInfo as &$value) {
         $value = is_string($value) && strpos($value, 'SQLSRV_') === 0 && defined($value) ? constant($value) : (is_numeric($value) ? (int) $value : $value);
     }
     $this->connection = sqlsrv_connect($serverName, $connectionInfo);
     if (!$this->connection) {
         $this->connection = null;
         throw new AgaviDatabaseException(sprintf("%s\n\n%s", sprintf('Could not open database connection "%s".', $this->getName()), implode("\n", $this->getErrors())));
     }
     $this->resource =& $this->connection;
     foreach ((array) $this->getParameter('init_queries') as $query) {
         sqlsrv_query($this->connection, $query);
     }
 }