Commit Graph

33 Commits (ceb013278e4846f6e77cbea12660a9644f9783f5)

Author SHA1 Message Date
Steven Wittens 897aae3e31 - #27846: Clean up dev_query code in db_query() 2005-07-30 18:01:51 +00:00
Steven Wittens d9d4b9bdab - #27231: Friendly DB error screens. 2005-07-27 01:58:43 +00:00
Dries Buytaert 5c8843704c - Patch #18213 by chx: boostrap system. Modified to work with HEAD, tidied
up the documentation a little.

  chx: can you double-check whether the global $conf variable is secure?
       (That is, make sure it can't be send using the URL or something.)
2005-06-22 20:19:58 +00:00
Dries Buytaert 7dcb9086f8 - Patch #23465 by Gerhard: tiny performance improvement to db_query_range(). 2005-05-23 21:14:01 +00:00
Dries Buytaert f2d200f51e - Patch #19442 by chx: cache_set sometimes failed.
TODO: this patch lets us clean up more code in code!  Let's have a look
        at this ...
2005-05-12 14:36:43 +00:00
Dries Buytaert fa40f24460 - Patch #20235 by chx: fixed problem with db_set_active(). 2005-04-14 18:50:16 +00:00
Dries Buytaert 29337ad8bb - Patch #13581 by Steven: Db_query() allows a variable amount of parameters so you can pass the query arguments in. There is however an alternative syntax: instead of passing the query arguments as function arguments, you can also pass a single array with the query arguments in it. For example the following two statements are equivalent:
db_query($query, $a, $b, $c);
db_query($query, array($a, $b, $c));

This usage is particularly interesting when the query is constructed dynamically, and the amount of arguments to pass varies. In that case we use the second method to avoid using call_user_func_array(). This behaviour is not documented explicitly, but it is used in several places.

However, db_query_range() and pager_query() do not support this syntax properly, which means there are several pieces of code which still revert to the ugly call_user_func_array() call.

This patch updates db_query_range() and pager_query() so they support the array-passing method. I also added documentation about this method to each of the db functions.

I also cleaned up the code for db_query (it was weird and hard to understand) and moved db_query() and db_queryd() from database.xxxxx.inc to database.inc: it was the same between both mysql and pgsql, as it doesn't do anything database specific. It just prefixes the tables and inserts the arguments. The actual db query is performed in _db_query(), which is still in database.xxxxx.inc.

Finally, I updated several places with the new syntax, and the code is a lot cleaner. For example:
- array_unshift($params, "SELECT u.* FROM {users} u WHERE $query u.status < 3");
- $params[] = 0;
- $params[] = 1;
- $result = call_user_func_array('db_query_range', $params);
+ $result = db_query_range("SELECT u.* FROM {users} u WHERE $query u.status < 3", $params, 0, 1);

and

- return call_user_func_array('db_query_range', array_merge(array($query), $args, array((int)$pager_from_array[$element], (int)$limit)));
+ return db_query_range($query, $args, (int)$pager_from_array[$element], (int)$limit);

I've tested it on mysql. I didn't alter the actual db behaviour, so pgsql should be okay too.

This patch is important because many people avoid the call_user_func_array() method and put data directly into the db query.  This is very, very bad because the database prefix will be applied to it, and strip out braces. It's also generally bad form as you have to call check_query() yourself.  With the new, documented syntax, there is no more excuse to put data directly in the query.
2004-11-29 13:13:29 +00:00
Dries Buytaert fa97839088 - Patch 13180 by chx: renamed check_query() to db_escape_string() and implemtented it properly per database backend.
Read the manual for pg_escape_string:  "Use of this function is recommended instead of addslashes()." Or read sqlite_escape_string: "addslashes() should NOT be used to quote your strings for SQLite queries; it will lead to strange results when retrieving your data."
2004-11-21 08:25:17 +00:00
Dries Buytaert b84b6e42cf - Patch #10663 by JonBob: documentation improvements: fixed some typos and improved consistency to the use of Doxygen/api.module commands in the comments. 2004-09-09 05:51:08 +00:00
Dries Buytaert 7b716e8e77 - Patch #10622 by Adrian: fixes various PostgreSQL related problems.
1) Menu problems with Postgres (this is a highly critical 1 line fix)
  2) Archive module fails with Postgres
  3) Postgres setup problems - changes to database.pgsql (although i made these changes myself before finding this patch)
  4) Book module fails with Postgres
  5) Postgres problems following creation of a new type of user - which is actually about a taxonomy.module bug.
  6) Creating accregator_item_table in PostgreSQL
  7) Postgres - Polls not displayed on Poll Page
  8) Blog module has sql errors with postgres

  This should not affect MySQL users (hopefully).
