Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Is there a Drupal's database version of mysql_data_seek() function? I'd like to use Drupal version of mysql_data_seek function as to maintain future compatibility.
Almost every table definition I've evaluated so far could be rewritten into portable code. That is, most MySQLisms I have come across are pointless and outdated - and could easily be avoided, making Drupal a much more cross-database solution than it currently is. That is, we should develop some essential database coding guidelines!
The boringly obvious point is of course to use standard SQL statements only - the MySQL and PostgreSQL documentation usually state whether a statement is compatible to standard SQL. As many people will rarely look up whether the statements they have been using for years are deprecated, here are a couple of recommendations to start with:
do not copy&paste your table definitions from a dump, or you will end up with the particular backends' database specific view of your design, often with some obsoleted indices and columns from discarded design stages thrown in. Design is a result of planning and consideration, not a snapshot from a trial-and-error process. Rethink, reorder and rewrite your code to be concise, logical and generic...
use standard generic data types, that is, integer rather than int(x). And choose text over varchar(y) unless you have very good reasons to use the latter
don't force table types - "MyISAM" won't only annoy people using other databases, but also the InnoDB users...
" and ` are not ' - portable SQL string literals are in single quotes (') only.
I just had some fun w/ debugging the hell out then realizing that boolean fields have values f and t and both of them is treated as TRUE by PHP. Do not use boolean fields with Drupal (well, I might say with PHP) or you'll need to convert all the time. Related bug in PEAR: http://pear.php.net/bugs/bug.php?id=4535 so I am not alone. The fact that PHP manual states this does not help too much -- all I saw were stuck checkboxes.
Hello, I have some suggestions how to improve MySQL script.
1) I suggest to rename all fields named 'timestamp', beacouse TIMESTAMP is MySQL data type. I had already several problems with this.
2) Add FOREIGN KEY constraints. This would:
a) greatly improve readability of database script
b) enables to reverse engineer and visualize the script properly with all bindings
c) db model will be prepared for future, when somebody decides to make use of foreign keys