我有一些现有的数据,我试图更新,在我的应用程序中运行的计划任务的后面.
计划任务获取一些数据,然后将其插入到我的数据库中,这会导致时间戳仅比倒数秒(例如2017-14-03 08:00:02)几秒钟.
我想在更新之前使用它来完善一个select语句.到目前为止我有这个:
SELECT server_name, connected_count, TIME_FORMAT( SEC_TO_TIME( (TIME_TO_SEC(created_at) DIV 60) * 60 ), '%Y-%m-%d %H:%i:%s') AS rounded_time FROM `server_tracking`
Run Code Online (Sandbox Code Playgroud)
这适用于时间,将其四舍五入到最接近的分钟,但它会丢弃日期; 离开我0000-00-00 08:00:00.
我怎样才能更新这个来结束日期呢?
我正在编写一个工匠控制台命令,它循环遍历表中的所有记录并重新生成该表上的字段.
该字段是a hash并且生成为md5()特定字符串的一个.
最初我的代码看起来像这样:
// Get all recipes
$recipes = Recipe::all();
$hashProgress = $this->output->createProgressBar(count($recipes));
// Loop over each recipe and generate a new hash for it
foreach ($recipes as $recipe)
{
$hashString = '';
$hashString .= $recipe->field1;
$hashString .= $recipe->field2;
$hashString .= $recipe->field3;
$hashString .= $recipe->field4;
$hashString .= $recipe->field5;
$hashString .= $recipe->field6;
$hashString .= $recipe->field7;
$extras1Total = $recipe->extras1->sum('amount');
$hashString .= $recipe->extras1->reduce(function ($str, $item) use ($extras1Total) {
return $str . $item->name . ($extras1Total == 0 ? $item->amount : …Run Code Online (Sandbox Code Playgroud) 我不是很流利的Javascript,但我正在尝试使用它来构建一个简单的Web应用程序来尝试学习更多.
我想使用Google Distance Matrix API让我查询两个地址之间的距离.
我有两个输入字段,使用Google的自动完成功能来获取地址,然后我使用place_id地址来查询API.
我相信我需要使用JSONP来调用API并获取数据,但是我在使用响应时遇到问题,并且在控制台中出现以下错误:
未捕获的SyntaxError:意外的令牌:
我一直在寻找,每个人都在使用PHP和JSONP - 但是我想要避免这种情况并保持整个进程的客户端.
如何发出请求然后使用返回的JSON响应?
这是我目前用来发出请求的函数:
function getDistance()
{
//Find the distance
$.getJSON("https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins=place_id:" + $("#autocompleteDeparture").data("place_id") + "&destinations=place_id:" + $("#autocompleteArrival").data("place_id") + "&key=MY_API_KEY0&callback=?", function(data) {
data = JSON.parse(data);
console.log(data);
});
}
Run Code Online (Sandbox Code Playgroud)
如果我检查请求,它正在成功运行并返回正确的JSON数据:
{
"destination_addresses" : [ "9 Coach Ln, Belmont, Lower Hutt 5010, New Zealand" ],
"origin_addresses" : [ "3/30 Rata St, Naenae, Lower Hutt 5011, New Zealand" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "4.9 …Run Code Online (Sandbox Code Playgroud) 我从我的子组件设置我的主要组件的所有上下文,它工作正常,但我不知道这是否正确
这是我的主要组成部分
import Child from "./apps/child";
export default class NewTest extends Component {
constructor(){
super();
this.state={
one:1,
}
}
render() {
return (
<View style={styles.container}>
<Text>{this.state.one}</Text>
<Child root={this}/> //<----- Here i set all the context of my main Component to the child component
<TouchableOpacity onPress={()=>console.log(this.state.one)}>
<Text>Touch</Text>
</TouchableOpacity>
</View>
);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的孩子组成部分
export default class Child extends Component{
constructor(props){
super(props);
this.parent=this.props.root;
}
render(){
return(
<View>
<TouchableOpacity onPress={()=>{
this.parent.setState({one:this.parent.state.one+1}) // <- if you see here i change the state of the …Run Code Online (Sandbox Code Playgroud) javascript ×2
eloquent ×1
jquery ×1
json ×1
laravel ×1
laravel-5 ×1
mysql ×1
php ×1
react-native ×1
reactjs ×1