Esempio n. 1
2
 public function get_json_data()
 {
     $lista = json_decode($this->field_list);
     $base = $this->db->getDB();
     $this->conn = odbc_connect("DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ={$base}", '', '') or exit('Cannot open with driver.');
     if (!$this->conn) {
         exit("Connection Failed: " . $this->conn);
     }
     $rs = odbc_exec($this->conn, $this->sql);
     if (!$rs) {
         exit("Error in SQL");
     }
     $value = '[';
     while (odbc_fetch_row($rs)) {
         $value .= '[';
         foreach ($lista as $valor) {
             $value .= $this->not_null(odbc_result($rs, $valor[0]), $valor[1]) . ',';
         }
         $value .= '],';
     }
     $value .= ']';
     $value = str_replace(",]", "]", $value);
     odbc_close_all();
     //$value = utf8_encode($value);
     return $value;
 }
Esempio n. 2
0
 public function GetOdbcSqlServer($Ip, $User, $Pass, $Db)
 {
     $connstr = "Driver={SQL Server};Server={$Ip};Database={$Db}";
     echo $connstr . "\n";
     $con = odbc_connect($connstr, $User, $Pass, SQL_CUR_USE_ODBC) or False;
     return $con;
 }
Esempio n. 3
0
 /**
  * Connects to a database.
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     DibiConnection::alias($config, 'username', 'user');
     DibiConnection::alias($config, 'password', 'pass');
     if (isset($config['resource'])) {
         $this->connection = $config['resource'];
     } else {
         // default values
         if (!isset($config['username'])) {
             $config['username'] = ini_get('odbc.default_user');
         }
         if (!isset($config['password'])) {
             $config['password'] = ini_get('odbc.default_pw');
         }
         if (!isset($config['dsn'])) {
             $config['dsn'] = ini_get('odbc.default_db');
         }
         if (empty($config['persistent'])) {
             $this->connection = @odbc_connect($config['dsn'], $config['username'], $config['password']);
             // intentionally @
         } else {
             $this->connection = @odbc_pconnect($config['dsn'], $config['username'], $config['password']);
             // intentionally @
         }
     }
     if (!is_resource($this->connection)) {
         throw new DibiDriverException(odbc_errormsg() . ' ' . odbc_error());
     }
 }
Esempio n. 4
0
function doquery($query, $table, $fetch = false)
{
    global $link, $debug, $ugamela_root_path;
    @(include $ugamela_root_path . 'config.php');
    if (!$link) {
        $link = odbc_connect($dbsettings["server"], $dbsettings["user"], $dbsettings["pass"]) or $debug->error(odbc_error() . "<br />{$query}", "SQL Error");
        //message(mysql_error()."<br />$query","SQL Error");
        odbc_select_db($dbsettings["name"]) or $debug->error(odbc_error() . "<br />{$query}", "SQL Error");
    }
    // por el momento $query se mostrara
    // pero luego solo se vera en modo debug
    $sqlquery = odbc_exec($query, str_replace("{{table}}", $dbsettings["prefix"] . $table)) or $debug->error(odbc_error() . "<br />{$query}", "SQL Error");
    //message(mysql_error()."<br />$query","SQL Error");
    unset($dbsettings);
    //se borra la array para liberar algo de memoria
    global $numqueries, $debug;
    //,$depurerwrote003;
    $numqueries++;
    //$depurerwrote003 .= ;
    $debug->add("<tr><th>Query {$numqueries}: </th><th>{$query}</th><th>{$table}</th><th>{$fetch}</th></tr>");
    if ($fetch) {
        //hace el fetch y regresa $sqlrow
        $sqlrow = odbc_fetch_array($sqlquery);
        return $sqlrow;
    } else {
        //devuelve el $sqlquery ("sin fetch")
        return $sqlquery;
    }
}
 public function changeUserPassword($userName, $userOldPassword, $userNewPassword, $portalID)
 {
     VDSN;
     $conn = odbc_connect(VDSN, USER, PW) or die('ODBC Error:: ' . odbc_error() . ' :: ' . odbc_errormsg() . ' :: ' . VDSN);
     //test for user name
     if ($conn) {
         $sql = "SELECT '1' outputFlag FROM Portal_User WHERE User_Name = '" . $userName . "' AND Portal_ID = '" . $portalID . "'";
         $rs = odbc_exec($conn, $sql);
         $row = odbc_fetch_row($rs);
         if ($row == null) {
             odbc_close($conn);
             return "You have entered an invalid user name; please try again.";
         }
     }
     //test for password
     if ($conn) {
         $sql = "SELECT '1' FROM Users WHERE User_Name = '" . $userName . "' AND User_Password = '******'";
         $rs = odbc_exec($conn, $sql);
         $row = odbc_fetch_row($rs);
         if ($row == null) {
             odbc_close($conn);
             return "You have entered an invalid password for your account; please try again.";
         }
     }
     //save new password
     if ($conn) {
         $sql = "UPDATE Users SET User_Password = '******' WHERE User_Name = '" . $userName . "'";
         $rs = odbc_exec($conn, $sql);
     }
     return "OK";
 }
 /**
  * Connect to server
  */
 function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
 {
     $this->persistency = $persistency;
     $this->user = $sqluser;
     $this->dbname = $database;
     $port_delimiter = defined('PHP_OS') && substr(PHP_OS, 0, 3) === 'WIN' ? ',' : ':';
     $this->server = $sqlserver . ($port ? $port_delimiter . $port : '');
     $max_size = @ini_get('odbc.defaultlrl');
     if (!empty($max_size)) {
         $unit = strtolower(substr($max_size, -1, 1));
         $max_size = (int) $max_size;
         if ($unit == 'k') {
             $max_size = floor($max_size / 1024);
         } else {
             if ($unit == 'g') {
                 $max_size *= 1024;
             } else {
                 if (is_numeric($unit)) {
                     $max_size = floor((int) ($max_size . $unit) / 1048576);
                 }
             }
         }
         $max_size = max(8, $max_size) . 'M';
         @ini_set('odbc.defaultlrl', $max_size);
     }
     $this->db_connect_id = $this->persistency ? @odbc_pconnect($this->server, $this->user, $sqlpassword) : @odbc_connect($this->server, $this->user, $sqlpassword);
     return $this->db_connect_id ? $this->db_connect_id : $this->sql_error('');
 }
