我是 laravel 的新手,我遇到了 DB 问题。
我通过编辑/etc/mysql/my.cnf文件禁用了 'only_full_group_by' sql_mode 。我sql_mode使用SELECT @@GLOBAL.sql_mode;and检查了 global 和 sessionSELECT @@SESSION.sql_mode;并确认sql_mode不再有only_full_group_by.
但是,当我通过邮递员提出请求时,它给了我错误提示this is incompatible with sql_mode=only_full_group_by。
我感到很困惑。为什么即使在我更改后仍会出现此错误sql_mode?难道我做错了什么?
任何建议或建议将不胜感激。
谢谢你。
使用 toSql() 的 SQL
select A.*
from `A`
inner join `B` on `A`.`id` = `B`.`a_id`
inner join `C` on `C`.`id` = `B`.`c_id`
group by `A`.`id` having COUNT(A.id) > 0;
Run Code Online (Sandbox Code Playgroud) 我是 Laravel 的新手,我对事件的使用有疑问。
据我了解,当发生某些操作(例如注册用户)并处理这些操作(例如发送确认电子邮件)之后的逻辑时,会使用事件。
但我不明白的是,为什么我不能创建一个辅助函数来处理这些操作,而不是创建事件和侦听器文件。
换句话说,使用事件有什么好处?
谢谢你。
我是Laravel的新手.我试图使用Eloquent Model来访问DB中的数据.
我有表与表名相似的表.
所以我想使用一个模型来访问DB中的几个表,但是没有运气.
有没有办法动态设置表名?
任何建议或意见将不胜感激.先感谢您.
模型:
class ProductLog extends Model
{
public $timestamps = false;
public function __construct($type = null) {
parent::__construct();
$this->setTable($type);
}
}
Run Code Online (Sandbox Code Playgroud)
控制器:
public function index($type, $id) {
$productLog = new ProductLog($type);
$contents = $productLog::all();
return response($contents, 200);
}
Run Code Online (Sandbox Code Playgroud)
解决方案对于那些遭受同样问题的人:
我能够通过@Mahdi Younesi建议的方式更改表名.
我能够通过以下方式添加条件
$productLog = new ProductLog;
$productLog->setTable('LogEmail');
$logInstance = $productLog->where('origin_id', $carrier_id)
->where('origin_type', 2);
Run Code Online (Sandbox Code Playgroud) tr我想在的底部加一个边框thead。
我有如下表。我能够将边框放在ths 的底部。然而,这达不到我想要的,因为彼此交叉的两个边框仍然不是黑色的,如下图所示。
table {
border-collapse: collapse;
}
table thead tr th {
border-bottom: 1px solid #000000;
}
table th,
table td {
border: 1px solid #d9d9d9;
}Run Code Online (Sandbox Code Playgroud)
<table>
<thead>
<tr>
<th>
#
</th>
<th>
Date
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
TUB1234
</td>
<td>
2018/02/22
</td>
</tr>
</tbody>
</table>Run Code Online (Sandbox Code Playgroud)
我试图使用Codeigniter作为框架从数据库中获取数据.
我能够提出SQL查询以获得所需的结果,但由于我不熟悉Codeigniter DB语法,我遇到了麻烦.下面是我想要执行的查询.我怎么在PHP中这样做?
任何建议或建议将不胜感激.谢谢.
SELECT A.*, B.*
FROM
(SELECT A.*
FROM DriversInfo as A, InvoiceQueue as B
WHERE A.CreateTime = B.DriverCreateTime
AND B.Error <> 1
GROUP BY A.CreateTime
UNION
SELECT DISTINCT A.*
FROM DriversInfo as A, OrderInfo as B
WHERE A.CreateTime = B.DriverKey
AND B.Invoice <> '0') as A
LEFT JOIN DriversDoc as B
on A.CreateTime = B.DriverCreateTime
WHERE B.DriversLicense is null
OR B.CarRegistration is null
OR B.BizCertificate is null
OR B.Insurance is null;
Run Code Online (Sandbox Code Playgroud)