PHP code example of julianmar / laravel-crate
1. Go to this page and download the library: Download julianmar/laravel-crate 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/ */
julianmar / laravel-crate example snippets
'crate' => array(
'driver' => 'crate',
'host' => 'localhost',
'database' => 'doc',
'port' => 4200,
),
'default' => 'crate',
'crate' => array(
'driver' => 'crate',
'host' => 'localhost',
'database' => 'doc',
'port' => 4200,
'username' => 'MyUsername',
'password' => 'MyPassword',
),
'crate' => array(
'driver' => 'crate',
'host' => 'localhost,10.0.0.1,10.0.0.2',
'database' => 'doc',
'port' => 4200,
),
'host' => 'localhost:4201,10.0.0.1:4300,10.0.0.2',
'crate' => array(
'driver' => 'crate',
'host' => 'localhost,10.0.0.1,10.0.0.2',
'database' => 'doc',
'port' => 4200,
'randomHosts' => false,
),
Schema::create('article', function(Blueprint $table)
{
$table->integer('id');
$table->string('title')->index('plain');
$table->mediumText('summary');
$table->text('internal_Comment')->index('off');
$table->text('body')->index('fulltext:english');
$table->bigInteger('nb_views');
$table->timestamp('published_on');
$table->arrayField('images','object as (id integer, title string');
$table->objectField('author','(dynamic) as (id integer, name string)');
$table->timestamps();
$table->primary('id');
});
Schema::createBlob('myblob');
Schema::dropBlob('myblob');
$table->index('field1','fulltext');
$table->string('field1')->index('fulltext');
$table->index(['field1','field2'],'fulltext');
$table->index(['field1','field2'],'fulltext:english');
$table->primary('field1');
$table->primary(['f_id','f2_id']);
$table->string('not_important_field')->index('off');
$table->string('field')->index('plain');
$table->string('field')->index();
Schema::drop('article');
$table->objectField('field_name', 'object parameters');
$table->objectField('my_object_1','as (f_date timestamp)');
$table->objectField('my_object_2','as (object(dynamic) as (name string, birthday timestamp)');
$table->arrayField('f_array','object as (age integer, name string');
$articles = DB::select('select * from article where id = ?', array(1));
$user = DB::table('user')->where('email','[email protected] ')->first();
$users = DB::table('user')->get();
use Julianmar\Crate\Eloquent\Model AS Eloquent;
class Article extends Eloquent {}
protected $table = 'myArticles';
use Julianmar\Crate\Eloquent\Model AS Eloquent;
'CrateEloquent' => 'Julianmar\Crate\Eloquent\Model'
use CrateEloquent;
class Article extends CrateEloquent {}
$articles = Article::all();
$article = Article::find(1);
$articles = Article::where('name','LIKE','Star%')->where('views','>',100)->get();
$articles = Article::where('name','LIKE','Star%')->take(10)->get();
$articles = Article::whereIn('id',[1,2,3])->get();
$article = Article::select('id','name')->where('id',1)->first();
$nb = Article::where('views','>',100)->count();
$articles = Article::where('id','=',3)->orWhere(function($query)
{
$query->where('title', 'Star Wars 7')
->orWhere('title', 'none');
})->get();
$new = Article::create([
'id' => 1, // don't forget, there is no auto increment
'title' => 'John Doe and friends',
'summary' => '...',
'array_of_strings' => ['one', 'two'],
'object_field' => ['author' => 'Someone', 'title' => 'Editpr']
]);
$article = Article::find(1);
$article->title = 'Brand new title';
$article->array_of_strings = ['tree', 'four'];
$article->object_field = ['author' => 'Someone Else', 'title' => 'Administrator'];
$article->save();
$article->object_field = ['crated_by' => 'Third Person'];
$newValues = $article->object_field;
$newValues['created_by'] = 'Third Person';
$article->object_field = $newValues;
$article = Article::find(1);
$article->delete();
'crate' => array(
'driver' => 'crate',
'host' => 'localhost',
'database' => 'doc',
'port' => 4200,
'prefix' => 'sys',
),