1
Ewaan
query queryF
  • 2005/2/3 18:31

  • Ewaan

  • Just popping in

  • Posts: 4

  • Since: 2005/1/18


function queryF and query are both declared in /class/database/mysqldatabase.php.

The code suggests that:
query has no body and does nothing.
queryF executes a sql statement and returns MySQL resource.

I've created numerous subclasses for XoopsUser and am rewriting the XoopsUserHandler to manage the data access for all the subclasses. For function &get() I've had to use queryF() to retrieve the MySQL resource. For $getObjects I'v used query() and am returned the resource.

All the XOOPS core code that I've seen uses query() for database querying.

1.Why can query() be used to return resources?

2.Why in two very similar cases i.e. the rewritten &get() and &getObjects(), query() can be used for one but does not return anything in the other?


Please can somebody explain.

Cheers

Ewan

2
Mithrandir
Re: query queryF

query() can always be used for SELECT statements (i.e. SQL statements that begin with SELECT without any whitespaces, breaks or other characters before the SELECT)

query() can only be used for non-SELECT statements if the HTTP request method is POST (i.e. if the request was made through a form using the method=POST)

This is because what is instantiated is NOT a MySQLDatabase, but a MySQLDatabaseProxy or MySQLDatabaseSafe. This is done in include/common.php where the request method and the HTTP referer is checked. If either the request method is not POST or the HTTP Referer is not disclosed, a MySQLDatabaseProxy object is instantiated - which does not allow non-SELECT statements in query() - otherwise a MySQLDatabaseSafe is instantiated, which allows non-SELECT statements in query()

Hope this helps

3
Ewaan
Re: query queryF
  • 2005/2/4 8:49

  • Ewaan

  • Just popping in

  • Posts: 4

  • Since: 2005/1/18


Thanks

Login

Who's Online

190 user(s) are online (104 user(s) are browsing Support Forums)


Members: 0


Guests: 190


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Oct 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits