当前位置: 首页>>代码示例>>PHP>>正文


PHP odbc_connect函数代码示例

本文整理汇总了PHP中odbc_connect函数的典型用法代码示例。如果您正苦于以下问题:PHP odbc_connect函数的具体用法?PHP odbc_connect怎么用?PHP odbc_connect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了odbc_connect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_json_data

 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;
 }
开发者ID:el486,项目名称:dipsoh-rt,代码行数:26,代码来源:class_lib.php

示例2: GetOdbcSqlServer

 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;
 }
开发者ID:eappl,项目名称:prototype,代码行数:7,代码来源:SqlServer.php

示例3: connect

 /**
  * 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());
     }
 }
开发者ID:jakubkulhan,项目名称:shopaholic,代码行数:34,代码来源:odbc.php

示例4: doquery

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;
    }
}
开发者ID:sonicmaster,项目名称:RPG,代码行数:29,代码来源:odbc.php

示例5: changeUserPassword

 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 = '" . $userOldPassword . "'";
         $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 = '" . $userNewPassword . "' WHERE User_Name = '" . $userName . "'";
         $rs = odbc_exec($conn, $sql);
     }
     return "OK";
 }
开发者ID:nemac,项目名称:flash-fcav,代码行数:31,代码来源:NEMAC_MapViewer_queries.php

示例6: sql_connect

 /**
  * 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('');
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:31,代码来源:mssql_odbc.php

示例7: connect

 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.";
     }
 }
开发者ID:neilor,项目名称:MuShopping-v3,代码行数:7,代码来源:odbc.class.php

示例8: InsereProduto

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";
}
开发者ID:paiol4,项目名称:PI2ndSem,代码行数:7,代码来源:CadProd2.php

示例9: db

 public function db($query)
 {
     $connect = odbc_connect("SIT", "palagi01", "s1mple01");
     $result = odbc_exec($connect, $query);
     return $result;
     #odbc_close($connect);
 }
开发者ID:agansiv,项目名称:DI_Test,代码行数:7,代码来源:db_connect.php

示例10: Connect

 /**
  * @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;
     }
 }
开发者ID:JDevelopers,项目名称:Mail,代码行数:28,代码来源:odbc.php

示例11: toCti

 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;
 }
开发者ID:jocoonopa,项目名称:lubri,代码行数:7,代码来源:Connector.php

示例12: connect

 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");
     }
 }
开发者ID:quan2010,项目名称:DataDictionaryGenerator,代码行数:7,代码来源:Handler.php

示例13: __construct

 /**
  * 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);
     }
 }
开发者ID:keboola,项目名称:php-db-import,代码行数:48,代码来源:Connection.php

示例14: __construct

 /**
  * 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);
     }
 }
开发者ID:Jonathonbyrd,项目名称:SportsCapping-Experts,代码行数:41,代码来源:odbc.php

示例15: sql_db

 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;
     }
 }
开发者ID:BackupTheBerlios,项目名称:phpbbsfp,代码行数:33,代码来源:db2.php


注:本文中的odbc_connect函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。