PHP code example of yoramdelangen / laravel-pdo-odbc

1. Go to this page and download the library: Download yoramdelangen/laravel-pdo-odbc library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yoramdelangen / laravel-pdo-odbc example snippets


'providers' => [
  // ...
  LaravelPdoOdbc\ODBCServiceProvider::class,
];

'snowflake_pdo' => [
    'driver' => 'snowflake_native',
    'account' => '{account_name}.eu-west-1',
    'username' => '{username}',
    'password' => '{password}',
    'database' => '{database}',
    'warehouse' => '{warehouse}',
    'schema' => 'PUBLIC', // change it if necessary.
    'options' => [
        // Required for Snowflake usage
        \PDO::ODBC_ATTR_USE_CURSOR_LIBRARY => \PDO::ODBC_SQL_USE_DRIVER
    ]
],

   'odbc-connection-name' => [
       'driver' => 'odbc',
       'dsn' => 'OdbcConnectionName', // odbc: will be prefixed
       'username' => 'username',
       'password' => 'password'
   ]
   

   'odbc-connection-name' => [
       'driver' => 'odbc',
       'dsn' => 'Driver={Your Snowflake Driver};Server=snowflake.example.com;Port=443;Database={DatabaseName}',
       'username' => 'username',
       'password' => 'password'
   ]
   

   'odbc-connection-name' => [
       'driver' => 'snowflake',
       // please change this path accordingly your exact location
       'odbc_driver' => '/opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib',
       // 'odbc_driver' => 'Snowflake path Driver',
       'server' => 'host.example.com',
       'username' => 'username',
       'password' => 'password',
       'warehouse' => 'warehouse name',
       'schema' => 'PUBLIC', // most ODBC connections use the default value
   ]
   

# Facade
$books = DB::connection('odbc-connection-name')
            ->table('books')
            ->where('Author', 'Abram Andrea')
            ->get();

# ORM
$books = Book::where('Author', 'Abram Andrea')->get();