Esempio n. 7
0
 public function connect()
 {
     $this->connection = @odbc_connect(@DNS_ODBC, @USER_ODBC, @PWD_ODBC);
     if (!$this->connection) {
         echo "<br>LdODBC Error: n&atilde;o foi possivel conectar do Banco de Dados.";
     }
 }
Esempio n. 8
0
function InsereProduto($NomeProduto, $descProduto, $precProduto, $descontoProduto, $idCategoria, $ativoProduto, $idUsuario, $qtdMinEstoque)
{
    $con = odbc_connect("DRIVER={SQL Server}; SERVER=i9yueekhr9.database.windows.net;\n\t\tDATABASE=lotus;", "TSI", "SistemasInternet123");
    $SQL = "insert into produto(nomeProduto, descProduto, precProduto, descontoPromocao, idCategoria, ativoProduto, idUsuario, qtdMinEstoque, imagem)\n\t\tvalues('" . $NomeProduto . "', '" . $descProduto . "', " . $precProduto . ", \n\t\t\t" . $descontoProduto . ", " . $idCategoria . ", " . $ativoProduto . ", " . $idUsuario . ", " . $qtdMinEstoque . ",  null)";
    odbc_exec($con, $SQL);
    echo "PRODUTO INSERIDO COM SUCESSO";
}
Esempio n. 9
0
 public function db($query)
 {
     $connect = odbc_connect("SIT", "palagi01", "s1mple01");
     $result = odbc_exec($connect, $query);
     return $result;
     #odbc_close($connect);
 }
Esempio n. 10
0
 /**
  * @return bool
  */
 function Connect()
 {
     if (!extension_loaded('odbc')) {
         $this->ErrorDesc = 'Can\'t load ODBC extension.';
         setGlobalError($this->ErrorDesc);
         $this->_log->WriteLine($this->ErrorDesc, LOG_LEVEL_ERROR);
         return false;
     }
     if ($this->_log->Enabled) {
         $ti = getmicrotime();
     }
     $this->_conectionHandle = @odbc_connect($this->_dbCustomConnectionString, $this->_user, $this->_pass, SQL_CUR_USE_ODBC);
     if ($this->_conectionHandle && $this->_log->Enabled) {
         $this->_log->WriteLine(':: connection time -> ' . (getmicrotime() - $ti));
     }
     if ($this->_conectionHandle) {
         if ($this->_dbType == DB_MYSQL) {
             @odbc_exec($this->_conectionHandle, 'SET NAMES utf8');
         }
         return true;
     } else {
         $this->_setSqlError();
         return false;
     }
 }
