-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQLSTATE[HY000]: General error when using jf::$RBAC->Permissions->Add('Test', 'Test Rights') #13
Comments
I don't know whether is right or not, I replace the source from line 61 till line 64 with the following which solves the issue:
Thanks in advance for taking time to look into this. |
Are you using PhpRbac v1.0 or v2.0 Beta? If you are using v2.0 Beta you will need to use the new interface.
We still need to update the docs for v2.0 Beta, but for the most part you will use the above to instantiate the $rbac object and use $rbac rather than jf::RBAC. Also, make sure you are using 'PhpRbac/database/database.config' for database configuration. |
Thanks for taking time to response. I am using v2-beta. Actually I am trying not to use PhpRbac/database/database.config since my application already got one PDO link to MySQL and I don't feel comfortable to have two mysql database login information saved in file (one for phprbac and one in my application). Currently I am doing: Where $DB is the pdo_mysql link and I did commented out last 3 lines in jf.php: //jf::setTablePrefix($table_prefix); Or is there any way to go around this? Sorry, just trying phprbac and will try to find time to learn more from the sources. Thanks again. |
I had a similar issue as you're describing in a project I'm working on. Here's the solution I use, and it works like a charm. The database connection setting in my project are stored in constants. I just updated my database.config with the following:
Now I only have to keep track of one database config file. This is extremely handy in my project, as it's a CMS with an installation script where the user fills out a form with the db connection info and then the installer creates the dbConnections config, so every installation has different settings. But there's no need to worry about PhpRbac separately. The above example should point you in the right direction, but if you need any help that's specific to your setup please let me know: jburns 131 at g mai l. c om... remove the spaces of course :-p |
Thanks again. For my case, I prefer not to use the database.config file at all. Personally I find it easier just to set jf::$Db and done with it :p I will try to learn more from the sources when I have the time. Will email you whenever I have doubts. Once again, thanks a lot for your kind responses ;) |
I'm not sure you will be able to do that with v2.0, especially the farther we move towards PSR compliance. If you would like to interact directly with the jf class I'd suggest you use v1.0, as there won't be many changes in the future that would affect your customizations. Maybe this is an issue that should be addressed in the code base, i.e. design a way that will ease the process of integrating PhpRbac into existing projects. But because of the specialized nature of PhpRbac, and the advanced queries involved, there is no way to decouple the queries from the system, as the queries are the system. My suggestion is to alter the database.config and let the rest of the system do it's job. Once the database.config has the proper values, there is no need, or reason, to customize the internals. |
Also, if you are using
you are just hacking into the v1.0 code, which has been modified to work with the v2.0 wrapper class (Rbac.php). Yeah, if you want to do that, I definitely suggest you use v1.0. |
Will look into the sources to learn more :p Thanks again for your suggestion and advice ;) |
k, no problem at all :-) |
Setup Issue. Closing. |
Sorry, just a note here in case someone reading this and encounter issue when using v2 beta on what you posted as below: include 'PhpRbac/autoload.php'; The above didn't work for me. However, changing: $rbac = new Rbac(); To $rbac = new PhpRbac\Rbac(); Works. Thanks. |
I think it is supposed to be the second way, unless you do: This is for PSR-Compliance (the whole purpose of version 2). Notice: This message is digitally signed, its source and integrity are verifiable. On Oct 7, 2013, at 9:00 AM, Giam Teck Choon notifications@github.com wrote:
|
Thanks Abbas. In the end, I do as per Jesse's suggestion and use constants in database.config file. Once again, thanks to both of your prompt responses ;) |
Here are some examples. If you are using an autoloader point it to 'PhpRbac/src'. If you are not using an autoloader then include 'PhpRbac/autoload.php'. One you have autoloaded/included the project, you have the following options to instantiate an object. With a 'use' statement:
Without a 'use' statement, outside of a namespace -
Without a 'use' statement, inside of another namespace (notice the leading backslash) -
Hope this helps. |
I am getting the following:
PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error' in SNAP/PhpRbac/src/PhpRbac/core/lib/jf.php:61
Stack trace:
#0 SNAP/PhpRbac/src/PhpRbac/core/lib/jf.php(61): PDOStatement->fetchAll(2)
#1 [internal function]: jf::SQL_pdo('LOCK TABLE phpr...')
#2 SNAP/PhpRbac/src/PhpRbac/core/lib/jf.php(45): call_user_func_array('self::SQL_pdo', Array)
#3 SNAP/PhpRbac/src/PhpRbac/core/lib/nestedset/full.php(53): jf::SQL('LOCK TABLE phpr...')
#4 SNAP/PhpRbac/src/PhpRbac/core/lib/nestedset/full.php(419): FullNestedSet->Lock()
#5 SNAP/PhpRbac/src/PhpRbac/core/lib/rbac.php(74): FullNestedSet->insertChildData(Array, 'ID=?', 1)
#6 SNAP/test.php(32): BaseRbac->Add('Test', 'Test Rights')
#7 {main}
thrown in SNAP/PhpRbac/src/PhpRbac/core/lib/jf.php on line 61
In https://github.com/OWASP/rbac/blob/master/PhpRbac/src/PhpRbac/core/lib/jf.php#L61:
I think we shouldn't use the above when there is an insert or update query?
The text was updated successfully, but these errors were encountered: