小编tft*_*ftd的帖子

Symfony2 Doctrine - PostgreSQL的ILIKE子句?

我目前正在使用symfony2,doctrine 2.3和PostgreSQL 9.我现在一直在寻找几个小时来看看我是如何ILIKE选择的QueryBuilder.

看起来他们只有LIKE.但在我的情况下,我正在搜索不区分大小写的内容.怎么样呢?

// -- this is the "like";
$search = 'user';
$query = $this->createQueryBuilder('users');
$query->where($query->expr()->like('users.username', $query->expr()->literal('%:username%')))->setParameter(':username', $search);


// -- this is where I get "[Syntax Error] line 0, col 86: Error: Expected =, <, <=, <>, >, >=, !=, got 'ILIKE'
$search = 'user';
$query = $this->createQueryBuilder('users');
$query->where('users.username ILIKE :username')->setParameter(':username', $search);
Run Code Online (Sandbox Code Playgroud)

postgresql symfony doctrine-orm

5
推荐指数
2
解决办法
6745
查看次数

Php写入文件 - 空?

我一直在努力将单个字符串写入文件.我在Slackware 13下只使用了一个简单的代码:

$fp = fopen('/my/absolute/path/data.txt', 'w');
fwrite($fp, 'just a testing string...');
fclose($fp);
Run Code Online (Sandbox Code Playgroud)

文件被创建(如果它尚未创建),但它是空的?!写入此文件的目录由apache的用户和组(daemon.daemon)拥有,并具有0777权限.这在我之前从未发生过.我很好奇我无法在文件中写入的原因是什么?

提前致谢.

php file

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

用Spring运行测试. - > java.lang.IllegalStateException:无法加载ApplicationContext

我在运行返回的测试用例时遇到问题java.lang.IllegalStateException: Failed to load ApplicationContext.我已经检查了@ContextConfiguration但看起来不错.

课堂:

public class MainSecurityInit extends SecurityFunctionalityCbosInit
{

    protected FileWriter logFile = null;
    private String logFileName = "";

    /* _______________________ Initializers ________________________ */
    @Autowired
    private CbosSecurityInit cbosSecurityInit;