Esempio n. 11
0
 public static function toCti()
 {
     if (!(self::$ctiCnx = odbc_connect(env('ODBC_CTI_DSN'), env('ODBC_CTI_USER'), env('ODBC_CTI_PWD'), SQL_CUR_USE_ODBC))) {
         throw new \Exception('odbc error');
     }
     return self::$ctiCnx;
 }
Esempio n. 12
0
 public function connect()
 {
     $this->link = $this->_config['pconnect'] == 0 ? @odbc_connect($this->_config['dsn'], $this->_config['username'], $this->_config['password'], SQL_CUR_USE_ODBC) : odbc_pconnect($this->_config['dsn'], $this->_config['username'], $this->_config['password'], SQL_CUR_USE_ODBC);
     if (!$this->link) {
         $this->halt("Connect to odbc  failed");
     }
 }
Esempio n. 13
0
 /**
  * The connection constructor accepts the following options:
  * - host (string, required) - hostname
  * - port (int, optional) - port - default 443
  * - user (string, required) - username
  * - password (string, required) - password
  * - warehouse (string) - default warehouse to use
  * - database (string) - default database to use
  * - tracing (int) - the level of detail to be logged in the driver trace files
  * - loginTimeout (int) - Specifies how long to wait for a response when connecting to the Snowflake service before returning a login failure error.
  * - networkTimeout (int) - Specifies how long to wait for a response when interacting with the Snowflake service before returning an error. Zero (0) indicates no network timeout is set.
  * - queryTimeout (int) - Specifies how long to wait for a query to complete before returning an error. Zero (0) indicates to wait indefinitely.
  *
  * @param array $options
  */
 public function __construct(array $options)
 {
     $requiredOptions = ['host', 'user', 'password'];
     $missingOptions = array_diff($requiredOptions, array_keys($options));
     if (!empty($missingOptions)) {
         throw new Exception('Missing options: ' . implode(', ', $missingOptions));
     }
     $port = isset($options['port']) ? (int) $options['port'] : 443;
     $tracing = isset($options['tracing']) ? (int) $options['tracing'] : 0;
     $dsn = "Driver=SnowflakeDSIIDriver;Server=" . $options['host'];
     $dsn .= ";Port=" . $port;
     $dsn .= ";Tracing=" . $tracing;
     if (isset($options['loginTimeout'])) {
         $dsn .= ";Login_timeout=" . (int) $options['loginTimeout'];
     }
     if (isset($options['networkTimeout'])) {
         $dsn .= ";Network_timeout=" . (int) $options['networkTimeout'];
     }
     if (isset($options['queryTimeout'])) {
         $dsn .= ";Query_timeout=" . (int) $options['queryTimeout'];
     }
     if (isset($options['database'])) {
         $dsn .= ";Database=" . $this->quoteIdentifier($options['database']);
     }
     if (isset($options['warehouse'])) {
         $dsn .= ";Warehouse=" . $this->quoteIdentifier($options['warehouse']);
     }
     try {
         $this->connection = odbc_connect($dsn, $options['user'], $options['password']);
     } catch (\Exception $e) {
         throw new Exception("Initializing Snowflake connection failed: " . $e->getMessage(), null, $e);
     }
 }
Esempio n. 14
0
 /**
  * Database object constructor
  *
  * @access	public
  * @param	array	List of options used to configure the connection
  * @since	1.5
  * @see		bDatabase
  */
 function __construct($options)
 {
     $host = array_key_exists('host', $options) ? $options['host'] : 'localhost';
     $user = array_key_exists('user', $options) ? $options['user'] : '';
     $password = array_key_exists('password', $options) ? $options['password'] : '';
     $database = array_key_exists('database', $options) ? $options['database'] : '';
     $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : 'jos_';
     $select = array_key_exists('select', $options) ? $options['select'] : true;
     // Requires the direct server path
     $driver = array(1 => '{Microsoft Access Driver (*.mdb)}', 2 => '{SQL Server Native Client 10.0}', 3 => '{Microsoft Excel Driver (*.xls)}', 4 => '{SQL Server}', 5 => '{Adaptive Server Anywhere 8.0}');
     $provider = array(1 => 'Microsoft.ACE.OLEDB.12.0', 2 => 'Microsoft.Jet.OLEDB.4.0');
     $dsn = "" . "Driver={$driver['1']};" . "DriverId=281;" . "Data Source=" . $host . $database . ";" . "DefaultDir=" . $host . ";" . "DATABASE=" . $database . ";" . "Servername=localhost;" . "Port=5432;" . "ReadOnly=Yes;" . "Persist Security Info=False;" . "UID=" . $user . ";" . "PWD=" . $password . ";";
     echo $dsn . '<BR><BR>';
     // perform a number of fatality checks, then return gracefully
     if (!function_exists('odbc_connect')) {
         $this->_errorNum = 1;
         $this->_errorMsg = 'The ODBC adapter "odbc" is not available.';
         return;
     }
     //echo $dsn;
     // connect to the server
     if (!($this->_resource = odbc_connect($dsn, $user, $password, SQL_CUR_USE_ODBC))) {
         $this->_errorNum = 2;
         $this->_errorMsg = 'Could not connect to ODBC';
         return;
     }
     // finalize initialization
     parent::__construct($options);
     // select the database
     if ($select) {
         $this->select($database);
     }
 }
