我有以下非常大的(~10e8记录)表(table):
+--------------------------------+ | id order value | +--------------------------------+ | PK int int | | 1 1 1 | | 2 2 5 | | 3 2 | | 4 2 0 | +--------------------------------+
如您所见,value列只能包含非负整数或null.现在,我需要编写一个返回没有a的订单的查询value > 0(即order = 2不保存条件,因为有记录value = 5).
该反向查询很简单:
SELECT order
FROM table
WHERE value > 0
Run Code Online (Sandbox Code Playgroud)
查询的性能对我来说是令人满意的.
但我们不能写
SELECT order
FROM table
WHERE value = 0
Run Code Online (Sandbox Code Playgroud)
因为有可能有一个具有相同订单的记录,但有value > 0.我能找到写这个查询的唯一方法是:
SELECT order
FROM table
GROUP BY …Run Code Online (Sandbox Code Playgroud) $staffGroup = StaffGroup::where('id', $id)
->with('staffGroupRight')
->first();
Run Code Online (Sandbox Code Playgroud)
在StaffGroup Model:
public function staffGroupRight() {
return $this->hasMany('Modules\Staff\Http\Models\StaffGroupRight');
}
Run Code Online (Sandbox Code Playgroud)
public function staffGroupRight() {
return $this->hasMany('Modules\Staff\Http\Models\StaffGroupRight')->take(5);
}
Run Code Online (Sandbox Code Playgroud)
但它总共给出了5行,staff_group但我希望它能limit用于一个staff_group
有10 staff_group则给出了5条的staffgrouprights为10 staff_group,但我想它5单staff_group
这里staffGroupRight返回data适当id的staff group.
但我想limit在那个with()方法数据中设置.
是否有可能limit在with()方法中设置......?
我正在尝试使用本地化,如下
$types = trans('constants.type');
Run Code Online (Sandbox Code Playgroud)
我创建constants.php了如下文件(在config目录中),这是它的语言文件,
/resources
/lang
/en
constants.php
/es
constants.php
Run Code Online (Sandbox Code Playgroud)
return ['type' => 'Type'];
Run Code Online (Sandbox Code Playgroud)
它在同一格式的其他文件中翻译的方式相同,但这件事给了我以下错误
注意:我在config目录的文件中使用了这个,
(1/1)ReflectionException类转换器不存在
在ReflectionClass中的Container.php(第729行) - 在Container.php(第729行)中的Container.php(第729行)中的Container-> build('translator')在Container.php(第608行)中的Container-> resolve( Container.php中的'translator')(第575行)在Container-> make('translator')
trans()方法不在constants.php我在config目录中创建的文件中工作如下,
/ config constants.php
我想更新 mysql 表的两列,
column1减去某个值并column2乘以某个值,
我从这里做了这样的减量
$stock_obj->decrement('quantity_on_hand', $product_data["quantity"], array(
'total_quantity_on_hand' => 'quantity_on_hand' * some_other_value
));
Run Code Online (Sandbox Code Playgroud)
这里减法有效,但我该如何做乘法呢?
我在 CI(CodeIgniter) 中有这个解决方案,但不知道如何在 laravel 中做到这一点,任何帮助将不胜感激......
$this->db->set("quantity_on_hand", "quantity_on_hand-" . ($product_data["quantity"] ? $product_data["quantity"] : 0), FALSE);
$this->db->set("total_quantity_on_hand", "quantity_on_hand*" . ($product_data['product_packing_value'] ? $product_data['product_packing_value'] : 1), FALSE);
$this->db->where("id", $warehouse_transfer_product_data['stock_id'])->update("stock");
Run Code Online (Sandbox Code Playgroud) 我正在尝试用JavaScript构建计算器.它除了罪和cos之外都有效,它们给出了错误和意想不到的结果.
罪(180)= 0
在代码sin(180)= - 0.8011526357338304

我的代码如下所示,
function d(val){
if(val=="sin"){
var x=document.getElementById("d").value;
document.getElementById("d").value=Math.sin(x);
}
if(val=="cos"){
var x=document.getElementById("d").value;
document.getElementById("d").value=Math.cos(x);
}
if(val=="envers"){
var x=document.getElementById("d").value;
document.getElementById("d").value=eval(1/x);
}
if(val=="sqrt"){
var x=document.getElementById("d").value;
document.getElementById("d").value=Math.sqrt(x);
}
}
function c(val){
document.getElementById("d").value=val;
}
function v(val){
document.getElementById("d").value+=val;
}
function e(){
try {
c(eval(document.getElementById("d").value))
}
catch(e){
c('Error')
}
}
Run Code Online (Sandbox Code Playgroud)
<div class="display">
<p>
<input type="text" readonly size="14" id="d">
<input type="button" class="button black" value="C" onclick='c("")'>
</p>
</div>
<div class="keys">
<p>
<input type="button" class="button black" value="1" onclick='v("1")'>
<input type="button" …Run Code Online (Sandbox Code Playgroud) laravel ×3
eloquent ×2
laravel-5 ×2
angularjs ×1
datepicker ×1
javascript ×1
laravel-5.1 ×1
limit ×1
localization ×1
mysql ×1
php ×1
postgresql ×1
sql ×1