草庐IT

sub-collection

全部标签

php - 拉维 5.1 : How to share a collection in all views?

我需要在所有View中共享一个集合。此集合包含网站新闻:$news=NewsStory::orderBy('created_at','desc')->paginate(5);我该怎么做? 最佳答案 可以分享ViewData所有View之间。只需将这一行添加到App\Providers\AppServiceProvider中的boot()方法:view()->share('news',NewsStory::orderBy('created_at','desc')->paginate(5));

php - 即使在包含 laravel Collective 之后,Laravel 5.1 Blade 也无法正常工作

composer.json{"name":"laravel/laravel","description":"TheLaravelFramework.","keywords":["framework","laravel"],"license":"MIT","type":"project","require":{"php":">=5.5.9","laravel/framework":"5.1.*","laravelcollective/html":"5.1.*"},"require-dev":{"fzaninotto/faker":"~1.4","mockery/mockery":"0.9

php - ZeroMQ PUB/SUB 不适用于 PHP

我目前正在处理一个相当大的数据处理任务,需要拆分和分配处理。我有一个使用ZeroMQ的PUSH/PULL机制的完整工作流水线原型(prototype)-正在发送“处理”数据并完成OK。但是,一旦数据被扇出并且处理完成,我需要指示工作人员(在while/true循环中运行)终止。我认为为此使用ZMQ的PUB/SUB机制是明智的。但是,工作人员没有收到任何控制消息。令人沮丧的是,如果我切换到PUSH/PULL机制,工作人员会收到消息并正确终止。我从这里复制了一些原型(prototype)代码:http://pastebin.com/myZyWQ1E您可以看到生产者(向工作人员发送数据的位)

基于 PHP Memcache(d) 的 session : Should garbage collection be disabled?

当使用peclmemcached(或者我猜是memcache..)扩展时,是否应该通过将概率设置为0来禁用php的session垃圾收集(例如:session.gc_probability/session.gc_divisor)?由于以下原因,这似乎是合乎逻辑的:A)session过期时间很可能只是通过在存储的key上设置过期时间来简单地存储。EG:每个session都有其到期ttl,并在到期时被memcached简单地清除。B)要清除尚未被memcached本身清除的现有session,memcached扩展必须对存储在memcache守护进程中的所有数据进行完整转储,检查每个键以查

php - 如何通过索引将项目添加到 Laravel Eloquent Collection 中?

我尝试了以下但它不起作用。$index=2;$collection->put($index,$item4);例如,如果$collection看起来像这样:$collection=[$item1,$item2,$item3];我想结束:$collection=[$item1,$item2,$item4,$item3]; 最佳答案 最简单的方法可能是拼接它,像这样:$collection->splice(2,0,[$item4]);集合通常支持与常规PHP数组相同的功能。在这种情况下,它是array_splice()在幕后使用的函数。通

php - Count Doctrine 的 iterate() Collection Result

有一个QueryBuilder结果$query=$em->createQuery("SELECT....");通过iterate()方法获取它们http://doctrine-orm.readthedocs.org/en/2.0.x/reference/batch-processing.html$objects=$query->iterate();我现在可以foreach($objectsas$object){$object=$object[0];//dosomething..$object->getObjectId();...}但是...//aftertheiterate()call

php - 使用 Laravel Collection 获取重复值

我不想删除重复值,我想获取articles_id重复项并将它们的数量值相加,例如,这是我的收藏:Collection{#306▼#items:array:3[▼0=>CartLine{#294▼+quantity:2+article_id:1728+article_name:"TAZACERAMICA"}1=>CartLine{#296▼+parent_line_id:null+quantity:1+article_id:1728+article_name:"TAZACERAMICA"}2=>CartLine{#298▼+quantity:1+article_id:1378+artic

php - Symfony2 表单集合 : How to remove entity from a collection?

我尝试从集合中删除实体,但它不起作用。我想我在某处有错误,但我不知道在哪里。这是我的updateAction中的代码:$em=$this->getDoctrine()->getEntityManager();$entity=newPerson();if(!$entity){throw$this->createNotFoundException('UnabletofindPersonentity.');}$editForm=$this->createForm(newPersonType(),$entity);$deleteForm=$this->createDeleteForm($id)

php - 扁平化 Laravel Eloquent Collection 关系

我正在使用以下数据库结构:电影-编号-标题导演-编号-姓名电影导演-director_id-电影编号模型是这样设置的:电影.phpnamespaceApp;useIlluminate\Database\Eloquent\Model;classMovieextendsModel{public$table="movie";/***Therolesthatbelongtotheuser.*/publicfunctiondirectors(){return$this->belongsToMany('App\Director','movie_director');}}Director.phpna

php - 我如何在 PHP 中声明 'sub-objects'

我对PHP中的OOP比较陌生,我不确定我正在尝试做的事情是否可行或是否值得推荐。无论如何,我想不通。如果能提供任何可能有帮助的教程或文档,我将不胜感激-我不希望在这里得到完整的答案。我有一个系统,其中每个用户都有许多“库”。每个库都包含一些“元素”。数据库设置如下:user_libraries-id(unique)-user_id(identifiesuser)-name(justastring)elements-id(unique)-content(astring)library_elements-id(unique)-library_id-element_idlibrary_id是