Esempio n. 15
0
 function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
 {
     $mtime = microtime();
     $mtime = explode(" ", $mtime);
     $mtime = $mtime[1] + $mtime[0];
     $starttime = $mtime;
     $this->persistency = $persistency;
     $this->user = $sqluser;
     $this->password = $sqlpassword;
     $this->dbname = $database;
     $this->server = $sqlserver;
     if ($this->persistency) {
         $this->db_connect_id = odbc_pconnect($this->server, "", "");
     } else {
         $this->db_connect_id = odbc_connect($this->server, "", "");
     }
     if ($this->db_connect_id) {
         @odbc_autocommit($this->db_connect_id, off);
         $mtime = microtime();
         $mtime = explode(" ", $mtime);
         $mtime = $mtime[1] + $mtime[0];
         $endtime = $mtime;
         $this->sql_time += $endtime - $starttime;
         return $this->db_connect_id;
     } else {
         $mtime = microtime();
         $mtime = explode(" ", $mtime);
         $mtime = $mtime[1] + $mtime[0];
         $endtime = $mtime;
         $this->sql_time += $endtime - $starttime;
         return false;
     }
 }
Esempio n. 16
0
function connectDB()
{
    $dsn = 'TPDB';
    $user = '';
    $password = '';
    $con = odbc_connect($dsn, $user, $password);
    return $con;
}
Esempio n. 17
0
 public function try_connect($login, $pasw, $db_name = NULL)
 {
     if ($db_name == NULL || empty($db_name)) {
         $db_name = $this->db;
     }
     $try_dsn = sprintf("Driver={%s};UID=%s;PWD=%s;DBQ=%s", $this->drvr, $login, $pasw, $db_name);
     return odbc_connect($try_dsn, NULL, NULL);
 }
Esempio n. 18
0
 /**
  * Connect to the database
  */
 public function db_connect()
 {
     /**==================================================================
     		 * Connect to the user databsae
     		 ====================================================================*/
     $this->link = odbc_connect($this->c_ident['host'], $this->c_ident['user'], $this->c_ident['password']);
     /*===================================================================*/
 }
 /**
  * @return boolean successfully connected or not
  */
 public function connect()
 {
     // No changes needed from now on
     $connection_string = "Driver={$this->driver};Server={$this->host};Database={$this->dbname}";
     // $connection_string = "DSN=testdsn";
     $this->connection = @odbc_connect($connection_string, $this->user, $this->pass);
     return $this->connection;
 }
Esempio n. 20
0
 function db_connect($oArray)
 {
     $oCon = odbc_connect($oArray[2], $oArray[0], $oArray[1]);
     if (!$oCon) {
         die("could not connect");
     }
     return $oCon;
 }
Esempio n. 21
0
function DeletarProduto($idProduto)
{
    $con = odbc_connect("DRIVER={SQL Server}; SERVER=i9yueekhr9.database.windows.net;\n\t\tDATABASE=lotus;", "TSI", "SistemasInternet123");
    //$SQL = 'SELECT COUNT(*) AS QTD FROM ESTOQUE WHERE IDPRODUTO='.$idProduto;
    $SQL = 'delete from produto where idproduto = ' . $idProduto;
    echo "PRODUTO EXCLUIDO COM SUCESSO";
    odbc_exec($con, $SQL);
}
Esempio n. 22
0
 public function getConnection_mssql()
 {
     $host = "vasquez-pc";
     $dbname = "tramites";
     $user = "******";
     $password = "******";
     $conn = odbc_connect("Driver={SQL Server Native Client 10.0};Server={$host};Database={$dbname};", $user, $password);
     return $conn;
 }