2004-09-08 15:38:26 +00:00
Dries Buytaert 63a327db97 - Patch #9287 by JonBob: made the code style in the three database include files consistent with Drupal standards, and adds a wealth of Doxygen-style comments to aid developers in writing solid database access code using the API. 2004-07-14 19:15:25 +00:00
Dries Buytaert e4d45aaef3 - Patch by Adrian: added support for multiple database connections. 2004-04-30 05:12:46 +00:00
Dries Buytaert 3904790e03 - Tidied up the DoxyGen comments. Patch by Kjartan. 2003-12-08 06:32:19 +00:00
Dries Buytaert 06045ff7fc Patch by Ax to fixe and improve to the core doxygen PHPdoc:
* fixes all doxygen warnings [#]_ in the current code base
    + changes @param style from phpDocumentor (@param type $var desc) to doxygen (@param $var desc)
    + documents all undocumented parameters
    + escapes / fixes html warnings
    + fixes @defgroup in theme.inc
  * adds more groupings [#]_
    + drupal_{set|get}_title, drupal_{set|get}_breadcrumb
    + pager.inc: pager_api (pager_query(), pager_display()), pager pieces
  * adds a new group "themeable" which contains all themeable functions.
2003-11-24 22:46:03 +00:00
Dries Buytaert 742410aafd - Bugfix: prefix not prepended to sequences. Fixes bug #3639.
Make sure to write:

    db_next_id({table}_field);

  instead of:

    db_next_id(table_field);
2003-10-22 13:03:32 +00:00
Dries Buytaert c39562ae03 - Fixed node_save() and user_save() bug introduced by table prefix changes.
Modified patches from Gerhard.

- Changed the order of the checks in node_teaser().  Patch from Kobus.
2003-07-21 15:36:05 +00:00
Dries Buytaert 337b3c9de9 - Committed a slightly modified version of Slavica's table prefix patch. 2003-07-10 17:46:44 +00:00
Dries Buytaert a161110a6b - Applied Michael Caerwyn's "%s -> %d" patch.
- Changed all occurences of '%d' to %d as suggested on the mailing list.
2003-05-07 21:00:36 +00:00
Dries Buytaert cb2d27c78d - Patch by Ax. Fixed some syntax errors:
-    case t("whatever");
    +    case t("whatever"):
2003-04-04 06:17:02 +00:00
Dries Buytaert 3ab5709af5 - Changed pconnect() to connect(). 2003-04-03 22:18:47 +00:00
Dries Buytaert b2583b624c Patch by Ax:
- db_query_range() in database.mysql.inc wasn't updated to match
  db_query().

- Fixed phpdoc.
2003-03-16 17:38:51 +00:00
Dries Buytaert 3dd7d9b47d - Oops. The db_query_range() query got added twice. 2002-11-09 20:47:52 +00:00
Dries Buytaert c93ab2a21f - Added a db_query_range function. Patch by Natrak, slightly modified. 2002-11-09 20:02:41 +00:00
Kjartan Mannes 601d34ec31 - removing whitespace (+testing still). 2002-11-06 14:18:45 +00:00
Dries Buytaert 2512ce7697 - Killed a warning. Reported by ax. 2002-10-24 17:44:39 +00:00
Dries Buytaert 1e5813d4f4 - Made it possible to connect to mysql databases running on non-standard
ports.  Patch by Alastair.
2002-10-23 20:09:29 +00:00
Dries Buytaert fcae7030cc - Committed Jeremy's incarnation of the statistics module. Last minutes
changes include:

    * a couple of coding style changes, renamed some "stats" into
      "statistics", etc.

    * removed the "Who's online" block from the user module.

    * added db_affected_rows() to the resp. database abstraction
      layers and made the statistics module use db_affected_rows()
      instead.

    * added update logic to "update.php".
2002-10-13 12:00:50 +00:00
Dries Buytaert bfe5b85dbd - Applied a (modified) version of Marco's SQL sequence patch. 2002-08-20 19:29:16 +00:00
Dries Buytaert d1b2125be4 - Added the improved db_query() function with timings from Marco's sandbox. 2002-06-23 13:40:01 +00:00
Kjartan Mannes de5b9a168d - bug fixes:
* fixed mails not being parsed properly.
    * tracker now shows user name when you view your own recent
      comments.
    * link to submission queue now points to the right place.
    * fixed jabber module.
    * theme is now activated when changed.
- applied Gerhards coding style patch.
2002-04-22 09:05:36 +00:00
Dries Buytaert 8043cb998f - Applied Marco's big patch, including contributions from Moshe:
+ Changed the db_query() API.

    + Wrapped all links in l(), lm(), la(), ..., drupal_url() functions.

    + XHTML-ified some HTML.

    + Wrapped a lot of text in the administrative pages in a t()
      function.

    + Replaced all $REQUEST_URI/$PATH_INFOs by request_uri().

    + Small bugfixes (eg. bug in book_export_html() and clean-ups (eg.
      RSS code).

    + Fixed some bugs in the taxonomy module (eg. tree making bug), added
      new functionality (eg. new APIs for use by other modules), included
      Moshe's taxonomy extensions, and some documentation udpates.

    + ...
2002-04-20 11:52:50 +00:00
Dries Buytaert 8c8b305892 - Added "query log" functionality to Drupal. Inspired by weitzman's
code/patch.
2001-12-23 21:47:02 +00:00
Dries Buytaert 7c181aba6d - Made some improvements/updates to the database abstraction layer. 2001-10-31 20:33:23 +00:00