小编xda*_*azz的帖子

Mysql外键约束不起作用

嗨,大家好,我只是在子表中创建父表的外键引用.当我尝试从父表中删除其子表中引用的行时,令人惊讶的是它允许我删除它.我试图通过写删除限制来创建子表,也没有它但没有帮助.任何想法为什么会这样?.Below是我在创建表时使用的代码.

CREATE TABLE region
(
id int PRIMARY KEY AUTO_INCREMENT,
name varchar(50) NOT NULL
);

CREATE TABLE aggregator
(
id int PRIMARY KEY AUTO_INCREMENT,
name varchar(50) NOT NULL
);

CREATE TABLE gateway
(
id int PRIMARY KEY AUTO_INCREMENT,
name varchar(50) NOT NULL,
region_id int ,
aggregator_id int ,
is_public boolean  DEFAULT 0 NOT NULL,
FOREIGN KEY (region_id) REFERENCES region(id),
FOREIGN KEY (aggregator_id) REFERENCES aggregator(id)
);
Run Code Online (Sandbox Code Playgroud)

mysql foreign-key-relationship

4
推荐指数
1
解决办法
3214
查看次数

$(this)的值随确认而变化

我想知道为什么$(this)不按照我期望的方式工作?在下面的代码中,单击"删除图像"时没有任何反应.如果您注释掉确认语​​句,则单击"删除图像"时背景将变为绿色.你知道为什么吗?$(this)由于确认声明,它似乎指向其他东西.提前致谢!

<a href="#" class='thumbnail the-one delete-file'><i class="icon-remove"></i>Remove Image</a>

$('.the-one').click(function(){
    if(confirm("What do you say?")) { return true;} else {return false;}
    $(this).css("background", "green");

});
Run Code Online (Sandbox Code Playgroud)

jquery

4
推荐指数
2
解决办法
64
查看次数

使用jquery在其中按整数拆分字符串

我有很长的字符串

"When I was 10 year old"
Run Code Online (Sandbox Code Playgroud)

我必须将此字符串拆分为数组:["When I was", "10" , "year old"].

在不同情况下整数可以不同,并且句子也可以改变.

简而言之,我希望将整数字符串拆分为可能吗?

我怎样才能在Jquery/java-script中使用正则表达式与split进行共轭

javascript regex jquery

4
推荐指数
1
解决办法
2077
查看次数

变量定义但不能在javascript中工作,而这个代表窗口

我在下面有一个小代码片段

var foo = {
    bar: function () {
        return this.baz;
    },
    baz: 1
};
(function () {
    return typeof arguments[0]();
})(foo.bar);
baz = 1;
//result undefined
Run Code Online (Sandbox Code Playgroud)

foo.bar函数执行时,this指的是窗口范围,当然bazbaz=1在窗口中定义了什么.但该计划仍然没有工作和返回undefined.为什么它返回undefinedbaz在窗口定义,我从窗口执行foo.bar

javascript arguments function

4
推荐指数
1
解决办法
69
查看次数

如何检查用户在 symfony2 中是否具有一个角色?

假设在我的系统中有四个用户角色 -

1. ROLE_SUPER_ADMIN
2. ROLE_ADMIN
3. ROLE_EDITOR
4. ROLE_AUTHOR
Run Code Online (Sandbox Code Playgroud)

现在想想,一个用户拥有角色 ROLE_AUTHOR。他可以访问特定文档,但其他用户无法访问该文档。所以我只想允许拥有ROLE_AUTHOR. 我在搜索时得到了一些解决方案,其中有类似的内容, is_granted('ROLE_AUTHOR')但这会返回分层结果。因为在我的配置文件中我设置了层次结构。那么我怎样才能只授予ROLE_AUTHOR用户权限呢?

php symfony

4
推荐指数
1
解决办法
8727
查看次数

__DIR__ VS使用Reflection

在Symfony2中,我看到了如下代码:

    if (null === $this->rootDir) {
        $r = new \ReflectionObject($this);
        $this->rootDir = dirname($r->getFileName());
    }
Run Code Online (Sandbox Code Playgroud)

为什么不只是使用__DIR__

    if (null === $this->rootDir) {
        $this->rootDir = __DIR__;
    }
Run Code Online (Sandbox Code Playgroud)

他们之间有什么区别?

php symfony

3
推荐指数
1
解决办法
711
查看次数

我如何解决语义错误:"类没有名称的关联.."

我正在遵循symblog symfony2教程的第5部分:

http://tutorial.symblog.co.uk/docs/customising-the-view-more-with-twig.html
Run Code Online (Sandbox Code Playgroud)

标题下:主页 - 博客和评论

当我得到更新时:

// src/Blogger/BlogBundle/Repository/BlogRepositoy.php

public function getLatestBlogs($limit = null)
{
    $qb = $this->createQueryBuilder('b')
           ->select('b, c')
           ->leftJoin('b.comments', 'c')
           ->addOrderBy('b.created', 'DESC');

    if (false === is_null($limit))
    $qb->setMaxResults($limit);

    return $qb->getQuery()
          ->getResult();
}
Run Code Online (Sandbox Code Playgroud)

当我更新时:

{# src/Blogger/BlogBundle/Resources/views/Page/index.html.twig #}

{# .. #}

<footer class="meta">
    <p>Comments: <a href="{{ path('BloggerBlogBundle_blog_show', { 'id': blog.id }) }}#comments">{{ blog.comments|length }}</a></p>
    <p>Posted by <span class="highlight">{{ blog.author }}</span> at {{ blog.created|date('h:iA') }}</p>
    <p>Tags: <span class="highlight">{{ blog.tags }}</span></p>
</footer>

{# .. #}
Run Code Online (Sandbox Code Playgroud)

我然后刷新我的浏览器并得到错误:

[Semantical Error] line 0, col 71 near …
Run Code Online (Sandbox Code Playgroud)

php symfony doctrine-orm

3
推荐指数
1
解决办法
1万
查看次数

httpd.conf和ssl.conf之间的区别

httpd.conf(/etc/httpd/conf/httpd.conf)ssl.conf(/etc/httpd/conf.d/ssl.conf)文件有什么区别?

我正在尝试在我的网站上设置ssl,发现这些文件有类似的令牌.

任何帮助,将不胜感激.

apache ssl httpd.conf

3
推荐指数
1
解决办法
4603
查看次数

从MySQL表中获取最接近的日期

我需要从MySQL表中获取最接近当前日期的日期.

这是我的表:

id        | date          | name
1         | 2012-10-29    | test
2         | 2009-11-31    | test
Run Code Online (Sandbox Code Playgroud)

因此,如果查询今天运行,它将返回 1 | 2012-10-29 | test

任何帮助深表感谢.谢谢

php mysql sql date

3
推荐指数
1
解决办法
5104
查看次数

合并段落

我是Jquery的新手,我的要求是将两个段落合并为单个段落.我尝试使用以下代码.

<p>This is first para text </p>
<p>This is second para text </p>
<p>This is third para text.</p>
Run Code Online (Sandbox Code Playgroud)

<p>This is first para text This is second para text This is third para text.</p>
Run Code Online (Sandbox Code Playgroud)

它不起作用.有任何想法吗?

javascript jquery

2
推荐指数
1
解决办法
899
查看次数