Esempio n. 23
0
 /**
  * check the connection.
  *
  * @return void
  */
 public static function chkConnect($config)
 {
     $conid = @odbc_connect($config['dsn'], $config['username'], $config['password'], SQL_CUR_USE_ODBC);
     if (odbc_error()) {
         //return odbc_errormsg(); //SQL Server 2005 不支持 utf-8 编码,其使用  UCS-2  编码架构(所有 unicode 字符都占用 2 个字节)。
         return 'connect failed';
     }
     return true;
 }
Esempio n. 24
0
 public function connect($config = array())
 {
     $this->config = $config;
     $dsn = !empty($this->config['dsn']) ? $this->config['dsn'] : 'DRIVER=' . $this->config['host'] . ';SERVER=' . $this->config['server'] . ';DATABASE=' . $this->config['database'];
     $this->connect = $this->config['pconnect'] === true ? @odbc_pconnect($dsn, $this->config['user'], $this->config['password']) : @odbc_connect($dsn, $this->config['user'], $this->config['password']);
     if (empty($this->connect)) {
         die(getErrorMessage('Database', 'mysqlConnectError'));
     }
 }
Esempio n. 25
0
 function _connect($argDSN, $argUsername, $argPassword, $argDatabasename)
 {
     global $php_errormsg;
     $php_errormsg = '';
     $this->_connectionID = odbc_connect($argDSN, $argUsername, $argPassword, $this->curmode);
     $this->_errorMsg = $php_errormsg;
     //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true);
     return $this->_connectionID != false;
 }
Esempio n. 26
0
 /**
  * 连接数据库,参数与 odbc_connect 相同
  *
  * 连接成功后存储在$this->db 中,无返回,出错则返回错误信息
  *
  * @version 0.13.9.28
  * @param unknown $dsn        	
  * @param unknown $user        	
  * @param unknown $password        	
  * @param string $cursor_type        	
  * @return multitype:string
  */
 function connect($dsn, $user, $password, $cursor_type = null)
 {
     $this->db = odbc_connect($dsn, $user, $password, $cursor_type);
     // 连接数据库
     if (false === $this->db) {
         return array('error' => '错误代码' . odbc_error() . '。错误信息:' . odbc_errormsg());
     }
     // 出错时返回错误代码
 }
Esempio n. 27
0
 function connect()
 {
     if (0 == $this->Link_ID) {
         $this->Link_ID = odbc_connect($this->Database, $this->User, $this->Password, $this->UseODBCCursor);
         if (!$this->Link_ID) {
             $this->halt("Link-ID == false, connect failed");
         }
     }
 }
Esempio n. 28
0
function DBGetConnection($name, $db, $user, $password)
{
    // Establece una conexión con el servidor Oracle..
    $conn = odbc_connect($name, $user, $password);
    if (!$conn) {
        echo "Error al conectarse al servidor de la base de datos.";
    }
    return $conn;
}
Esempio n. 29
0
 function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
 {
     $this->persistency = $persistency;
     $this->user = $sqluser;
     $this->server = $sqlserver . ($port ? ':' . $port : '');
     $this->dbname = $database;
     $this->db_connect_id = $this->persistency ? @odbc_pconnect($this->server, $this->user, $sqlpassword) : @odbc_connect($this->server, $this->user, $sqlpassword);
     return $this->db_connect_id ? $this->db_connect_id : $this->sql_error('');
 }
Esempio n. 30
-1
	/**
	* Connect to server
	*/
	function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
	{
		$this->persistency = $persistency;
		$this->user = $sqluser;
		$this->server = $sqlserver . (($port) ? ':' . $port : '');
		$this->dbname = $database;

		$max_size = @ini_get('odbc.defaultlrl');
		if (!empty($max_size))
		{
			$unit = strtolower(substr($max_size, -1, 1));
			$max_size = (int) $max_size;

			if ($unit == 'k')
			{
				$max_size = floor($max_size / 1024);
			}
			else if ($unit == 'g')
			{
				$max_size *= 1024;
			}
			else if (is_numeric($unit))
			{
				$max_size = floor((int) ($max_size . $unit) / 1048576);
			}
			$max_size = max(8, $max_size) . 'M';

			@ini_set('odbc.defaultlrl', $max_size);
		}

		$this->db_connect_id = ($this->persistency) ? @odbc_pconnect($this->server, $this->user, $sqlpassword) : @odbc_connect($this->server, $this->user, $sqlpassword);

		return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
	}