    public void doTest()
    {

        Map<Class, Object> map = new HashMap<Class, Object>();
        List<DataBaseInitializerResult> results = null;

        initLogFile();
        try
        {
            // -------------- Begin of initialization ------------------ //
            cbosSecurityInit.execute();
            // -------------- End of initialization -------------------- //
        }
        catch (Throwable ex)
        {
            logger.error(ex.getMessage());
            ex.printStackTrace();
            test(results);
        }
        finally
        {
            closeLogFile(); …
Run Code Online (Sandbox Code Playgroud)

spring

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

隐藏POST/GET请求 - Flash和PHP

我正在和朋友一起玩flash游戏.当玩家完成游戏时,他希望将分数插入数据库中.他正在使用本教程的flash - http://www.tizag.com/flashTutorial/flashforms.php.他制作的瑞士法郎很有效 - 它发布了数据.问题是我可以看到来自firebug的请求.这开启了另一个问题 - 任何更高级的用户都可以在不玩游戏的情况下插入自己的分数......

那么有没有办法隐藏Flash游戏的请求?这个问题的正确方法是什么?

php security flash

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

关于window.print()的奇怪问题

使用时我遇到了一个很奇怪的问题window.print()
我有一个页面,该页面需要具有与通常显示给用户的页面不同的打印布局。因此,我创建了一个叠加层,当用户单击print按钮然后触发时,该叠加层会显示出来window.print()。一切正常,除了出于某些未知原因,打印窗口显示多次。如果我第一次单击“打印”按钮,我将获得两次打印窗口,第二次,我将获得4次打印窗口。

HTML:

<div id="printDiv" style="position: fixed; overflow: auto; top: 0px; width: 100%; height: 100%; background: white; z-index: 9999;display: none;">
   The print page content
</div>
Run Code Online (Sandbox Code Playgroud)

JavaScript:

function show_print(){
    $('body').css('overflow', 'hidden');
    $('html,body').animate({ scrollTop: 0 }, 'fast', function () {
        window.print();
    });
}
Run Code Online (Sandbox Code Playgroud)

任何想法是什么原因造成的?

javascript jquery

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

当我打开php opcache时,学说很吓人

我和Doctrine有一个非常奇怪的问题PHP 5.5.6 Opcache.opcache关闭模块后,一切正常.一旦我打开它,我开始得到以下异常:

Fatal error: Uncaught exception 'Doctrine\ORM\Mapping\MappingException' with message 'Class "Admin\Models\Users\Role" is not a valid entity or mapped super class.' in vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php on line 336
( ! ) Doctrine\ORM\Mapping\MappingException: Class "Admin\Models\Users\Role" is not a valid entity or mapped super class. in vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php on line 336
Call Stack
#   Time    Memory  Function    Location
1   0.0000  128016  {main}( )   ../app.php:0
2   0.0185  615020  Core\Bootstrap->handle( )   ../app.php:53
3   0.0210  695744  call_user_func_array ( )    ../Bootstrap.php:111
4   0.0210  695976  Admin\Controllers\DashboardController->indexAction( …
Run Code Online (Sandbox Code Playgroud)

php doctrine doctrine-orm opcache

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

是否有适用于用户的 LDAP 标准组成员资格属性?

我目前正在开发一个使用 LDAP 作为身份验证方法的应用程序。我想知道LDAP协议是否有一个标准的成员资格属性来保存用户的组?到目前为止memberOf正在工作OpenLDAPActive Direcotry但不在Apache DS. 我在 RFC 中找不到这个属性,所以我有点困惑。我应该使用该memberOf属性还是我需要采用旧时尚的方式遍历所有组以查找哪个组具有member

ldap active-directory openldap

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

如何强制注销Symfony中的用户?

我有一个User实体,它有一个布尔列isActivated.根据每个用户的列值,他可能会或可能无法登录(即他没有激活他的帐户,因此无法登录).我通过simple_form.authenticator在防火墙中分配一个检查每次登录来实现这一点.

我正在试图找出当用户仍在进入时如何强制注销用户.
请考虑以下情形:

  1. 用户在其帐户仍处于活动状态时登录.
  2. 管理员停用该用户的帐户.
  3. 用户因其不再处于活动状态而被注销.

不幸的是,第3步没有发生.原因可能在于用户已经收到令牌并且被Symfony 2.5防火墙视为"被"攻击(可能是令牌被缓存在安全上下文中?).

我想知道克服这个问题的最佳方法是什么?我应该编写内核事件监听器还是自定义用户提供程序

php authentication symfony

3
推荐指数
2
解决办法
4414
查看次数

Less - 动态样式表语言?

虽然谷歌用更少的写作来搜索更多的CSS,但我发现了这一点 - http://lesscss.org/

有没有人试过它,它是否在IE6 +,Firefox 3 +,Chrome,Safari,Opera以及我们所有使用的所有标准网络浏览器下工作?

提前致谢 :)

css dynamic stylesheet

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

在RESTful Web服务中添加删除方法

我正在制作我的第一个RESTful Web服务(使用MySQL)。但是我不知道如何通过ID从表中删除记录。

到目前为止,这是我所做的:

  1. 通过id搜索一个人,并以XML格式返回结果(id,全名和年龄):

    private PersonDao personDao = new PersonDao();
    //method which return a single person in xml
    @GET
    @Path("/getPersonByIdXML/{id}")
    @Produces(MediaType.APPLICATION_XML)
    public Person getPersonByIdXML(@PathParam("id")int id){
        return personDao.getPersonById(id);
    }
    
    // return JSON response
    
    Run Code Online (Sandbox Code Playgroud)
  2. 通过id搜索一个人并以JSON格式返回结果(id,全名和年龄):

    @GET
    @Path("/getPersonByIdJSON/{id}")
    @Produces(MediaType.APPLICATION_JSON)
    public Person getPersonById(@PathParam("id")int id){
        return personDao.getPersonById(id);
    }
    
    Run Code Online (Sandbox Code Playgroud)
  3. 输出所有人并以JSON格式返回结果(id,全名和年龄):

    // the method returns list of all persons
    @GET
    @Path("/getAllPersonsInXML")
    @Produces(MediaType.APPLICATION_XML)
    public List<Person> getAllPersonsInXML(){
        return personDao.getAllPersons();
    }
    
    Run Code Online (Sandbox Code Playgroud)
  4. 在数据库中插入一个人:

    //insert
    @GET
    @Path("/insertPerson/{fullName}/{age}")
    @Produces(MediaType.APPLICATION_JSON)
    public String saveNewPerson(@PathParam("fullName") String fullName, @PathParam("age") int age) {
        Person person = new Person(); …
    Run Code Online (Sandbox Code Playgroud)

java mysql rest

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