DrupalBin
Submit Code
About
Recent Posts
Code
2 hours 5 min
ago
Code
5 hours 17 min
ago
Fix for Code
5 hours 27 min
ago
d5, hook_comment, trying to force an input filter format
8 hours 45 min
ago
more
Tags
CCK
drupal
fapi
jquery
menu
module
Panels
php
simpletest
test
theme
views
more tags
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Create new account
Request new password
Log in using OpenID
Cancel OpenID login
Home
Fix for Random non-colliding computed field values
View
Download
Fix
This fix will not be saved to the database until you submit.
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Source code:
*
$rand = mt_rand(0, 1000000000); while ((int) db_result(db_query('SELECT COUNT(*) FROM content_type_<content_type_name> WHERE field_<fieldname> = %d', $rand)) > 0) { $rand = mt_rand(0, 1000000000); } $node_field[0]['value'] = $rand;
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal
Drupal 5
Drupal 6
HTML
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.