PHP code example of pe46dro / laravel-odbc
1. Go to this page and download the library: Download pe46dro/laravel-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/ */
pe46dro / laravel-odbc example snippets
'odbc-connection-name' => [
'driver' => 'odbc',
'dsn' => 'OdbcConnectionName',
'database' => 'DatabaseName',
'host' => '127.0.0.1',
'username' => 'username',
'password' => 'password'
]
'providers' => [
...
Abram\Odbc\ODBCServiceProvider::class
]
# Facade
$books = DB::connection('odbc-connection-name')->table('books')->where('Author', 'Abram Andrea')->get();
# ORM
$books = Book::where('Author', 'Abram Andrea')->get();
class CustomProcessor extends ODBCProcessor
{
/**
* @param Builder $query
* @param null $sequence
* @return mixed
*/
public function getLastInsertId(Builder $query, $sequence = null)
{
return $query->getConnection()->table($query->from)->latest('id')->first()->getAttribute($sequence);
}
}
'odbc-connection-name' => [
'driver' => 'odbc',
'dsn' => 'OdbcConnectionName',
'database' => 'DatabaseName',
'host' => '127.0.0.1',
'username' => 'username',
'password' => 'password',
'options' => [
'processor' => Illuminate\Database\Query\Processors\Processor::class, //default
'grammar' => [
'query' => Illuminate\Database\Query\Grammars\Grammar::class, //default
'schema' => Illuminate\Database\Schema\Grammars\Grammar::class //default
]
]
]