我正在使用 faker 来获取虚拟数据并尝试添加 100 万条记录。不知何故,我只能达到大约 100000 行,以下是我的代码
$no_of_rows = 1000000;
for( $i=1; $i <= $no_of_rows; $i++ ){
$user_data[] = [
'status' => 'ACTIVE',
'username' => $faker->userName,
'email' => $faker->email,
'password' => $password,
'firstname' => $faker->firstName,
'surname' => $faker->lastName,
'mobilenumber' => $faker->phoneNumber,
'confirmed' => (int)$faker->boolean(50),
'gender' => $faker->boolean(50) ? 'MALE' : 'FEMALE',
'dob' => $faker->date(),
'address_line_1' => $faker->address,
'address_line_2' => '',
'post_code' => $faker->postcode,
];
}
User::insert($user_data);
Run Code Online (Sandbox Code Playgroud)
我收到以下错误消息
PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted
Run Code Online (Sandbox Code Playgroud)
我已经设置了 ini_set('memory_limit', '1024M'); …
在我的Laravel项目中,我有以下文件夹结构
application/controllers/products.php
application/controllers/products/categories.php
在我的 products.php
class Products_Controller extends Base_Controller {
public $restful = true;
public function get_index()
{
$data['title'] = 'Products List';
return View::make('product.index',$data);
}
}
Run Code Online (Sandbox Code Playgroud)
在我的 categories.php
class Products_Categories_Controller extends Base_Controller{
public $restful = true;
public function get_index(){
$data['title'] = "All Categtories";
return View::make('category.index', $data);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的 routes.php
Route::get('products', array('as' => 'products', 'uses' => 'products@index'));
Route::get('products/categories', array('as' => 'categories', 'uses' => 'categories@index'));
Run Code Online (Sandbox Code Playgroud)
当我浏览时example.com/products/categories,我收到了404错误消息.我的错了routes.php
我有一个带有复选框的表单,用于接受TOS.问题是我需要为此复选框添加自定义错误,
<form>
<input type="text" name="fname" placeholder="Name" /><?php echo form_error('fname') ?>
<input type="text" name="email" placeholder="Email" /><?php echo form_error('email') ?>
<input type="text" name="password" placeholder="Password" /><?php echo form_error('password') ?>
<input type="checkbox" name="accept_terms" value="yes" /> Accept TOS<br>
<?php echo form_error('accept_terms') ?>
</form>
Run Code Online (Sandbox Code Playgroud)
PHP
<?php
$this->form_validation->set_rules('fname','First Name','trim|required|xss_clean');
$this->form_validation->set_rules('email','Email','trim|required|xss_clean|valid_email');
$this->form_validation->set_rules('password','Password','trim|required|xss_clean');
$this->form_validation->set_rules('accept_terms','TOS','trim|required|xss_clean'); // Need to add custom error message
if ( $this->form_validation->run() === TRUE ) {
}else{
}
?>
Run Code Online (Sandbox Code Playgroud)
当用户没有选择TOS时,我不得不说
请阅读并接受我们的条款和条件.
注意:我添加form_error了显示单个错误的功能
我有一个按钮,可以在点击时执行某些操作.例如
$(function() {
$('button1').click(function(e){
/** This is just a pseudocode
if( me.triggering ) {
doTrigger();
}else{
doClick();
}
**/
})
$('button2').click(function(e){
$('button1').trigger('click')
})
});
Run Code Online (Sandbox Code Playgroud)
如何通过来电trigger或用户点击来判断事件是否正在执行?
嗨这是我的2D数组格式.我想删除第一个内部数组.
Array
(
[0] => Array
(
[0] => Array
(
[type] => section-open
)
)
[1] => Array
(
[0] => Array
(
[type] => section-close
)
)
)
Run Code Online (Sandbox Code Playgroud)
我想删除所有内部数组并像这样返回它
Array
(
[0] => Array
(
[type] => section-open
)
[1] => Array
(
[type] => section-close
)
)
Run Code Online (Sandbox Code Playgroud)
我试过array_shift功能它不起作用......
当我发送AJAX请求时,如果成功则返回一个值.例如
$('#content').load(url, function (info) {
})
Run Code Online (Sandbox Code Playgroud)
在此代码info中返回HTML页面源.
<!DOCTYPE html>
<html lang="en-US" dir="ltr" autopagermatchedrules="1">
<head>
<body class="single single-post postid-1 single-format-standard logged-in admin-bar single-author singular two-column right-sidebar" linkifying="true">
</html>
Run Code Online (Sandbox Code Playgroud)
我怎样才能获得正文类名称.