我将 XAMPP 从 7.1.24 升级到 7.4.2。首先我使用卸载我的 XAMPP uninstall.app,然后安装我的新 XAMPP,然后我检查我的 phpmyadmin 一切看起来都正常。但是当我打开我的一个数据库时它说Table doesn't exists in engine。我试图删除它所说的数据库
#1558 - Column count of mysql.proc is wrong.
Expected 21, found 20.
Created with MariaDB 100108, now running 100411.
Please use mysql_upgrade to fix this error
Run Code Online (Sandbox Code Playgroud)
我搜索 mysql_upgrade 人们说只需在终端或 cmd 上编写即可。我尝试过,但它说command not found我发现人们说我应该这样做export PATH=${PATH}:/usr/local/mysql/bin,~/.bash_profile但问题是没有 mysql 文件夹/usr/local/。我应该怎么办?我使用的是 macOS 10.15.2。
在 php 上,我可以使用此代码获取我的商品 db 上的商品数量
$total = 0;
$sql = "select count(*) as total from goods";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$total = $row['total'];
}
}
echo $total;
// example return 5
Run Code Online (Sandbox Code Playgroud)
我可以在 Laravel 上这样做吗?如果我在控制器上使用此代码
function show(Request $request){
$c = DB::select("SELECT count(*) as total FROM goods");
if($c > 0 ): a ? b;
}
Run Code Online (Sandbox Code Playgroud)
它会收到错误消息,因为它会在数组中返回 JSON。有没有更好的方法来做到这一点?或者如何从控制器内部的 $c 中获取总数
我想以不同的方式显示公司列表,有没有办法使用 eloquent?这段代码不起作用
public function create()
{
$goods = goods::all();
$company = company::all()->distinct('name')->get();
return view('pages.purchaseCreate',['goods' => $goods, 'company' =>$company]);
}
Run Code Online (Sandbox Code Playgroud)
这是错误消息
方法 Illuminate\Database\Eloquent\Collection::distinct 不存在。
我遇到这个问题,如果我手动输入它,我需要获取这种 url,localhost:8000/purchaseOrder/3/purchase/1
它可以工作,但是当我让 laravel 自动创建 url 时,它会出错并最终得到localhost:8000/purchaseOrder/$data-%3Eid/payable/$p-%3Eid
这是我的路线
Route::get('/purchaseOrder/{id}/payable/{he}', 'AjaxController@purchaseOrder');
Run Code Online (Sandbox Code Playgroud)
这是我的控制器(到目前为止我想要的只是响应我给出的网址)
function purchaseOrder($id,$he)
{
echo $id." | ".$he;
}
Run Code Online (Sandbox Code Playgroud)
这是我的观点
<a href="{{ url('purchaseOrder/$data->id/payable/$p->id') }}"><button type="button" class="btn btn-success btn-sm my-1" name="button">Create Purchase Order</button></a><br>
Run Code Online (Sandbox Code Playgroud) 我有一个需要基于进行拼接的字符串,
x = '1,0.5,3'
y = x.split(',')
print(y)
//Result
//['1','0.5','3']
Run Code Online (Sandbox Code Playgroud)
我想拆分字符串,但获取数字数组作为返回值。
预期收益
[1,0.5,3]
Run Code Online (Sandbox Code Playgroud)