首页 \ 问答 \ Doctrine 2 - 无法访问新创建的记录(在Doctrine之外)(Doctrine 2 - Unable to access newly created record (outside of Doctrine))

Doctrine 2 - 无法访问新创建的记录(在Doctrine之外)(Doctrine 2 - Unable to access newly created record (outside of Doctrine))

关于我的环境的几个关键说明:

  • 我有一个基于WordPress的应用程序,我们使用Doctrine作为我们的ORM。
  • 为了保持WP的完整性,我们让WP处理用户的创建
  • 每个WP对象和自定义对象都通过Doctrine正确映射。

情况是:

// 1. Create a user via **WP** function (which returns ID)
$wp_user_id = wp_insert_user($wp_user_array);

// 2. Then, I need to immediately retrieve that user object via Doctrine
$wp_user = $MyDb->em->getRepository('WpUsers')->findOneBy(array('id'=>$wp_user_id));

// 3. RESULT = NULL

该对象没有找到,大概是因为该实体被缓存或存储在某个地方的教义。

如何强制Doctrine查看数据库并获取这个新创建的用户?


A few key notes on my environment:

  • I have an app that is built on Wordpress and we're using Doctrine as our ORM.
  • In order to maintain WP's integrity, we let WP handle the creation of users
  • Every WP object and custom object is mapped properly through Doctrine.

The situation is:

// 1. Create a user via **WP** function (which returns ID)
$wp_user_id = wp_insert_user($wp_user_array);

// 2. Then, I need to immediately retrieve that user object via Doctrine
$wp_user = $MyDb->em->getRepository('WpUsers')->findOneBy(array('id'=>$wp_user_id));

// 3. RESULT = NULL

The object is not found, presumably because the Entity is cached or stored in memory somewhere by Doctrine.

How can I force Doctrine to go look at the DB and get this newly created user?


原文:https://stackoverflow.com/questions/32084483
更新时间:2023-05-03 08:05

最满意答案

你可以尝试这样的事情:

JS

$(document).keydown(function(e) {
    switch (e.which) {
    case 37:
        $('#movingBox').stop().animate({
            left: '-=10'
        }); //left arrow key
        break;
    case 38:
        $('#movingBox').stop().animate({
            top: '-=10'
        }); //up arrow key
        break;
    case 39:
        $('#movingBox').stop().animate({
            left: '+=10'
        }); //right arrow key
        break;
    case 40:
        $('#movingBox').stop().animate({
            top: '+=10'
        }); //bottom arrow key
        break;
    }
})

CSS

#movingBox{
    width:20px;
    height:20px;
    background:blue;
    position:absolute;
    top: 0;
    left: 0;
}

小提琴


You can try something like this:

js

$(document).keydown(function(e) {
    switch (e.which) {
    case 37:
        $('#movingBox').stop().animate({
            left: '-=10'
        }); //left arrow key
        break;
    case 38:
        $('#movingBox').stop().animate({
            top: '-=10'
        }); //up arrow key
        break;
    case 39:
        $('#movingBox').stop().animate({
            left: '+=10'
        }); //right arrow key
        break;
    case 40:
        $('#movingBox').stop().animate({
            top: '+=10'
        }); //bottom arrow key
        break;
    }
})

css

#movingBox{
    width:20px;
    height:20px;
    background:blue;
    position:absolute;
    top: 0;
    left: 0;
}

fiddle

相关问答

更多
  • 您可以直接触发任何事件,如下所示: $(function() { $('item').keydown(); $('item').keypress(); $('item').keyup(); $('item').blur(); }); 这是做你想做的事情吗? 你也应该触发.focus()和潜在的.change() 如果要使用特定键触发密钥事件,可以这样做: $(function() { var e = $.Event('keypress'); e.which ...
  • 除非我误以为你要找的东西,否则你应该能够改变你的 event.stopPropagation() 回到 event.preventDefault() 它会按预期工作。 Unless I'm mistaken as far as what you're looking for, you should just be able to change your event.stopPropagation() back to event.preventDefault() and it will work as ...
  • 正如@Lee提到的那样,它是操作系统的一个特性。 你可以解决它的唯一方法是使用setInterval函数: var pressedKeys = []; $(document.body).keydown(function(e){ if (!pressedKeys[e.which]){ pressedKeys[e.which] = setInterval(function(){ console.log(1); }, 0); } }); $ ...
  • 元素没有焦点,即使它是可视的。 文本输入仍然具有焦点。 您需要检查文本上的回车键。 不在
  • $('input#example').on('keydown', function (e) { //... var key = e.keyCode if (key == 40) { // Down key //... } else if (key == 38) { // Up key //... } else if ( ...
  • 您需要将该keydown事件绑定到元素。 假设您要在document keydown上显示该框, $(document).keydown(function() { if($('#infocontent').hasClass('cnthidden')) { $('#infocontent').removeClass('cnthidden'); //assuming cnthidden has display:none property } }); You ...
  • 事件正在通过文档的其余部分从输入中冒出来。 在您的活动中尝试注销event.trigger: $j(':not(input)').keydown(function(event) { console.log(event.trigger); // REST OF FN 我敢打赌它不是HTMLInputElement 一种解决方案,尝试绑定输入并停止事件传播: $j('input').keydown(function(event) { event.stopPropagation(); }); 看看 ...
  • 小数的问题是因为你正在使用 rightHalf >= 3 它评估实际数字而不是它的长度,因为javascript类型 - 将其转换为数字以进行比较。 你想要的是数字位数,试试 rightHalf.toString().length >= 2 小提琴这里http://jsfiddle.net/Qxtnd/1/ 编辑 只要rightHalf是一个字符串,你可以这样做: rightHalf.length >= 2 如果rightHalf是一个数字,你会得到一个例外。 The problem of decim ...
  • 你可以尝试这样的事情: JS $(document).keydown(function(e) { switch (e.which) { case 37: $('#movingBox').stop().animate({ left: '-=10' }); //left arrow key break; case 38: $('#movingBox').stop().animate({ ...
  • 基本上,您需要将keydown event与window绑定,并将当前打开的图像对象存储在全局变量中。 尝试这个 更新了jsfiddle HTML
    ...
  • 看起来你想增加一个。 尝试a+=1; (相当于a=a+1; ) It looks like you want to increment a. Try a+=1; (Equivalent to a=a+1;)
  • 相关文章

    更多
  • Unable to load configuration.
  • RFC2848--The PINT Service Protocol: Extensions to SIP and SDP for IP Access to Telephone Call Services
  • ACCESS TOKEN
  • java微信接口之——获取access_token
  • Securing Solr on Tomcat access using a user account
  • Force.com微信开发系列(四)申请Access Token及自定义菜单之创建菜单
  • 顶 微信API access_token 验证 weixin_authorize
  • [22] 微信公众平台开发教程第22篇-如何保证access_token长期有效
  • 微信公众账户的开发者模式(一) 部分细节access_token的获取等
  • Extjs 怎样将grid的record转换成Json串,然后post到下个画面?
  • 最新问答

    更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。