1. Go to this page and download the library: Download explosivebit/yii2-arangodb 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/ */
use explosivebit\arangodb\Query;
$query = new Query;
// compose the query
$query->select(['name', 'status'])
->from('customer')
->limit(10);
// execute the query
$rows = $query->all();
use explosivebit\arangodb\ActiveRecord;
class Customer extends ActiveRecord
{
/**
* @return string the name of the index associated with this ActiveRecord class.
*/
public static function collectionName()
{
return 'customer';
}
/**
* @return array list of attribute names.
*/
public function attributes()
{
return ['_key', 'name', 'email', 'address', 'status'];
}
}
use yii\data\ActiveDataProvider;
use explosivebit\arangodb\Query;
$query = new Query;
$query->from('customer')->where(['status' => 2]);
$provider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSize' => 10,
]
]);
$models = $provider->getModels();
use yii\data\ActiveDataProvider;
use app\models\Customer;
$provider = new ActiveDataProvider([
'query' => Customer::find(),
'pagination' => [
'pageSize' => 10,
]
]);
$models = $provider->getModels();
class m170413_210957_create_services_collection extends \explosivebit\arangodb\Migration
{
public function up()
{
# When you start the migration, a collection of "services" with the edge type is created
$this->createCollection('services',['Type' => 3]);
}
public function down()
{
# When the migration rollback starts, the collection "services"
$this->dropCollection('services');
}
}