所以我使用Zend_Auth来验证我的网站用户.目前,他们只能使用他们的电子邮件登录登录,但我想让他们也使用他们的用户名登录.
这是一些代码:
// prepare adapter for Zend_Auth
$adapter = new Zend_Auth_Adapter_DbTable($this->_getDb());
$adapter->setTableName('users');
$adapter->setIdentityColumn('email');
$adapter->setCredentialColumn('password_hash');
$adapter->setCredentialTreatment('CONCAT(SUBSTRING(password_hash, 1, 40), SHA1(CONCAT(SUBSTRING(password_hash, 1, 40), ?)))');
$adapter->setIdentity($request->getParam('email'));
$adapter->setCredential($request->getParam('password'));
Run Code Online (Sandbox Code Playgroud)
注意这一行:
$adapter->setIdentityColumn('email');
Run Code Online (Sandbox Code Playgroud)
如何在那里添加用户名(数据库中名为username的列)?
更新:
这就是我解决这个问题的方法:
$login = $request->getParam('email');
$validator = new Zend_Validate_EmailAddress();
if (false === $validator->isValid($login)) {
$u = $this->_getTable('Users')->getSingleWithUsername($login);
if (null === $u) {
throw new Exception ('Invalid login and/or password');
}
$login = $u->email;
}
// prepare adapter for Zend_Auth
$adapter = new Zend_Auth_Adapter_DbTable($this->_getDb());
$adapter->setTableName('users');
$adapter->setIdentityColumn('email');
$adapter->setCredentialColumn('password_hash');
$adapter->setCredentialTreatment('CONCAT(SUBSTRING(password_hash, 1, 40), SHA1(CONCAT(SUBSTRING(password_hash, 1, 40), ?)))');
$adapter->setIdentity($login); …Run Code Online (Sandbox Code Playgroud) 我从textarea获取一个字符串并将其爆炸并使用array_map()修剪数组的每一行:
$answers = explode("\n", $data['answers']);
// remove all whitespace such as \r (carriage return)
$asnwers = array_map('trim', $answers);
Run Code Online (Sandbox Code Playgroud)
然后我将每个数组值存储在数据库中的表答案中的单独行中.问题是数据库中每个答案的末尾似乎都有\n字符.当我在HTML中回显这样的答案时:
<?php foreach ($this->answers as $a): ?>
<tr>
<td><?php echo $this->escape($a->body); ?></td>
</tr>
<?php endforreach; ?>
Run Code Online (Sandbox Code Playgroud)
当我看到HTML源代码时,我看到了这个:
<tr>
<td>Some random answer
</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
如您所见,字符串末尾有一个换行符(可能是\n),因为结束标记会移动到下一行.
我做错了什么?
Zend Framework默认只在此路径中查找验证器:
Zend_Validate_: Zend/Validate/
Run Code Online (Sandbox Code Playgroud)
我怎样才能让它看起来像,例如:
My_Validator_: My/Validator/
Run Code Online (Sandbox Code Playgroud)
我在文档中找不到任何关于此问题的信息.
我通常发送范围从3到15 KB的数据包,但有时我需要发送一个大约0.8-0.9 MB的大数据包.在这种情况下,UDP套接字将停止,因为单个数据包大小可能存在一些限制.
如何增加此限制以便我可以发送大包?
这对我来说似乎很荒谬.我应该使用数组还是有其他更好的解决方案?
$('.hoursRange').change(function() {
if ('0' == $(this).val())
{
$(this).val('00');
return false;
}
if ('1' == $(this).val())
{
$(this).val('01');
return false;
}
if ('2' == $(this).val())
{
$(this).val('02');
return false;
}
if ('3' == $(this).val())
{
$(this).val('03');
return false;
}
if ('4' == $(this).val())
{
$(this).val('04');
return false;
}
if ('5' == $(this).val())
{
$(this).val('05');
return false;
}
if ('6' == $(this).val())
{
$(this).val('06');
return false;
}
if ('7' == $(this).val())
{
$(this).val('07');
return false;
}
});
Run Code Online (Sandbox Code Playgroud) 这是我的HTML:
<table>
<tbody><tr>
<td>
<label for="DocumentsName">Názov</label>
</td>
<td>
<input name="DocumentsName" class="input documentsName" value="" style="width: 10em;" type="text">
</td>
</tr>
<tr>
<td>
<label for="DocumentsDescription">Popis</label>
</td>
<td>
<textarea name="DocumentsDescription" id="DocumentsDescription" cols="15" rows="4" class="input" style="width: 340px; font: 1em sans-serif;"></textarea>
</td>
</tr>
<tr>
<td>
<label for="Document1">Doc 1</label>
</td>
<td>
<input name="Document1" class="input document1" style="width: 10em;" type="file">
</td>
</tr>
</tbody></table>
<a href="#" id="addDocumentFileInput">+++++</a>
Run Code Online (Sandbox Code Playgroud)
我想在单击#addDocumentFileInput链接时从表中获取带有type ="file"的最新输入.
返回null.为什么?
<script type="text/javascript">
$(document).ready(function() {
$("#addDocumentFileInput").click(function() {
var $lastFileInput = $(this).prev().children("tr").last().children("input");
alert($lastFileInput.html());
return false;
});
});
</script>
Run Code Online (Sandbox Code Playgroud) 我们有一个这样的表:
<table>
<tr>
<td><input type="text" name="FirstName1" /></td>
<td><input type="text" name="LastName1" /></td>
</tr>
<tr>
<td><input type="text" name="FirstName2" /></td>
<td><input type="text" name="LastName2" /></td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
我想要一个按钮,它将在表的末尾添加新行,并增加名称属性,因此它将如下所示:
<table>
<tr>
<td><input type="text" name="FirstName1" /></td>
<td><input type="text" name="LastName1" /></td>
</tr>
<tr>
<td><input type="text" name="FirstName2" /></td>
<td><input type="text" name="LastName2" /></td>
</tr>
<tr>
<td><input type="text" name="FirstName3" /></td>
<td><input type="text" name="LastName3" /></td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
等等.
到目前为止,我有这个,但它没有增加名称属性:
$("#newRowButton").click(function(){
$("table tr:last").clone().appendTo("table");
});
Run Code Online (Sandbox Code Playgroud) 所以我有一个简单的SQL脚本,它创建了一个简单的库在线目录的数据库模式:
DROP TABLE book_copies;
/
DROP TABLE books_authors_xref;
/
DROP TABLE authors;
/
DROP TABLE books;
/
CREATE TABLE books (
isbn VARCHAR2(13) NOT NULL PRIMARY KEY,
title VARCHAR2(200),
summary VARCHAR2(2000),
date_published DATE,
page_count NUMBER
);
/
CREATE TABLE authors (
name VARCHAR2(200) NOT NULL PRIMARY KEY
);
/
CREATE TABLE books_authors_xref (
author_name VARCHAR2(200),
book_isbn VARCHAR2(13),
CONSTRAINT pk_books_authors_xref PRIMARY KEY (author_name, book_isbn),
CONSTRAINT fk_books_authors_xref1 FOREIGN KEY (author_name) REFERENCES authors (name),
CONSTRAINT fk_books_authors_xref2 FOREIGN KEY (book_isbn) REFERENCES books (isbn)
); …Run Code Online (Sandbox Code Playgroud) 如何在ErrorController中获取控制器和操作名称?我指的是发生异常的控制器和动作.例如,如果我去:
/bogusController/bogusAction
Run Code Online (Sandbox Code Playgroud)
我想得到"bogusController"和"bogusAction".呼叫:
$this->_request->getControllerName();
$this->_request->getActionName();
Run Code Online (Sandbox Code Playgroud)
返回"错误"和"错误".
如果我的脚本抛出异常,我应该返回什么HTTP状态?
200好的
要么
500内部服务器错误
假设用户请求参数是正确的,但我的脚本中存在一个错误,导致出现错误消息而不是正确的响应(XML,JSON或其他格式).什么应该是HTTP状态?
我试图突出显示UICollectionView中具有黄色边框的选定集合单元格,以便用户可以看到当前选择了哪一个.我试过这个:
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
FilterCell *filterCell = (FilterCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"FilterCell" forIndexPath:indexPath];
filterCell.window.backgroundColor = [UIColor yellowColor];
filterCell.backgroundColor = [UIColor yellowColor];
NSLog(@"hello");
}
Run Code Online (Sandbox Code Playgroud)
在UICollectionViewCell内的UIImageView周围有2个空像素,所以它应该可以工作,但事实并非如此.
它正在记录"你好",但边框保持黑色.看这个截图:

所以这是我的JavaScript:
我有一个Cat对象,它扩展了Mammal的原型.哺乳动物有run()方法.但是当我创建新的Cat对象并调用run()时,它告诉我它未定义:
function Mammal(config) {
this.config = config;
}
Mammal.prototype.run = function () {
console.log(this.config["name"] + "is running!");
}
function Cat(config) {
// call parent constructor
Mammal.call(this, config);
}
Cat.prototype = Object.create(Mammal);
var felix = new Cat({
"name": "Felix"
});
felix.run();
Run Code Online (Sandbox Code Playgroud)
知道为什么吗?
这是我的模型:
class User(models.Model):
email = models.EmailField(db_index=True, unique=True)
password = models.CharField(max_length=160, blank=True)
Run Code Online (Sandbox Code Playgroud)
即使电子邮件无效,此代码也不会引发 ValidationError:
user = User(email='invalid e-mail address', 'password'='password_hash')
user.save()
Run Code Online (Sandbox Code Playgroud)
为什么?
javascript ×4
jquery ×3
php ×3
c++ ×1
django ×1
http ×1
http-status ×1
ios ×1
objective-c ×1
oracle ×1
plsql ×1
sql ×1
sqlplus ×1
udp ×1