sta*_*upz 2 php doctrine symfony1
我正在使用Doctrine 1.2处理Symfony 1.4,我遇到了一些问题.
我创建了一个我的产品的Doctrine集合,如下所示:
$oProductCollection = new Doctrine_Collection('Products');
Run Code Online (Sandbox Code Playgroud)
我添加了一些产品:
$oProductCollection->add($oMyProduct);
Run Code Online (Sandbox Code Playgroud)
然后我想知道产品是否已经在我的收藏中.因为如果我添加我的产品两次,那将覆盖我的旧版本......
我发现"包含"功能,但我不能直接提供我的产品对象,我不知道关键是什么...
请问你能帮帮我吗 ?
您可以设置keyColumn
通过
//set the id column as key
$oProductCollection = new Doctrine_Collection('Products', 'id');
Run Code Online (Sandbox Code Playgroud)
然后您可以$oProductCollection->contains($oMyProduct->getId());
用来检查$oMyProduct
您的收藏中是否已有.
归档时间: |
|
查看次数: |
4642 次 |
最近记录: |