質問

カスタムモジュールグリッドでグリッドシリアル化を使用しています。

student_idsを使用してデータをフィルタリングしたいです。

現在の学生IDを持っています。

データベース内のstudent_ids exの複数の学生IDを保存します。1,2,3

今度は現在の学生IDがstudent_idsに存在したい。

私はこれを試しています

$currentStudentId = $this->getRequest()->getParam('id');
    $collection = Mage::getModel('example/data')->getCollection()
                ->addFieldToFilter('student_ids',array('like' => '%,'.$currentStudentId));
.

しかし、この1,2,3のような文字列はこのような多くの可能性が非常に多くの可能性であるため、適切なデータが得られませんので、これを使用できません。

[編集]

Enter Image説明

役に立ちましたか?

解決

finset SQL Cluse

$currentStudentId = $this->getRequest()->getParam('id');
        $collection = Mage::getModel('example/data')->getCollection()
         ->addFieldToFilter('student_ids',array("finset"=>$currentStudentId);
.

基本的にこの句は、任意の属性に複数選択がある場合にマゼントで使用します。

あなたのために働くことを願っています。

ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top