私は、リレーショナルモデルの列を通してメインモデルのデータセット全体をソートしようとしています。 MongoのモデルLaravel Jensenggers Eloquentモデルをソートメインモデルとリレーションモデル
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class UserEventActivity extends Eloquent
{
protected $collection = 'user_event_activity';
protected $connection = 'mongodb';
public function handset() {
return $this->hasOne('HandsetDetails', '_id', 'handset_id');
}
public function storeDetail() {
return $this->hasOne('StoreDetails', 'st_id', 'store_id');
}
}
HandsetDetails.php - 私は
UserEventActivity.php持っている3.1
はここでモデルですLaravel ORM 5.2.43とJensenggersにMongoDBを使用しています - Mongoモデル
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class HandsetDetails extends Eloquent
{
var $collection = 'user_handset_details';
var $connection = 'mongodb';
}
StoreDetails.php - MySQLのモデル
use Jenssegers\Mongodb\Eloquent\HybridRelations;
use Illuminate\Database\Eloquent\Model as Eloquent;
class StoreDetails extends Eloquent
{
use HybridRelations;
protected $connection = 'mysql';
protected $table = 'icn_store';
}
PHPのスクリプト
$activity = UserEventActivity::join('handset ', 'handset._id', '=', 'handset_id')
->join('storeDetail', 'store_id', '=', 'storeDetail.st_id')
->orderBy('handset.handset_make', 'desc')
->select('storeDetail.*', 'handset.*')
->get()
->toArray();
UserEventActivity
からこのデータは、携帯電話の関係でhandset_make
フィールドに基づいて保存されていません。
私の知る限りのMongoDBはこのように加入をサポートしていません知っているように予想される結果
ありがとう:)それは働いた – Haridarshan