Skip to content

Instantly share code, notes, and snippets.

@jokosusilo
Created April 14, 2014 15:34
Show Gist options
  • Save jokosusilo/10658866 to your computer and use it in GitHub Desktop.
Save jokosusilo/10658866 to your computer and use it in GitHub Desktop.
<?php
// Load eloquent
require 'vendor/autoload.php';
// Setting eloquent
use Illuminate\Database\Capsule\Manager as Capsule;
$capsule = new Capsule;
$capsule->addConnection(array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'nama_database',
'username' => 'username',
'password' => 'password',
'prefix' => '',
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
));
$capsule->bootEloquent();
$capsule->setAsGlobal();
$conn = $capsule->connection();
// Penggunaan Eloquent
use Illuminate\Database\Eloquent\Model as Model;
class User extends Model {
public $table = "user";
public $timestamps = false;
}
print_r(User::all());
// Informasi detail tentang Eloquent dan method2nya, ada di http://laravel.com/docs/eloquent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment