sgpatil / oriquent

Orientdb Eloquent driver for Laravel 5
MIT License
47 stars 15 forks source link

empty relation ( create edge CreatedBy from 0 to 0 ) #17

Closed mshanak closed 8 years ago

mshanak commented 8 years ago

hello i have tried to create relation between tow objects like following

$item=new  \App\Page();
        $item->title="page2";
        $item->body="this is body2";
        $item->save();

        $user = new \App\User();
        $user->name="user1";
        $user->email="user1@ggg.com";

        $user->save();
        $relation = $item->created_by()->save($user);

but Laravel throw this error :


om.orientechnologies.orient.core.sql.OCommandSQLParsingException: Error on parsing command at position #0: Error parsing query:
create edge CreatedBy from 0 to 0
Encountered "" at line 1, column 28.
Was expecting one of:
#0 /var/www/html/academicmultisite/vendor/sgpatil/orientdb-php/src/Sgpatil/Orientphp/Transport.php(126): Sgpatil\Orientphp\Transport\Curl->makeRequest('POST', '', Array)
#1 /var/www/html/academicmultisite/vendor/sgpatil/orientdb-php/src/Sgpatil/Orientphp/Command.php(67): Sgpatil\Orientphp\Transport->post('', Array, '/batch/ppustaff')
#2 /var/www/html/academicmultisite/vendor/sgpatil/orientdb-php/src/Sgpatil/Orientphp/Client.php(904): Sgpatil\Orientphp\Command->execute()
#3 /var/www/html/academicmultisite/vendor/sgpatil/orientdb-php/src/Sgpatil/Orientphp/Client.php(237): Sgpatil\Orientphp\Client->runCommand(Object(Sgpatil\Orientphp\Command\ExecuteBatchQuery))
#4 /var/www/html/academicmultisite/vendor/sgpatil/orientdb-php/src/Sgpatil/Orientphp/Batch/Query.php(58): Sgpatil\Orientphp\Client->executeBatchQuery(Object(Sgpatil\Orientphp\Batch\Query))
#5 /var/www/html/academicmultisite/vendor/sgpatil/oriquent/src/Sgpatil/Orientdb/Connection.php(211): Sgpatil\Orientphp\Batch\Query->getResultSet()
#6 /var/www/html/academicmultisite/vendor/sgpatil/oriquent/src/Sgpatil/Orientdb/Connection.php(458): Sgpatil\Orientdb\Connection->Sgpatil\Orientdb\{closure}(Object(Sgpatil\Orientdb\Connection), 'create edge Cre...', Array)
#7 /var/www/html/academicmultisite/vendor/sgpatil/oriquent/src/Sgpatil/Orientdb/Connection.php(213): Sgpatil\Orientdb\Connection->run('create edge Cre...', Array, Object(Closure))
#8 /var/www/html/academicmultisite/vendor/sgpatil/oriquent/src/Sgpatil/Orientdb/Query/Builder.php(805): Sgpatil\Orientdb\Connection->insert('create edge Cre...', Array)
#9 [internal function]: Sgpatil\Orientdb\Query\Builder->insertRelationship(Object(App\Page), Object(App\User), Object(Sgpatil\Orientphp\Relationship), Array)
#10 /var/www/html/academicmultisite/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(1313): call_user_func_array(Array, Array)
#11 /var/www/html/academicmultisite/vendor/sgpatil/oriquent/src/Sgpatil/Orientdb/Eloquent/Edges/Relation.php(220): Illuminate\Database\Eloquent\Builder->__call('insertRelations...', Array)
#12 /var/www/html/academicmultisite/vendor/sgpatil/oriquent/src/Sgpatil/Orientdb/Eloquent/Edges/Relation.php(220): Sgpatil\Orientdb\Eloquent\Builder->insertRelationship(Object(App\Page), Object(App\User), Object(Sgpatil\Orientphp\Relationship), Array)
#13 /var/www/html/academicmultisite/vendor/sgpatil/oriquent/src/Sgpatil/Orientdb/Eloquent/Relations/HasOneOrMany.php(186): Sgpatil\Orientdb\Eloquent\Edges\Relation->save()
#14 /var/www/html/academicmultisite/app/Http/Controllers/PagesController.php(57): Sgpatil\Orientdb\Eloquent\Relations\HasOneOrMany->save(Object(App\User))
#15 [internal function]: App\Http\Controllers\PagesController->store()
#16 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(9268): call_user_func_array(Array, Array)
#17 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(9330): Illuminate\Routing\Controller->callAction('store', Array)
#18 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(9310): Illuminate\Routing\ControllerDispatcher->call(Object(App\Http\Controllers\PagesController), Object(Illuminate\Routing\Route), 'store')
#19 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#20 /var/www/html/academicmultisite/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#21 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#22 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(9787): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#23 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(9311): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#24 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(9298): Illuminate\Routing\ControllerDispatcher->callWithinStack(Object(App\Http\Controllers\PagesController), Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'store')
#25 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(8385): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'App\Http\Contro...', 'store')
#26 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(8372): Illuminate\Routing\Route->runController(Object(Illuminate\Http\Request))
#27 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(8086): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#28 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#29 /var/www/html/academicmultisite/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#30 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#31 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(9787): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#32 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(8087): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#33 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(8078): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#34 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(8068): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#35 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(2393): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#36 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#37 /var/www/html/academicmultisite/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#38 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(3226): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#39 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#40 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(9797): call_user_func_array(Array, Array)
#41 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#42 /var/www/html/academicmultisite/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#43 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#44 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(9787): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#45 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(2340): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#46 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(2324): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#47 /var/www/html/academicmultisite/public/index.php(54): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#48 /var/www/html/academicmultisite/server.php(21): require_once('/var/www/html/a...')
#49 {main}#0 /var/www/html/academicmultisite/vendor/sgpatil/oriquent/src/Sgpatil/Orientdb/Connection.php(213): Sgpatil\Orientdb\Connection->run('create edge Cre...', Array, Object(Closure))
#1 /var/www/html/academicmultisite/vendor/sgpatil/oriquent/src/Sgpatil/Orientdb/Query/Builder.php(805): Sgpatil\Orientdb\Connection->insert('create edge Cre...', Array)
#2 [internal function]: Sgpatil\Orientdb\Query\Builder->insertRelationship(Object(App\Page), Object(App\User), Object(Sgpatil\Orientphp\Relationship), Array)
#3 /var/www/html/academicmultisite/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(1313): call_user_func_array(Array, Array)
#4 /var/www/html/academicmultisite/vendor/sgpatil/oriquent/src/Sgpatil/Orientdb/Eloquent/Edges/Relation.php(220): Illuminate\Database\Eloquent\Builder->__call('insertRelations...', Array)
#5 /var/www/html/academicmultisite/vendor/sgpatil/oriquent/src/Sgpatil/Orientdb/Eloquent/Edges/Relation.php(220): Sgpatil\Orientdb\Eloquent\Builder->insertRelationship(Object(App\Page), Object(App\User), Object(Sgpatil\Orientphp\Relationship), Array)
#6 /var/www/html/academicmultisite/vendor/sgpatil/oriquent/src/Sgpatil/Orientdb/Eloquent/Relations/HasOneOrMany.php(186): Sgpatil\Orientdb\Eloquent\Edges\Relation->save()
#7 /var/www/html/academicmultisite/app/Http/Controllers/PagesController.php(57): Sgpatil\Orientdb\Eloquent\Relations\HasOneOrMany->save(Object(App\User))
#8 [internal function]: App\Http\Controllers\PagesController->store()
#9 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(9268): call_user_func_array(Array, Array)
#10 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(9330): Illuminate\Routing\Controller->callAction('store', Array)
#11 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(9310): Illuminate\Routing\ControllerDispatcher->call(Object(App\Http\Controllers\PagesController), Object(Illuminate\Routing\Route), 'store')
#12 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#13 /var/www/html/academicmultisite/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#14 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#15 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(9787): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#16 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(9311): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#17 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(9298): Illuminate\Routing\ControllerDispatcher->callWithinStack(Object(App\Http\Controllers\PagesController), Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'store')
#18 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(8385): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'App\Http\Contro...', 'store')
#19 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(8372): Illuminate\Routing\Route->runController(Object(Illuminate\Http\Request))
#20 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(8086): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#21 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#22 /var/www/html/academicmultisite/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#23 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#24 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(9787): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#25 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(8087): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#26 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(8078): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#27 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(8068): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#28 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(2393): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#29 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#30 /var/www/html/academicmultisite/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#31 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(3226): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#32 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#33 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(9797): call_user_func_array(Array, Array)
#34 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#35 /var/www/html/academicmultisite/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#36 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#37 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(9787): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#38 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(2340): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#39 /var/www/html/academicmultisite/bootstrap/cache/compiled.php(2324): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#40 /var/www/html/academicmultisite/public/index.php(54): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#41 /var/www/html/academicmultisite/server.php(21): require_once('/var/www/html/a...')
#42 {main}
sgpatil commented 8 years ago

