首页
\
问答
\
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; }
相关问答
更多-
在JS / jQuery中触发keypress / keydown / keyup事件?(Trigger a keypress/keydown/keyup event in JS/jQuery?)[2021-10-22]
您可以直接触发任何事件,如下所示: $(function() { $('item').keydown(); $('item').keypress(); $('item').keyup(); $('item').blur(); }); 这是做你想做的事情吗? 你也应该触发.focus()和潜在的.change() 如果要使用特定键触发密钥事件,可以这样做: $(function() { var e = $.Event('keypress'); e.which ... -
AngularJS类似于jQuery为了keydown而阻止了默认?(AngularJS analogue to jQuery preventDefault for keydown?)[2024-05-09]
除非我误以为你要找的东西,否则你应该能够改变你的 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 ... -
JQuery - JS - Keydown(JQuery - JS - Keydown)[2024-03-01]
正如@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;)