Closed nekromoff closed 8 years ago
Have you tried: user_id and $limit->user ?
Hello,
no I haven't, but why woudl suddenly userlimit
in $limit would be changed to something like user
only? This goes against all the docs.
Ok, I've tried both to no avail, i.e. echo prints nothing.
print_r of $limit, if that helps:
RedBeanPHP\OODBBean Object
(
[properties:protected] => Array
(
[id] => 1
[userId] => 1
[userLimit] => 100
)
[__info:protected] => Array
(
[type] => limits
[sys.id] => id
[sys.orig] => Array
(
[id] => 1
[userId] => 1
[userLimit] => 100
)
[tainted] =>
[changed] =>
)
[beanHelper:protected] => RedBeanPHP\BeanHelper\SimpleFacadeBeanHelper Object
(
)
[fetchType:protected] =>
[withSql:protected] =>
[withParams:protected] => Array
(
)
[aliasName:protected] =>
[via:protected] =>
[noLoad:protected] =>
[all:protected] =>
)`
after changing database column name to lowercase userlimit
, it works.
definitely a bug in Redbeanphp
Sorry for my previous response, I was too tired I think. I was a bit confused.
I have tried to reproduce the issue, the following code snippet seems to work fine:
Did I miss something ?
$l = R::dispense('limit');
$l->userLimit = 999;
$id = R::store($l);
$x = R::load('limit',$id);
var_dump($x->userLimit);
prints:
string(3) "999"
I would love to fix a bug - however to do so - I must be able to reproduce it properly.
cheers, Gabor
My code is as shown in the first comment:
$limit=R::findOne('limits', 'userid=?', [$userid]);
table: `Column Type
id int(11) Auto Increment
userId int(11)
userLimit int(11)`
echo $limit->userLimit
prints out nothing
Could this be related to a fact that database/table was created before we started to use RedBeanPHP ?
(btw, I have resolved this to switching all column names to lowercase, no problem fetching values after that)
Sorry but you're code is not executable as-is, I have modified my version to look more like yours (I need a test case):
$l = R::dispense('limits');
$l->userLimit = 999;
$l->userid = 123;
$id = R::store($l);
$x = R::findOne('limits', 'userid=?', [123]);
var_dump($x->userLimit);
but this still works. Might have something to do with your DB config maybe ? What OS are you using?
HI, I am using standard MariaDB setup on Ubuntu 16.04
mysql Ver 15.1 Distrib 10.0.25-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
Okay, now tested with MariaDB (10.0.23 over here) - still not able to reproduce the issue. I don't know why but it seems to work fine here, just as I expect. Can you verify that my latest code snippet above reproduces the error on your system?
$limit=R::findOne('limits', 'userid=?', [$userid]);
log:
SELECT limits.* FROM limits WHERE userid=1 LIMIT 1 -- keep-cache resultset: 1 rows
after:
echo $limit
I get:{"id":"1","userId":"1","userLimit":"100"}
however after trying:
echo $limit->userLimit
nothing is printed out. Similarly after trying:echo $limit->user_limit
orecho $limit->userlimit
nothing is printed out either.