在我的.htaccess文件中使用这个RewriteRule我得到RewriteRule:Bad flag delimiters,它在浏览器中返回500错误.任何人都可以指出我正确的方向.谢谢.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^dev/(.*)$ http://dev.example.com/$1 [L,R=301, NC]
Run Code Online (Sandbox Code Playgroud)
这是在数字海洋Droplet上的Ubuntu上.
我有一个 Laravel Spark 项目,它使用 Horizon 来管理 Redis 的作业队列。
在本地(在我的 Homestead 盒子、Mac OS 上)一切都按预期工作,但在我们新的 Digital Ocean(Forge 配置)Droplet(内存优化的 256GB、32vCPU、10TB 和 1x 800GB VPS)上,我不断收到错误:
PDOException: Packets out of order. Expected 0 received 1. Packet size=23
Run Code Online (Sandbox Code Playgroud)
或者该错误的某些变体,其中数据包大小信息可能不同。
经过数小时/数天的调试和研究,我在 StackOverflow 和其他地方看到了许多帖子,这些帖子似乎表明可以通过执行以下列出的许多操作来解决此问题:
PDO::ATTR_EMULATE_PREPARES
在我的 database.php 配置中设置为 true。这对问题绝对没有影响,实际上引入了另一个问题,即整数被转换为字符串。
设置DB_HOST
为127.0.0.1
而不是localhost
,以便它使用 TCP 而不是 UNIX 套接字。同样,这没有任何效果。
DB_SOCKET
通过登录 MySQL (MariaDB) 并运行将套接字路径列出为 来设置为 MySQL 中show variables like '%socket%';
列出的套接字路径/run/mysqld/mysqld.sock
。我也离开DB_HOST
设置为localhost
。这也没有效果。我确实注意到的一件事是,pdo_mysql.default_socket
变量设置为/var/run/mysqld/mysqld.sock
,我不确定这是否是问题的一部分?
我已将 MySQL 配置设置大幅增加到/etc/mysql/mariadb.conf.d/50-server.cnf
以下内容: …
有没有人遇到过这个错误:一般错误:1390准备好的语句包含太多占位符
我刚刚通过SequelPro导入超过50,000条记录,现在当我在我的视图中查看这些记录时(Laravel 4)我得到一般错误:1390准备语句包含太多占位符.
我的AdminNotesController.php文件中的下面的index()方法是生成查询和呈现视图的方法.
public function index()
{
$created_at_value = Input::get('created_at_value');
$note_types_value = Input::get('note_types_value');
$contact_names_value = Input::get('contact_names_value');
$user_names_value = Input::get('user_names_value');
$account_managers_value = Input::get('account_managers_value');
if (is_null($created_at_value)) $created_at_value = DB::table('notes')->lists('created_at');
if (is_null($note_types_value)) $note_types_value = DB::table('note_types')->lists('type');
if (is_null($contact_names_value)) $contact_names_value = DB::table('contacts')->select(DB::raw('CONCAT(first_name," ",last_name) as cname'))->lists('cname');
if (is_null($user_names_value)) $user_names_value = DB::table('users')->select(DB::raw('CONCAT(first_name," ",last_name) as uname'))->lists('uname');
// In the view, there is a dropdown box, that allows the user to select the amount of records to show per page. Retrieve that value or set a default.
$perPage …
Run Code Online (Sandbox Code Playgroud) 我一直在文档中查看Laravel 4中的关系,我正在努力解决以下问题.
我的数据库中有一个名为'events'的表.该表具有各种字段,主要包含与其他表相关的ID.例如,我有一个'课程'表.事件表包含一个名为"course_id"的字段,该字段与courses表中"id"字段的ID相关.
所以基本上,我正在讨论如何关联两者(belongsTo()?)然后将连接的数据传递给视图.
这是我到目前为止的地方http://paste.laravel.com/pf3.
我希望你们能够就如何最好地解决这个问题给我一些建议.谢谢.
GAZ
看看我的前端URL生成的Str :: slug,但只是想知道你们如何用路由等来实现它,例如,你们如何将http://www.example.com/courses/1更改为http ://www.example.com/courses/this-course
我有一个数据库种子文件:
class ContactTableSeeder extends Seeder {
public function run()
{
$contacts = array(
array(
'first_name' => 'Test',
'last_name' => 'Contact',
'email' => 'test.contact@emai.com',
'telephone_number' => '0111345685',
'address' => 'Address',
'city' => 'City',
'postcode' => 'postcode',
'position' => 'Director',
'account_id' => 1
)
);
foreach ($contacts as $contact) {
Contact::create($contact);
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行php artisan migrate时:refresh --seed它为数据库播种并在contacts表中创建相关记录,除了它没有用种子数组中的任何信息填充字段.我对其他表使用完全相同的语法并且它们工作正常,我还彻底检查了每个字段以确保它们与数据库字段匹配,但无论我做什么它都不会正确播种.
有没有人有任何想法?
我的联系人模型中有这个:
public static function contacts($perPage = 10)
{
$order_type = '.desc';
$order = Session::get('contact.order', 'first_name' . $order_type); // Set the default order to created_at DESC
$order = explode('.', $order);
$columns = array(
'contacts.id as id',
'contacts.first_name as first_name',
'contacts.last_name as last_name',
'contacts.telephone_number as telephone_number',
'contacts.email as email',
'accounts.company_name as account',
'users.first_name as am_first_name',
'users.last_name as am_last_name'
);
$contacts = DB::table('contacts')
->leftJoin('accounts', 'account_id', '=', 'accounts.id')
->leftJoin('account_managers', 'accounts.account_manager_id', '=', 'account_managers.id')
->leftJoin('users', 'user_id', '=', 'users.id')
->orderBy($order[0], $order[1])
->paginate($perPage, $columns);
return $contacts;
}
Run Code Online (Sandbox Code Playgroud)
它没有将我的'as'语句分配给我想要的列,这意味着我得到'列first_name是不明确的. …
我有一个噩梦得到一个crontab/cronjob来运行Artisan命令.
我有通过cronjob运行的另一个Artisan命令没有问题但是第二个命令不会运行.
首先,当我执行'crontab -e'并编辑要包含的文件时:
0 0 * * * /usr/local/bin/php /home/purple/public_html/artisan feeds:send
Run Code Online (Sandbox Code Playgroud)
cronjob根本不运行.
如果我去cPanel并在那里添加cronjob,它运行但我收到以下错误:
open(public/downloads/feeds/events.csv): failed to open stream: No such file or directory
Run Code Online (Sandbox Code Playgroud)
问题是文件存在且目录具有正确的权限.如果我以root身份通过SSH登录或者用户紫色(php artisan feeds:send)运行命令,该命令运行完美并完成其任务没有问题.
如果在cPanel中,我编辑cronjob使用:
0 0 * * * php /home/purple/public_html/artisan feeds:send
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
There are no commands defined in the "feeds" namespace.
Run Code Online (Sandbox Code Playgroud)
有趣的是,我的其他命令在crontab文件中注册并且工作,并且在cPanel中根本没有引用.
任何帮助将非常感激.为简洁起见,我已经包含了命令使用的命令和模型.
Feed.php型号:
DataFeedController.php控制器:
SendFeeds.php命令:
启动/ artisan.php:
FeedInterface.php接口:
正如您所看到的,有一个GetRates命令,它可以工作.
我在视图中有一个用于删除记录的表单,我想要一个确认对话框,以显示何时单击删除按钮.在我看来,我有这个:
{{ Form::model($event, array('route' => array('events.destroy', $event->id), 'method' => 'Delete')) }}
{{ Form::submit('Delete', array('class' => 'btn-small btn-danger delete-event', 'data-toggle' => 'modal', 'data-title' => 'Delete Event', 'data-content' => 'Are you sure you want to delete this event?')) }}
{{ Form::close() }}
Run Code Online (Sandbox Code Playgroud)
我希望能够获取数据属性并使用jQuery动态填充Twitter Bootstrap模式对话框,但我不确定如何处理这个问题.
你们会做什么?基本上,当点击删除按钮时,我想要一个模态窗口,其中包含数据属性的标题和内容,以及取消按钮和删除按钮.如果用户点击删除按钮,我想提交表单.
请注意,此视图包含一个记录表,每个记录都有一个删除表单/按钮,这一点很重要.
真的很感谢你对这一个人的帮助.干杯.
编辑:我现在有这个,几乎可以工作,但它没有提交表格?
$('.delete-event').click(function(event) {
event.preventDefault();
var title = $(this).attr('data-title');
var content = $(this).attr('data-content');
$('#event-modal').html(title);
$('.modal-body p').html(content);
$('.modal-footer .delete').html(title);
$('#event-delete').modal('show');
$('.delete').click(function(event) {
$('#event-delete').modal('toggle');
$('.delete-event').submit();
});
});
Run Code Online (Sandbox Code Playgroud) 我在http://www.harmonics.co.uk有一个Magento商店,我在产品上有PinIt按钮.
问题是当您单击它时,即使URL正确,它也不会从查询字符串中的media属性中获取图像.
我正在使用以下代码生成我的图像和产品页面上的PinIt按钮:
<?php
$_helper = $this->helper('catalog/output');
$_product = $this->getProduct();
$image = $this->helper('catalog/image')->init($_product, $_product->getImageUrl(), 'image')->resize(150, 150);
?>
// PinIt Anchor
<a class="pinterest" href="http://pinterest.com/pin/create/button/?url=<?php echo $_product->getProductUrl(); ?>&media=<?php echo $image; ?>&description=<?php echo $_product->getName(); ?>" title="Share on Pinterest"> </a>
Run Code Online (Sandbox Code Playgroud)
它曾经工作,但我认为Pinterest改变了按钮的工作方式,但我看不出如何.生成的代码看起来几乎相同,除了生成的URL替换:%3A和/%2F.
我已经尝试过替换字符串,但这也不起作用.任何想法的人.干杯.
作为Laravel 4的新手,我想听听你的意见.
我正在为资源控制器的编辑方法创建一个编辑视图,并想知道如何处理从数据库中获取该记录到表单控件的正确数据,例如选择框和输入等?
任何人都可以给我任何指示吗?谢谢.
我试图从 Xpath 查询返回一些结果,但它不会正确选择元素。我正在使用以下代码:
public function getTrustPilotReviews($amount)
{
$trustPilotUrl = 'https://www.trustpilot.co.uk/review/purplegriffon.com';
$html5 = new HTML5;
$document = $html5->loadHtml(file_get_contents($trustPilotUrl));
$document->validateOnParse = true;
$xpath = new DOMXpath($document);
$reviewsDomNodeList = $xpath->query('//div[@id="reviews-container"]//div[@itemprop="review"]');
$reviews = new Collection;
foreach ($reviewsDomNodeList as $key => $reviewDomElement)
{
$xpath = new DOMXpath($reviewDomElement->ownerDocument);
if ((int) $xpath->query('//*[@itemprop="ratingValue"]')->item($key)->getAttribute('content') >= 4)
{
$review = [
'title' => 'Test',
'author' => $xpath->query('//*[@itemprop="author"]')->item($key)->nodeValue,
'date' => $xpath->query('//*[@class="ndate"]')->item($key)->nodeValue,
'rating' => $xpath->query('//*[@itemprop="ratingValue"]')->item($key)->nodeValue,
'body' => $xpath->query('//*[@itemprop="reviewBody"]')->item($key)->nodeValue,
];
$reviews->add((object) $review);
}
}
return $reviews->take($amount);
}
Run Code Online (Sandbox Code Playgroud)
此代码不会返回任何内容:
//div[@id="reviews-container"]//div[@itemprop="review"]
Run Code Online (Sandbox Code Playgroud)
但如果我把它改成:
//*[@id="reviews-container"]//*[@itemprop="review"]
Run Code Online (Sandbox Code Playgroud)
它部分有效,但不会返回正确的结果。
laravel-4 ×8
laravel ×7
mysql ×2
php ×2
apache ×1
belongs-to ×1
blade ×1
button ×1
cron ×1
crontab ×1
domdocument ×1
domxpath ×1
edit ×1
eloquent ×1
friendly-url ×1
magento ×1
media ×1
migrate ×1
mod-rewrite ×1
modal-dialog ×1
paginate ×1
pdo ×1
pinterest ×1
query-string ×1
seeding ×1
slug ×1
sockets ×1
string ×1
ubuntu ×1
url ×1
view ×1
xpath ×1