嗨,我正在尝试合并两个数组,并且还想从最终数组中删除重复值.
这是我的阵列1:
Array
(
[0] => stdClass Object
(
[ID] => 749
[post_author] => 1
[post_date] => 2012-11-20 06:26:07
[post_date_gmt] => 2012-11-20 06:26:07
)
Run Code Online (Sandbox Code Playgroud)
这是我的阵列2:
Array
(
[0] => stdClass Object
(
[ID] => 749
[post_author] => 1
[post_date] => 2012-11-20 06:26:07
[post_date_gmt] => 2012-11-20 06:26:07
)
Run Code Online (Sandbox Code Playgroud)
我array_merge用于将两个数组合并为一个数组.它正在给出这样的输出
Array
(
[0] => stdClass Object
(
[ID] => 749
[post_author] => 1
[post_date] => 2012-11-20 06:26:07
[post_date_gmt] => 2012-11-20 06:26:07
[1] => stdClass Object
(
[ID] => 749
[post_author] …Run Code Online (Sandbox Code Playgroud) 当executing我project和我不知道为什么.
目标是通过使用save Json文本到文本.databasehibernate
Users.java和UsersBooks.java同样是,
Books.java:
@Entity
@Table(name="tblbooks")
public class Books {
@Id
@Column(name = "bookshareId")
private int bookshareId;
@Column(name="author")
private String author;
@Column(name = "availableToDownload")
private int availableToDownload;
@Column(name = "briefSynopsis")
private String briefSynopsis;
@Column(name="category")
private String category;
@Column(name = "completeSynopsis")
private String completeSynopsis;
@Column(name = "contentId")
private int contentId;
@Column(name = "copyright")
private Date copyright;
@Column(name="downloadFormat")
private String downloadFormat;
@Column(name="dtbookSize")
private int dtbookSize;
@Column(name = "freelyAvailable")
private int freelyAvailable; …Run Code Online (Sandbox Code Playgroud) 我的应用程序中有一个数据透视表('offer_usage_detail'),表中有4个字段,如下所示
id int AutoIncrement
user_id int reference to user table
offer_id int reference to offer table
use_date date-time Store date time when user use offer
Run Code Online (Sandbox Code Playgroud)
我需要以d-m-Y H:i格式显示使用报价的用户列表,其中包含日期和时间.
所以我在我的商品模型中添加了以下代码
public function user() {
return $this->belongsToMany('User', 'offer_usage_detail', 'offer_id', 'user_id')->withPivot('use_time');
}
Run Code Online (Sandbox Code Playgroud)
目前我正在使用核心php的date功能strtotime来格式化日期时间,但我想知道是否有任何方法将数据透视表日期时间字段转换为碳对象.
我试图把use_time场中Offer Model的 protected $dates = array('created_at','use_time');,但它并没有奏效.
如果列是日期时间字段,是否可以将额外的数据透视表列转换为碳对象?
我有一个很小的问题,
我想在下拉更改时使用 jQuery 提交我的代码:
$("#mydropDown").change(function(){
$("#myForm").submit();
});
Run Code Online (Sandbox Code Playgroud)
但它没有提交。
我还在 Firebug 控制台中触发了以下代码:
$("#myForm").submit();
Run Code Online (Sandbox Code Playgroud)
它给了我这个输出
[form#myForm]
我不明白有什么问题...:o?
我正在尝试在执行它们之前验证查询,如果查询不是mysql select语句,那么我必须向用户显示消息.
我在此链接中找到了以下正则表达式: 使用正则表达式验证简单选择查询
$reg="/^Select\s+(?:\w+\s*(?:(?=from\b)|,\s*))+from\s+\w+\s+where\s+\w+\s*=\s*'[^']*'$/i";
Run Code Online (Sandbox Code Playgroud)
接下来我写下面的代码,但它总是打印不选择查询($ match每次都是空的)
$string="select * from users where id=1";
preg_match_all($reg,$string,$match);
if(!empty($match)){
echo "select query";
//execute and process result
//$this->user_model->list($string);
}else{
echo "not select query";
//show_message('inv_query');
}
Run Code Online (Sandbox Code Playgroud)
请更正正则表达式以验证sql select语句(select,from,where,join,orderby groupby all in select statement).或者让我知道完成任务的其他好方法.
/*
some sample select statements
select * from users where id=1;
select * from users where id=1 AND name= 'Prabhu';
select * from users where id=1 AND name= 'Prabhu' order by name;
Select * from users where id=1 AND name= 'Prabhu' group by …Run Code Online (Sandbox Code Playgroud) 我遇到了一个非常有趣的问题.我正在尝试使用javascript 设置焦点在输入字段上(没有jquery,我尝试了但也没用)window.onLoad.
看看这个fiddel:setFocusOnLoad
它在Chrome浏览器中运行良好,但在Firefox中没有.在Firefox中有任何问题.我怎么解决.谢谢.
编辑: 这是我在html文件中复制的代码.
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
function onloadFocus(){
var name = document.getElementById('name');
// name.value='window.onload called';
name.focus();
}
window.onload=onloadFocus();
</script>
</head>
<body>
<div><input type='text' value='' id='name' name='name'></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我正在尝试将 laravel 应用程序部署到 aws beanstalk,操作系统是 Amazon Linux 2 AMI。
我已经设置了以下文件:
.ebextensions/01-deploy-script-permission.config
Run Code Online (Sandbox Code Playgroud)
它包含以下代码:
container_commands:
01-storage-link:
command: 'sudo chmod +x .platform/hooks/postdeploy/post-deploy.sh'
Run Code Online (Sandbox Code Playgroud)
和
.platform\hooks\postdeploy/01-post-deploy.sh
Run Code Online (Sandbox Code Playgroud)
它包含以下代码:
php artisan optimize:clear
Run Code Online (Sandbox Code Playgroud)
部署失败,并在 eb-engine.log 文件中显示以下条目
[错误] 执行命令 [app-deploy] - [RunAppDeployPostDeployHooks] 期间发生错误。停止运行该命令。错误:命令 .platform/hooks/postdeploy/post-deploy.sh 失败,错误 fork/exec .platform/hooks/postdeploy/post-deploy.sh:没有这样的文件或目录
我正在开发一个简单的文件上传功能.
我用这个函数上传了三个文件:
这是我的目录结构,我在那里存储我的文件:
ROOT-
-notes-
-demo-
-demo_file1.jpg
-main-
-main_file1.jpg
-thumb-
-manage.php //file which handle uploading code
Run Code Online (Sandbox Code Playgroud)
我正在调用这样的上传功能:
$demo_path="notes\demo";
list($demo_file_name,$error)=upload('demo_file',$demo_path,'pdf');
if($error!=""){
echo 'error-demo'.$error;
exit;
}
//uploading main file
$main_path="notes\main";
list($file_name,$error)=upload('main_file',$main_path,'pdf');
if($error!=""){
echo 'error-main'.$error;
exit;
}
//uploadnig thumbnail
$thumb_path="notes\thumb";
list($thumb_file_name,$error)=upload('file_thumb',$thumb_path,'jpg,gif,jpeg,png');
if($error!=""){
echo 'error-thumb'.$error;
exit;
}
Run Code Online (Sandbox Code Playgroud)
此代码适用于演示文件和主文件,但拇指说错误
error-thumb无法上传文件{filename}:文件夹不存在.
你能帮我解决一下问题吗?
提前致谢.
注意:$ _FILES显示所有三个文件.
php ×4
javascript ×2
laravel ×2
arrays ×1
eloquent ×1
file-exists ×1
file-upload ×1
form-submit ×1
gson ×1
hibernate ×1
html ×1
java ×1
jquery ×1
laravel-4 ×1
postgresql ×1
preg-match ×1
regex ×1
submit ×1
wordpress ×1