我在Docker容器中运行MySQL 8.0以进行本地开发.Web容器可以很好地连接到mysql.当试图从Sequel Pro访问我的数据库时,容器给我一个错误,
db_1 | mbind: Operation not permitted
应该注意的是,连接MySQL Workbench不会导致容器抛出该错误,但它也没有完全连接.它确实显示数据库和表,但无法查询表.我在下面列出了Sequel Pro的错误.
NSInvalidArgumentException
-[_NSInlineData isEqualToString:]: unrecognized selector sent to instance 0x608000039740
(
0 CoreFoundation 0x00007fff3cae52fb __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fff63452c76 objc_exception_throw + 48
2 CoreFoundation 0x00007fff3cb7dda4 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x00007fff3ca5b670 ___forwarding___ + 1456
4 CoreFoundation 0x00007fff3ca5b038 _CF_forwarding_prep_0 + 120
5 Sequel Pro 0x000000010002fce3 -[SPDatabaseDocument setDatabases:] + 783
6 Sequel Pro 0x000000010002f2a9 -[SPDatabaseDocument setConnection:] + 610
7 Foundation 0x00007fff3eb56985 __NSThreadPerformPerform + 334
8 CoreFoundation 0x00007fff3ca7d821 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + …Run Code Online (Sandbox Code Playgroud) 尝试使用Codeception Web Driver和Selenium通过验收测试来模拟ajax.我正在使用PhpBrowser,但当我遇到Ajax问题时,我的朋友建议使用WebDriver.
启用它并下载selenium(并运行它)后,我收到以下错误.
[WebDriverCurlException]
Curl error thrown for http POST to http://127.0.0.1:4444/wd/hub/session
with params: {"desiredCapabilities":{"browserName":"googlechrome"}}
Failed to connect to 127.0.0.1 port 4444: Connection Refused
Run Code Online (Sandbox Code Playgroud)
我确定我在4444端口运行selenium.
java -jar selenium-server.jar -port 4444
Run Code Online (Sandbox Code Playgroud)
acceptance.suite.yml如下
class_name: AcceptanceTester
modules:
enabled:
- WebDriver
- REST
config:
WebDriver:
url: 'http://life1605.dev'
browser: googlechrome
REST:
url: 'http://life1605.dev'
Run Code Online (Sandbox Code Playgroud) 我需要运行一个返回多行并将其导出为CSV的查询.我必须按照一定的顺序放置细胞.
所以,让我说我的桌子是id,姓名,地址,妻子.我需要按照id,address,wife,name的顺序构建一个csv.我想我可以按照正确的顺序制作一个数组,然后用它制作一个csv但是经过一个小时的谷歌搜索我无法找到如何用数组制作一个csv.
有fputcsv但需要预先制作的csv.此外,我希望有一个codeigniter方式来做到这一点.
public function export() {
$this->load->helper('download');
$data[1] = 'i like pie';
$data[2] = 'i like cake';
force_download('result.csv', $data);
}
Run Code Online (Sandbox Code Playgroud)
我试过了,但错误说下载帮助文件期望字符串不是数组.
我的 chrome 扩展后台脚本没有被加载。我为他们遵循了 Google 的指南,但仍然一无所获。我不确定是否有另一种检查方法,但它不在 Inspect Element 中,并且脚本应该执行的操作没有发生。
http://developer.chrome.com/extensions/background_pages.html
manifest.json 文件
{
"manifest_version": 2,
"name": "WebDevFriend",
"description": "blah blah blah",
"version": "1.0",
"permissions": [
"bookmarks",
"tabs",
"http://*/*" ],
"background": {
"scripts": ["js/settings.js"],
},
"browser_action": {
"default_icon": "images/icon.png",
"default_popup": "html/popup.html"
}
}
Run Code Online (Sandbox Code Playgroud)
settings.js 文件
chrome.windows.onCreated.addListener(function(window){
chrome.windows.getAll(function(windows){
var length = windows.length;
if (length == 2) {
chrome.tabs.executeScript(null, {file: "content_script.js"});
}
});
});
document.write('hello');
Run Code Online (Sandbox Code Playgroud) 在你-1之前这是一个如此简单的问题,请进一步阅读,因为我花了一段时间搜索并且无法弄明白.我所拥有的是5个选择框.每个结果取决于之前选择的内容.没有提交按钮.我只需要根据前一个框中选择的内容进行更改,到目前为止我已经有了.哦,结果是从数据库中提取的.问题是,当您在框中选择一个选项时,框2显示选项框,但当您再次选择框1中的选项时,它们的选项只会叠加在其他选项上.当它再次改变时我需要它们清除.我会发布我拥有的js,如果你需要其他任何东西,请问.
ps我正在使用php-mysql获取选项.pss这个网站必须在明天完成,所以我有点匆忙.请不要浪费时间告诉我这是一个愚蠢的问题或什么不是.
在此先感谢您的帮助.
$(function () { //When the page is finished loading run this code
$('#country').change(function () {
$.ajax({
url: "<!--Base url taken out-->/discovery/aLoad",
success: function (data) {
eval(data);
},
error: function () {
alert('failed');
},
data: {
country: getSelectValues('#country')
},
type: 'POST'
});
});
});
function changeSearchBar (newBar) {
//remove the crap
function ClearOptions(country)
{
document.getElementById('country').options.length = 0;
}
for (var i = 0; i <= newBar.length; i++) {
newBar[i].id = newBar[i][0];
newBar[i].name = newBar[i][1];
$('#group').append(
$('<option></option>').attr('value', newBar[i].id).text(newBar[i].name)
); …Run Code Online (Sandbox Code Playgroud) 我需要检查user_id插入的是否存在.我打算在Codeigniter表单验证中使用回调,但是它们需要在控制器中进行验证的功能.我在多个控制器的许多页面上使用它,所以我想我会在模型中做到这一点.虽然Codeigniter不支持这一点.
http://codeigniter.com/forums/viewthread/205469/
我发现了这个,但每次验证似乎都有很多代码.我正在使用这个很多,所以我不希望每次都有大量的代码.
如何使用尽可能少的代码从模型运行表单验证?
我希望在我的用户模型中更改密码时设置密码.所以我正在使用该模型的启动方法:
<?php
namespace App\Model;
class User extends \Illuminate\Database\Eloquent\Model
{
protected $table = 'users';
public static function boot()
{
//die('here'); // this happens
User::saving(function ($user) {
//die('here'); // this doesn't happen
if ($user->isDirty('password')) {
$user->password = // hash password...
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
我在模型上使用save()方法在数据库中创建条目,显然这应该触发创建事件.我已经清空数据库表以确保正在创建一个新行(它是),此事件不会触发 - 并且我的密码是未加密的.顺便说一句,我在我的应用程序(不是Laravel)中使用illuminate/database ^ 5.2.
UPDATE - 胶囊初始化
$capsule = new Illuminate\Database\Capsule\Manager;
$capsule->addConnection([
'driver' => 'mysql',
'host' => 'localhost',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'database' => 'mydb',
'username' => 'myuser',
'password' => 'mypass',
]); …Run Code Online (Sandbox Code Playgroud) 排队很新,所以要温柔.据我所知,$job->release()应该把工作重新放回队列.我目前有以下代码,但它只通过队列运行一次.我需要能够运行它最多5次,如果它再次失败,删除它或其他东西.
工人:
public function fire($job, $data)
{
if ($job->attempts() < 5) {
\Log::error($job->attempts());
$job->release();
}
}
Run Code Online (Sandbox Code Playgroud)
推!:
Queue::push(
'ClassName',
[
'path' => $path;
]
Run Code Online (Sandbox Code Playgroud)
尝试在本地进行同步.尝试运行队列:监听和队列:工作,然后运行推送代码.仅记录1个条目.如果您需要更多信息,请告诉我.
我有一个查询正在提取ID列表.这些ID在一个数组中,我需要搜索具有这些ID的另一个表.我尝试使用implode使这些ID成为我可以在where子句中使用的字符串,但我一直收到此错误.
我目前的代码是:
$query = $this->db->query('
SELECT *
FROM system_scoperights
WHERE user = '. $this->session->userdata('username') .'
');
foreach ($query->result() as $row) {
$scope = $row->site;
$data[] = $scope;
}
$dataScope[] = $data;
$idList = implode(',', $dataScope); <---- Error Line
$where = 'WHERE scope_scopes.sc_ID IN '. $idList .'';
Run Code Online (Sandbox Code Playgroud)
我尝试过在论坛上发现的不同内容:
$idList = implode(',', array_values($dataScope));
Run Code Online (Sandbox Code Playgroud)
和
$idList = implode(',', join($dataScope));
Run Code Online (Sandbox Code Playgroud)
但这些都不起作用.(我甚至从未听说过连接功能)
在此先感谢您的帮助.
我是drupal的新手,我需要查询一个表并将该查询的结果作为变量传递给我的page.tpl文件.我已经尝试了几个小时,但没有找到工作.
template.php中的php代码
<?php
$result = db_select("SELECT COUNT(node.nid) AS num FROM node WHERE node.type = 'service'");
foreach ($result as $record) {
$number = $record->num;
}
return $number;
Run Code Online (Sandbox Code Playgroud)
我甚至尝试添加一个,echo 'hello world';但也没有出现.
page.tpl中的代码
<?php if ($number > 0) { ?>
testing
<?php } ?>
Run Code Online (Sandbox Code Playgroud)
有两个类型为服务的节点.任何帮助都会很棒.谢谢.
我正在使用我网站上的Chosen Select Box Jquery插件.select中的选项使用ajax更新,因此当您在1框中选择某些内容时,将显示下一个框的选项.
我几乎让它工作,但当我点击第二个框选项时,第三个框选项不显示.我在FireBug中遇到错误说:
TypeError:item未定义
item.selected = true;
它说它在Chosen Box的js文件中.
JS =======================
Chosen.prototype.result_select = function(evt) {
var high, high_id, item, position;
if (this.result_highlight) {
high = this.result_highlight;
high_id = high.attr("id");
this.result_clear_highlight();
if (this.is_multiple) {
this.result_deactivate(high);
} else {
this.search_results.find(".result-selected").removeClass("result-selected");
this.result_single_selected = high;
this.selected_item.removeClass("chzn-default");
}
high.addClass("result-selected");
position = high_id.substr(high_id.lastIndexOf("_") + 1);
item = this.results_data[position];
item.selected = true; <---------- Error
this.form_field.options[item.options_index].selected = true;
if (this.is_multiple) {
this.choice_build(item);
} else {
this.selected_item.find("span").first().text(item.text);
if (this.allow_single_deselect) this.single_deselect_control_build();
}
if (!(evt.metaKey && this.is_multiple)) this.results_hide();
this.search_field.val(""); …Run Code Online (Sandbox Code Playgroud) 我有一个帐户创建表单.没有提交按钮,只有一个<button>.现在,当单击按钮时,我运行了jQuery验证.正在运行验证并显示正确的错误,然后提交表单并重新加载页面.即使我没有提交按钮,也没有jQuery submit()功能.
HTML:
<form id="accountCreate" method="POST" action="<?=site_url('account/create')?>">
<h3>Create an Account</h3>
<ul>
<li><input type="text" name="email" placeholder="Email..." /></li>
<li><input type="password" name="password" placeholder="Password..." id="password" /></li>
<li><input type="password" placeholder="Verify Password..." id="verifyPassword" /></li>
<li><button id="button">Create</button></li>
</ul>
</form>
Run Code Online (Sandbox Code Playgroud)
JS:
$(document).ready(function() {
$('#button').click(function() {
var password = $('input#password').val();
var passwordV = $('input#passwordVerify').val();
if (password.length >= 6 && password.length <= 24) {
if (password == passwordV) {
} else {
$('div#error').css('display', 'inline');
$('div#error span.errorMessage').text('hey');
}
} else {
alert('yo');
return false;
}
});
});
Run Code Online (Sandbox Code Playgroud) php ×4
codeigniter ×3
jquery ×3
arrays ×2
javascript ×2
ajax ×1
callback ×1
csv ×1
curl ×1
docker ×1
download ×1
drupal ×1
drupal-7 ×1
eloquent ×1
firebug ×1
forms ×1
html ×1
html-select ×1
implode ×1
laravel ×1
laravel-4 ×1
model ×1
mysql ×1
onchange ×1
push-queue ×1
queue ×1
selenium ×1
string ×1
sync ×1
testing ×1
validation ×1
variables ×1
webdriver ×1