18.10.2016 Views

Drupal 7 Module Development

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Database Access<br />

Summary<br />

Although in practice it's surprising how often we won't need to deal with the<br />

database directly, we do in some way or the other. In this appendix we've seen how<br />

to leverage <strong>Drupal</strong>'s database layer to build powerful, cross-database queries that<br />

are, in many cases, easier to work with than SQL, while still mirroring actual SQL.<br />

• We've seen how to portably and securely write arbitrary SQL queries.<br />

• We've seen how to allow other modules to modify our queries before<br />

they're run.<br />

• We've seen how to write complex queries that change based on user input<br />

in a portable way.<br />

• We now know how to write data modification queries that will be<br />

automatically optimized for whatever database we happen to be using.<br />

• We've seen how to use transactions to make our code more robust and<br />

fault-tolerant.<br />

• We understand how to support master/slave replication to allow sites<br />

to scale to high levels of traffic.<br />

[ 374 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!