假设我有一个<select id="chat" size="9" />
,我想添加一些optgroup和选项,就像这样
像这样的对象
{friendchat:[{name:"somefriend1",...},{name:"somefriend2",...},
otherchat:[{name:"someother1",...},{name:"someother2",...},
friendrequest:[{name:"somerequest1",...},{name:"somerequest2",...},
sentrequest:[{name:"somesent1",...},{name:"somesent2",...}]
Run Code Online (Sandbox Code Playgroud)
编辑:键入输入而不是选择...
我有一个带有几个表的MYSQL数据库,所有这些表都具有相同的结构.我想搜索所有表以查找具有列的特定值的行.我是否必须逐个搜索表格,或者有更简单的方法?
到目前为止我所做的是 - >我已经在其中创建了一个包和实体类,并使用以下命令从该实体类创建了一个名为"news"的数据库表
php app/console doctrine:schema:update --force
一切顺利.
现在我在其中创建了一个新的bundle和一个其他的实体类,我想在其中创建一个名为"user"的数据库中的另一个表,但是给出了一个错误:"名为'symfony.news'的表已经存在'".
class user {
private $id;
private $userEmail;
public function getId() {
return $this->id;
}
public function setUserEmail($userEmail) {
$this->userEmail = $userEmail;
return $this;
}
}
Run Code Online (Sandbox Code Playgroud) 好的,我有3张桌子:
用户
CREATE TABLE IF NOT EXISTS `users` (
`user_id` int(11) NOT NULL,
`user_username` varchar(25) NOT NULL,
`user_email` varchar(100) NOT NULL,
`user_password` varchar(255) NOT NULL,
`user_enabled` int(1) NOT NULL DEFAULT '1',
`user_staff` varchar(15) NOT NULL DEFAULT '',
`user_account_type` varchar(20) NOT NULL DEFAULT '0',
`user_registerdate` date NOT NULL,
`user_twofactor` int(11) NOT NULL DEFAULT '0',
`user_twofackey` varchar(255) NOT NULL,
`user_forgot_email_code` varchar(255) NOT NULL,
`user_emailverified` varchar(25) NOT NULL DEFAULT 'unverified',
`user_banned` varchar(25) NOT NULL DEFAULT 'unbanned',
`user_has_avatar` int(11) NOT NULL DEFAULT '0',
`user_has_banner` …
Run Code Online (Sandbox Code Playgroud) 我有一个小的声明递减一个值:
UPDATE cart_items SET quantity = quantity - 1
WHERE cart_id = {$cart_id} AND id = {$cart_item_id}
Run Code Online (Sandbox Code Playgroud)
但是如果该值在减量后变为0,那么SQL是否可以删除该行?如果是这样,那么我想重新计算与该购物车匹配的行数:
SELECT FROM cart_items WHERE cart_id = {$cart_id}
Run Code Online (Sandbox Code Playgroud)
如果行数为零,我想从另一个表中删除该记录,如下所示:
DELETE FROM cart WHERE id = {$cart_id}
Run Code Online (Sandbox Code Playgroud)
目前看起来需要几个查询才能做到这一点,但是这一切都可以在一个SQL语句中完成吗?
内部有逻辑是一个好主意__constructor
吗?
public class someClass
{
public function __construct()
{
//some logic here
}
Run Code Online (Sandbox Code Playgroud)
到目前为止,我认为还可以。但是,此reddit评论表明相反。
目前正在使用 elasticsearch 开发标签搜索应用程序,我为索引中的每个文档提供了一个标签数组,以下是文档外观的示例:
_source: {
title: "Keep in touch scheme",
intro: "<p>hello this is a test</p> ",
full: " <p>again this is a test mate</p>",
media: "",
link: "/training/keep-in-touch",
tags: [
"employee",
"training"
]
}
Run Code Online (Sandbox Code Playgroud)
我希望能够进行搜索并且只返回带有所有指定标签的文档。
使用上面的例子,如果我搜索带有标签的文档 ["employee", "training"]
则将返回上述结果。
相反,如果我用标签搜索 ["employee", "other"]
,则不会返回任何内容;搜索查询中的所有标签都必须匹配。
目前我正在做:
query: {
bool: {
must: [
{ match: { tags: ["employee","training"] }}
]
}
}
Run Code Online (Sandbox Code Playgroud)
但我只是收到返回的异常,例如
IllegalStateException[Can't get text on a START_ARRAY at 1:128];
Run Code Online (Sandbox Code Playgroud)
我还尝试连接数组并使用逗号分隔的字符串,但是这似乎与第一个标签匹配的任何内容相匹配。
关于如何解决这个问题的任何建议?干杯
我正在处理遗留项目,试图改进项目结构。我的问题是我应该如何组织代码结构。我看到两个选择:
#1 业务域/层
app/
----accout/
--------application/
--------domain/
--------infrastructure/
----client/
--------application/
--------domain/
--------infrastructure/
----transfer/
--------application/
--------domain/
--------infrastructure/
Run Code Online (Sandbox Code Playgroud)
或#2层/业务域
app/
----application/
--------account/
--------client/
--------transfer/
----domain/
--------account/
--------client/
--------transfer/
----infrastructure/
--------account/
--------client/
--------transfer/
Run Code Online (Sandbox Code Playgroud)
哪种方法更适合遗留项目?根据您的经验,哪个更可取?
从我的角度来看,#1 将在进一步重构期间实现系统解耦。另一方面,对于遗留项目来说,#1 似乎更容易实现。
architecture legacy domain-driven-design directory-structure
mysql ×4
php ×3
sql ×2
architecture ×1
class ×1
connection ×1
constructor ×1
curl ×1
database ×1
debugging ×1
doctrine ×1
email ×1
entity ×1
get ×1
html ×1
javascript ×1
json ×1
legacy ×1
networking ×1
node.js ×1
oop ×1
search ×1
symfony ×1