与sinatra一起使用(Use whenever with sinatra)
我想和sinatra一起工作。 当我运行when命令时,我得到生成的cron选项卡。 但问题是,在我的sinatra应用程序中,我没有
script/runner
文件,它存在于Rails中。我如何获得这个跑步者,或者是否有一个when命令来生成一个?
谢谢!
I'm trying to get whenever to work with sinatra. When I run the
whenever
command, I get the generated cron tab. But the problem is, that in my sinatra app, I don't have ascript/runner
file, which is present in Rails.How do I get this runner, or is there a whenever command to generate one?
thx!
原文:https://stackoverflow.com/questions/16915457
最满意答案
您可以按降序排列,并接收将成为数据库中最后一行的第一行。 但事情是你以错误的方式存储日期。 正如@Strawberry所提到的那样,它不清楚日期或月份。 我建议你使用mysql datetime选项,那么你可以简单地做我下面发布的代码。 在这种情况下,您可能必须以正确的方式解析每个日期
$englishgrades = StudentHistory::select('date', 'name', 'grade') ->where('subject', 'english') ->groupBy('name') ->orderBy('date','desc') ->get();
You can do descending order and receive first row which is going to be your last row in database. But the thing is you store date in a wrong way. as mentioned by @Strawberry its not clear date or month. I would suggest you to do use mysql datetime option then you can simply do the code I post below. In this case you might have to parse each date for a proper way
$englishgrades = StudentHistory::select('date', 'name', 'grade') ->where('subject', 'english') ->groupBy('name') ->orderBy('date','desc') ->get();
相关问答
更多-
Laravel 5.2中的路由问题(Routing issue in Laravel 5.2)[2023-08-30]
有时由于缓存而出现这类问题。 所以尝试运行: composer dump-autoload 。 如果这不起作用,请尝试使用: sudo composer dump-autoload 。 (因为你使用的是ubuntu) 运行php artisan config:clear或php artisan cache:clear也可能有帮助 Sometimes these kinds of issues arise due to the cache. So try running: composer dump-auto ... -
我不熟悉你where sytnax。 尝试在WHERE子句中为这两个条件中的每一个添加单独的术语: $absen = Absen::with('siswa') ->where('level', '=', 'Siswa') ->where('created_at', '<=', DB::raw('curdate()')) ->get(); 作为一个变体,你也可以使用whereRaw()来处理涉及CURDATE() : $absen = Absen::with('siswa') ...
-
一次获得“批次”电话是获得参赛作品的唯一途径。 如果您认为该方法太慢,则可以通过反馈中心的“开发人员”类别提供反馈。 但是在你决定它太慢之前,你需要定义你的场景的“足够快”,然后用一个分析器测量代码与你的目标对比,并验证这个API造成的缓慢(与其他事情相比)。 Getting a "batch" of calls at a time is the only way to get entries. If you think the method is too slow, you can provide fee ...
-
Laravel 5.2中的“IN”查询(“IN” query in Laravel 5.2)[2023-04-24]
对于第一个查询,您应该替换 ->get(); 同 ->pluck('id'); 使用pluck(),您将获得一组id而不是对象数组。 然后,第二个查询中的错误部分: - > where('userid','in',$ query_first) 有whereIn() : $users = DB::table('tableuser')->whereIn('userid', $query_first)->get(); For first query you should replace ->get(); ... -
如果您使用Eloquent,您将拥有2个模型: Renewal.php
在laravel中搜索5.2(Search in laravel 5.2)[2023-01-12]
1)在视图中添加搜索栏