- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我想在 $items
数组中添加新元素,出于某些原因我不想使用连接。
$items = DB::select(DB::raw('SELECT * FROM items WHERE items.id = '.$id.' ;'));
foreach($items as $item){
$product = DB::select(DB::raw(' select * from product
where product_id = '. $id.';' ));
$item->push($product);
}
我该怎么办?
最佳答案
看起来你的一切都是正确的according to Laravel docs , 但是你打错了
$item->push($product);
应该是
$items->push($product);
push
方法将一个项目附加到集合的末尾:
我还想认为您正在寻找的实际方法是 put
$items->put('products', $product);
put
方法在集合中设置给定的键和值
关于php - 在 Laravel 集合对象中添加新元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33828769/
我正在用 Java 编写代码,并且使用 Vaadin 8 扩展。 我有一个 Vaadin 组合盒,效果很好。但我不仅想从组合框中选择项目,还想选择书面输入。这意味着我想使用组合框作为下拉菜单以及文本编
我正在尝试将 AJAX 添加到 JQuery ListView 中并呈黄色闪烁,但我似乎无法使其正常工作。谁能指出我正确的方向? http://jsfiddle.net/zFybm/ 最佳答案 根据
我有这个样式表: .pixel{ position: absolute; height: 10px; width: 10px; background-color: #f
这是我用来将新行推送到容器的一行代码: this.$el.append(new ItemView(item).render().el); 其中item是Backbone.js model,render
我正在尝试在 anguar.js 中制作一些测试应用程序,但遇到了问题。我的 js 文件包含: live = angular.module('live',[]); live.controller('p
如何绑定(bind)页面加载后创建的新元素? 我有这样的东西 system = function() { this.hello = function() { alert
html5 新元素(页眉、导航、页脚等)在 IE 中不工作 最佳答案 您需要包含 HTML5 shiv 脚本以允许在旧版 IE 浏览器中设置 HTML5 元素的样式:http://code.googl
我是一名优秀的程序员,十分优秀!