<?php

use eftec\PdoOne;

/**
 * @param $sql
 * @param PdoOne $conn
 * @return array|bool|PDOStatement|null
 */
 if(!function_exists("mssql_query")) {
function mssql_query($sql,$conn=null) {
    if($conn===null) {
        global $conn;
    }
    $result=$conn->runRawQuery($sql);
    return $result;
}
 }
if(!function_exists("mssql_fetch_row")) {
function mssql_fetch_row($array) {
    return $array;
}
}
if(!function_exists("mssql_num_fields")) {
function mssql_num_fields($array) {
    if(isset($array[0])) {
        return count($array[0]);
    }
    return 0;
}
}
if(!function_exists("mssql_result")) {
function mssql_result($array,$row,$column) {
    global $conn;
    $column=strtolower($column);
    if(!array_key_exists($row,$array)) {
        throw new RuntimeException("index row: [$row][$column] not found");
    }
    if(!array_key_exists($column,@$array[$row])) {
        throw new RuntimeException("index column: [$row][$column] not found. last query [".$conn->lastQuery.']');
    }
    return $array[$row][$column];
}
}