2017 © Pedro Peláez
 

library arangodb

An ArangoDb based model and Query builder for Cakephp 3.x

image

cakephparangodb/arangodb

An ArangoDb based model and Query builder for Cakephp 3.x

  • Wednesday, July 18, 2018
  • by shubham715
  • Repository
  • 1 Watchers
  • 0 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

ArangoDB-CAKEPHP-3x - A ArangoDb based model and Query builder for Cakephp 3.x



, (*1)

Table of Contents


, (*2)

, (*3)

Description

This is the cakephp version of the arangodb-php lib. the cakephp client allows you to convert your models to arangodb supported models easily. the cakephp arangodb client also allows you to use cakephp find, save, delete, update and joins etc simillar to cake core functionality., (*4)


, (*5)

, (*6)

Requirements

  • Cakephp version 3.0 or higher, (*7)

  • ArangoDB database server version 3.0 or higher., (*8)

  • PHP version 5.6 or higher, (*9)

Note on PHP version support:, (*10)


, (*11)

, (*12)

Installing the Cakephp arangodb client

To get started you need PHP 5.6 or higher plus an ArangoDB server running on any host that you can access., (*13)

There are two alternative ways to get the Cakephp ArangoDb client:, (*14)

  • Using Composer
  • Cloning the git repository

, (*15)

Alternative 1: Using Composer

composer require cakephparangodb/arangodb

NOTE IF ANY ERROR THEN Add minimum-stability and prefer-stable to your composer.json, (*16)

Example, (*17)

{
    "minimum-stability": "dev",
    "prefer-stable": true
}

, (*18)

Alternative 2: Cloning the git repository

You need to have a git client installed. To clone this repository from github, execute the following command in your project directory:, (*19)

git clone "https://github.com/shubham715/Cakephp-ArangoDb-Package.git"

This will create a subdirectory arangodb-php in your current directory. It contains all the files of the client library. It also includes a dedicated autoloader that you can use for autoloading the client libraries class files. To invoke this autoloader, add the following line to your PHP files that will use the library:, (*20)

, (*21)

Alternative 3: Invoking the autoloader directly

If you do not wish to include autoload.php to load and setup the autoloader, you can invoke the autoloader directly:, (*22)

require 'cakephparangodb/lib/ArangoDBClient/autoloader.php';
\ArangoDBClient\Autoloader::init();


, (*23)

, (*24)

How to use the CAKEPHP client

, (*25)

Setting up the connection options

In order to use Cakephp ArangoDB, you need to specify the connection options. currently its only available from core files of this client in future updates we will add functionality to change db config from app.php, (*26)

For now you need to open yourProject/vendor/cakephparangodb/arangodb/lib/ArangoDBClient/Connect.php and change db config of $_options according to your db config., (*27)

, (*28)

Convert Cakephp Models to ArangoDb supported models. Change your cakephp models to like below example

Here for example i am changing UsersTable Model., (*29)


Thats it. Now you can load model in your controller by using loadModel and use users Table of arangodb into controller like below example, (*30)

, (*31)

Here i am giving some examples that how you can use models in controller

FIND QUERY

Using Find

$data = $this->Users->find('all');

Using Find with conditions

$data = $this->Users->find('all',['conditions'=>['name'=>'test','email'=>'test@gmail.com']]);

Using findById()

$data = $this->Users->findById(10);

Using Find with select

$data = $this->Users->find('all',['select'=>['name','email','status']]);

Using FindOne

$data = $this->Users->findOne('all',['conditions'=>['email'=> $email]]);

advanced find with select , sort , limit

$data = $this->Users->find('all',['select'=>['name','email','status']]);
$data = $this->Users->find('all', ['conditions'=>['email'=>'test@gmail.com'],'order'=>['paydate'=> 'ASC'],'select'=>['name','email','status']]);

Using isUnique

$data = $this->Users->isUnique(['conditions'=>['email'=> $email]]);

Using Count

$data = $this->Users->count(['conditions'=>['email'=> $email]]);

Updation

Using updateById

$data = $this->Users->updateById(['email'=> $email],['id'=> 1]);

Using updateAll

$data = $this->Users->updateAll(['email'=> $email],['id'=> 1]);

deletion

deleteById, (*32)

Using deleteById

$data = $this->Users->deleteById(1);

deleteAll, (*33)

Using deleteAll

$data = $this->Users->deleteAll(['email'=> $email]);

Using createOrUpdate()

$data = $this->Users->createOrUpdate(['email'=> $email,'id'=> 10]);

Join

$data = $this->Users->findWithJoin('all',['contain'=> 'userdetails', 'conditions'=>['c.userid'=> 'u.id']]);
//Here c is refer for base table and u is for join table.

Save Data

$data = ['name'=>'shubham715', email'=> 'shubhamsharma715@gmail.com', 'status'=> 1];
$saveData = $this->Users->save($financeEntity);


, (*34)

Here lots of examples that we will update soon., (*35)

The Versions

18/07 2018

dev-master

9999999-dev https://github.com/shubham715/Cakephp-ArangoDb-Package

An ArangoDb based model and Query builder for Cakephp 3.x

  Sources   Download

Apache-2.0

The Requires

  • php >=5.6.0

 

nosql distributed arango arangodb document store graph database multi-model cakephp-arangodb cakephp3-arango arangodb-php