Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
documentation
Priority:
Minor
Category:
Task
Assigned:
Reporter:
Created:
8 Aug 2013 at 03:03 UTC
Updated:
29 Jul 2014 at 22:44 UTC
Jump to comment: Most recent file
As part of #1533096: Make includes directory, files starting with D-G pass Coder Review I've noticed:
database.inc
* @code
* INSERT INTO {example} (id, uid, path, name) VALUES (1, 2, 'home', 'Home path');
* @endcode
* one would instead write:
* @code
* $fields = array('nid' => 1, 'title' => 'my title', 'body' => 'my body');
* db_insert('node')->fields($fields)->execute();
* @endcode
The example code above doesn't make sense, in the first part of the example we put 4 values into the 'example' table, in the second part of the example we put 3 different fields into a different table.
I suggest changing the second part of the example to match the table and fields in the first part.
I'll post a patch for this in a moment
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | database.inc_example-2060037-1.patch | 949 bytes | sphism |
Comments
Comment #0.0
sphism commentedadded backlink to original issue
Comment #1
sphism commentedHere's the new example, which i think makes more sense and is formatted correctly:
Comment #2
longwaveThat makes much more sense now.
Comment #3
sphism commentedGreat stuff, thanks for reviewing that so quickly @longwave
Comment #4
longwaveChecked to see if this needs backporting, but in D7 both examples use the node table. This was changed in D8 in #1498674: Refactor node properties to multilingual but the db_insert() example was missed.
Comment #5
jhodgdonThanks for the patch, review, and check for D7 backport needs! Committed to 8.x.
Comment #6.0
(not verified) commenteddatabase.inc