User login

Drupal won't set values to NULL with db_query %d system

removed bug from taxonomy_location_save that was put in while trying, and failing, to put in a NULL value with a Drupal query

ben-agaric: Is there any special trick to getting db_query to stick a NULL into a database table? It allows NULL and I can set a value to NULL in phpMyAdmin
[7:35pm] beeradb: will you pastebin your query?
[7:37pm] ben-agaric: db_query("UPDATE {term_location} SET latitude = %d, longitude = %d WHERE tid = %d", $term_location['latitude'], $term_location['longitude'], $tid);
[7:37pm] ben-agaric: (doesn't really need pastebin!)
[7:38pm] ben-agaric: And I've replaced the variables with NULL directly, I think I tried putting the %d in '%d' and tried '%s' too....

beeradb: why not set latitude = null
[7:39pm] beeradb: directly in the query
[7:40pm] beeradb: asusming that's the field you want to set null, of course:)
[7:40pm] ben-agaric: So 'if my values are null, run an entirely different query' ?
[7:40pm] ben-agaric: I was sort of hoping that wasn't the Drupal way
[7:40pm] josh_k left the chat room. (Read error: 110 (Connection timed out))
[7:41pm] calebg: The Drupal way.......that makes you nutz.
[7:41pm] beeradb: well, it's really a sql thing, a empty variable or null in php isn't going to be translated in "null" in sql
[7:41pm] • calebg pets Drupal

Resolution

Searched words: 
beeradb drupal map

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.