Hello @mshanak , Can you please show me created_by() method.

mshanak commented 8 years ago
namespace App;

use Illuminate\Database\Eloquent\Model;

class Page extends \Orientdb 
{
    protected $table = 'Page';
    protected $fillable = [
        'title', 'body', 'status',
    ];

    public function created_by()
    {
        return $this->hasOne('\App\User', '\App\CreatedBy');
     }
}
sgpatil commented 8 years ago

Have you created CreatedBy class which will extends \Orientdb. Also please check and tell me if the record for user and page get inserted into orientdb database.

mshanak commented 8 years ago

i already have createdBy class

namespace App;

use Illuminate\Database\Eloquent\Model;

class CreatedBy extends \Orientdb
{
    protected $table = 'CreatedBy';
}
mshanak commented 8 years ago

the two records ( page + user ) is inserted successfully , the problem appears when i call the relation

sgpatil commented 8 years ago

Ok.. I am looking into it. Will try to fix it soon.

mshanak commented 8 years ago

Thank you for your help

Be Green & Save a tree. Don't print this e-mail unless it's really necessary.

Mahdi Atawneh, ‹Web Developer…›

On 28 Mar 2016, at 12:30 PM, Sumit Patil notifications@github.com wrote:

Ok.. I am looking into it. Will try to fix it soon.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub

mshanak commented 8 years ago

fixed

sgpatil commented 8 years ago

Hi @mshanak, yes... that fixed the bug. :+1: