SlideShare a Scribd company logo
MySQL Cookbook 1st ed Edition Paul Dubois download
pdf
https://ebookfinal.com/download/mysql-cookbook-1st-ed-edition-paul-
dubois/
Visit ebookfinal.com today to download the complete set of
ebook or textbook!
Here are some recommended products that we believe you will be
interested in. You can click the link to download.
MySQL Cookbook 2nd Edition Solutions Examples for Database
Developers and DBAs Paul Dubois
https://ebookfinal.com/download/mysql-cookbook-2nd-edition-solutions-
examples-for-database-developers-and-dbas-paul-dubois/
MySQL Admin Cookbook 1st New edition Edition Daniel
Schneller
https://ebookfinal.com/download/mysql-admin-cookbook-1st-new-edition-
edition-daniel-schneller/
MySQL Cookbook 4th Edition Sveta Smirnova & Alkin Tezuysal
https://ebookfinal.com/download/mysql-cookbook-4th-edition-sveta-
smirnova-alkin-tezuysal/
Useful Quasicrystals 1st Edition Jean-Marie Dubois
https://ebookfinal.com/download/useful-quasicrystals-1st-edition-jean-
marie-dubois/
Python Cookbook 2nd ed Edition Alex Martelli
https://ebookfinal.com/download/python-cookbook-2nd-ed-edition-alex-
martelli/
Linux Security Cookbook 1st ed Edition Daniel J. Barrett
https://ebookfinal.com/download/linux-security-cookbook-1st-ed-
edition-daniel-j-barrett/
Access Data Analysis Cookbook 1st ed Edition Ken Bluttman
https://ebookfinal.com/download/access-data-analysis-cookbook-1st-ed-
edition-ken-bluttman/
Analog Circuits Cookbook 2nd ed Edition Ian Hickman
https://ebookfinal.com/download/analog-circuits-cookbook-2nd-ed-
edition-ian-hickman/
MySQL Crash Course Rick Silva
https://ebookfinal.com/download/mysql-crash-course-rick-silva/
MySQL Cookbook 1st ed Edition Paul Dubois
MySQL Cookbook 1st ed Edition Paul Dubois Digital
Instant Download
Author(s): Paul DuBois
ISBN(s): 9780596001452, 0596001452
Edition: 1st ed
File Details: PDF, 4.00 MB
Year: 2003
Language: english
MySQL Cookbook
By Paul DuBois
Publisher : O'Reilly
Pub Date : October 2002
ISBN : 0-596-00145-2
Pages : 1022
MySQL Cookbook provides a unique problem-and-solution format that offers practical
examples for everyday programming dilemmas. For every problem addressed in the book,
there's a worked-out solution or "recipe" -- short, focused pieces of code that you can insert
directly into your applications. More than a collection of cut-and-paste code, this book
explanation how and why the code works, so you can learn to adapt the techniques to similar
situations.
Copyright
Preface
MySQL APIs Used in This Book
Who This Book Is For
What's in This Book
Platform Notes
Conventions Used in This Book
The Companion Web Site
Comments and Questions
Additional Resources
Acknowledgments
Chapter 1. Using the mysql Client Program
Section 1.1. Introduction
Section 1.2. Setting Up a MySQL User Account
Section 1.3. Creating a Database and a Sample Table
Section 1.4. Starting and Terminating mysql
Section 1.5. Specifying Connection Parameters by Using Option Files
Section 1.6. Protecting Option Files
Section 1.7. Mixing Command-Line and Option File Parameters
Section 1.8. What to Do if mysql Cannot Be Found
Section 1.9. Setting Environment Variables
Section 1.10. Issuing Queries
Section 1.11. Selecting a Database
Section 1.12. Canceling a Partially Entered Query
Section 1.13. Repeating and Editing Queries
Section 1.14. Using Auto-Completion for Database and Table Names
Section 1.15. Using SQL Variables in Queries
Section 1.16. Telling mysql to Read Queries from a File
Section 1.17. Telling mysql to Read Queries from Other Programs
Section 1.18. Specifying Queries on the Command Line
Section 1.19. Using Copy and Paste as a mysql Input Source
Section 1.20. Preventing Query Output from Scrolling off the Screen
Section 1.21. Sending Query Output to a File or to a Program
Section 1.22. Selecting Tabular or Tab-Delimited Query Output Format
Section 1.23. Specifying Arbitrary Output Column Delimiters
Section 1.24. Producing HTML Output
Section 1.25. Producing XML Output
Section 1.26. Suppressing Column Headings in Query Output
Section 1.27. Numbering Query Output Lines
Section 1.28. Making Long Output Lines More Readable
Section 1.29. Controlling mysql's Verbosity Level
Section 1.30. Logging Interactive mysql Sessions
Section 1.31. Creating mysql Scripts from Previously Executed Queries
Section 1.32. Using mysql as a Calculator
Section 1.33. Using mysql in Shell Scripts
Chapter 2. Writing MySQL-Based Programs
Section 2.1. Introduction
Section 2.2. Connecting to the MySQL Server, Selecting a Database, and Disconnecting
Section 2.3. Checking for Errors
Section 2.4. Writing Library Files
Section 2.5. Issuing Queries and Retrieving Results
Section 2.6. Moving Around Within a Result Set
Section 2.7. Using Prepared Statements and Placeholders in Queries
Section 2.8. Including Special Characters and NULL Values in Queries
Section 2.9. Handling NULL Values in Result Sets
Section 2.10. Writing an Object-Oriented MySQL Interface for PHP
Section 2.11. Ways of Obtaining Connection Parameters
Section 2.12. Conclusion and Words of Advice
Chapter 3. Record Selection Techniques
Section 3.1. Introduction
Section 3.2. Specifying Which Columns to Display
Section 3.3. Avoiding Output Column Order Problems When Writing Programs
Section 3.4. Giving Names to Output Columns
Section 3.5. Using Column Aliases to Make Programs Easier to Write
Section 3.6. Combining Columns to Construct Composite Values
Section 3.7. Specifying Which Rows to Select
Section 3.8. WHERE Clauses and Column Aliases
Section 3.9. Displaying Comparisons to Find Out How Something Works
Section 3.10. Reversing or Negating Query Conditions
Section 3.11. Removing Duplicate Rows
Section 3.12. Working with NULL Values
Section 3.13. Negating a Condition on a Column That Contains NULL Values
Section 3.14. Writing Comparisons Involving NULL in Programs
Section 3.15. Mapping NULL Values to Other Values for Display
Section 3.16. Sorting a Result Set
Section 3.17. Selecting Records from the Beginning or End of a Result Set
Section 3.18. Pulling a Section from the Middle of a Result Set
Section 3.19. Choosing Appropriate LIMIT Values
Section 3.20. Calculating LIMIT Values from Expressions
Section 3.21. What to Do When LIMIT Requires the "Wrong" Sort Order
Section 3.22. Selecting a Result Set into an Existing Table
Section 3.23. Creating a Destination Table on the Fly from a Result Set
Section 3.24. Moving Records Between Tables Safely
Section 3.25. Creating Temporary Tables
Section 3.26. Cloning a Table Exactly
Section 3.27. Generating Unique Table Names
Chapter 4. Working with Strings
Section 4.1. Introduction
Section 4.2. Writing Strings That Include Quotes or Special Characters
Section 4.3. Preserving Trailing Spaces in String Columns
Section 4.4. Testing String Equality or Relative Ordering
Section 4.5. Decomposing or Combining Strings
Section 4.6. Checking Whether a String Contains a Substring
Section 4.7. Pattern Matching with SQL Patterns
Section 4.8. Pattern Matching with Regular Expressions
Section 4.9. Matching Pattern Metacharacters Literally
Section 4.10. Controlling Case Sensitivity in String Comparisons
Section 4.11. Controlling Case Sensitivity in Pattern Matching
Section 4.12. Using FULLTEXT Searches
Section 4.13. Using a FULLTEXT Search with Short Words
Section 4.14. Requiring or Excluding FULLTEXT Search Words
Section 4.15. Performing Phrase Searches with a FULLTEXT Index
Chapter 5. Working with Dates and Times
Section 5.1. Introduction
Section 5.2. Changing MySQL's Date Format
Section 5.3. Telling MySQL How to Display Dates or Times
Section 5.4. Determining the Current Date or Time
Section 5.5. Decomposing Dates and Times Using Formatting Functions
Section 5.6. Decomposing Dates or Times Using Component-Extraction Functions
Section 5.7. Decomposing Dates or Times Using String Functions
Section 5.8. Synthesizing Dates or Times Using Formatting Functions
Section 5.9. Synthesizing Dates or Times Using Component-Extraction Functions
Section 5.10. Combining a Date and a Time into a Date-and-Time Value
Section 5.11. Converting Between Times and Seconds
Section 5.12. Converting Between Dates and Days
Section 5.13. Converting Between Date-and-Time Values and Seconds
Section 5.14. Adding a Temporal Interval to a Time
Section 5.15. Calculating Intervals Between Times
Section 5.16. Breaking Down Time Intervals into Components
Section 5.17. Adding a Temporal Interval to a Date
Section 5.18. Calculating Intervals Between Dates
Section 5.19. Canonizing Not-Quite-ISO Date Strings
Section 5.20. Calculating Ages
Section 5.21. Shifting Dates by a Known Amount
Section 5.22. Finding First and Last Days of Months
Section 5.23. Finding the Length of a Month
Section 5.24. Calculating One Date from Another by Substring Replacement
Section 5.25. Finding the Day of the Week for a Date
Section 5.26. Finding Dates for Days of the Current Week
Section 5.27. Finding Dates for Weekdays of Other Weeks
Section 5.28. Performing Leap Year Calculations
Section 5.29. Treating Dates or Times as Numbers
Section 5.30. Forcing MySQL to Treat Strings as Temporal Values
Section 5.31. Selecting Records Based on Their Temporal Characteristics
Section 5.32. Using TIMESTAMP Values
Section 5.33. Recording a Row's Last Modification Time
Section 5.34. Recording a Row's Creation Time
Section 5.35. Performing Calculations with TIMESTAMP Values
Section 5.36. Displaying TIMESTAMP Values in Readable Form
Chapter 6. Sorting Query Results
Section 6.1. Introduction
Section 6.2. Using ORDER BY to Sort Query Results
Section 6.3. Sorting Subsets of a Table
Section 6.4. Sorting Expression Results
Section 6.5. Displaying One Set of Values While Sorting by Another
Section 6.6. Sorting and NULL Values
Section 6.7. Controlling Case Sensitivity of String Sorts
Section 6.8. Date-Based Sorting
Section 6.9. Sorting by Calendar Day
Section 6.10. Sorting by Day of Week
Section 6.11. Sorting by Time of Day
Section 6.12. Sorting Using Substrings of Column Values
Section 6.13. Sorting by Fixed-Length Substrings
Section 6.14. Sorting by Variable-Length Substrings
Section 6.15. Sorting Hostnames in Domain Order
Section 6.16. Sorting Dotted-Quad IP Values in Numeric Order
Section 6.17. Floating Specific Values to the Head or Tail of the Sort Order
Section 6.18. Sorting in User-Defined Orders
Section 6.19. Sorting ENUM Values
Chapter 7. Generating Summaries
Section 7.1. Introduction
Section 7.2. Summarizing with COUNT( )
Section 7.3. Summarizing with MIN( ) and MAX( )
Section 7.4. Summarizing with SUM( ) and AVG( )
Section 7.5. Using DISTINCT to Eliminate Duplicates
Section 7.6. Finding Values Associated with Minimum and Maximum Values
Section 7.7. Controlling String Case Sensitivity for MIN( ) and MAX( )
Section 7.8. Dividing a Summary into Subgroups
Section 7.9. Summaries and NULL Values
Section 7.10. Selecting Only Groups with Certain Characteristics
Section 7.11. Determining Whether Values are Unique
Section 7.12. Grouping by Expression Results
Section 7.13. Categorizing Non-Categorical Data
Section 7.14. Controlling Summary Display Order
Section 7.15. Finding Smallest or Largest Summary Values
Section 7.16. Date-Based Summaries
Section 7.17. Working with Per-Group and Overall Summary Values Simultaneously
Section 7.18. Generating a Report That Includes a Summary and a List
Chapter 8. Modifying Tables with ALTER TABLE
Section 8.1. Introduction
Section 8.2. Dropping, Adding, or Repositioning a Column
Section 8.3. Changing a Column Definition or Name
Section 8.4. The Effect of ALTER TABLE on Null and Default Value Attributes
Section 8.5. Changing a Column's Default Value
Section 8.6. Changing a Table Type
Section 8.7. Renaming a Table
Section 8.8. Adding or Dropping Indexes
Section 8.9. Eliminating Duplicates by Adding an Index
Section 8.10. Using ALTER TABLE to Normalize a Table
Chapter 9. Obtaining and Using Metadata
Section 9.1. Introduction
Section 9.2. Obtaining the Number of Rows Affected by a Query
Section 9.3. Obtaining Result Set Metadata
Section 9.4. Determining Presence or Absence of a Result Set
Section 9.5. Formatting Query Results for Display
Section 9.6. Getting Table Structure Information
Section 9.7. Getting ENUM and SET Column Information
Section 9.8. Database-Independent Methods of Obtaining Table Information
Section 9.9. Applying Table Structure Information
Section 9.10. Listing Tables and Databases
Section 9.11. Testing Whether a Table Exists
Section 9.12. Testing Whether a Database Exists
Section 9.13. Getting Server Metadata
Section 9.14. Writing Applications That Adapt to the MySQL Server Version
Section 9.15. Determining the Current Database
Section 9.16. Determining the Current MySQL User
Section 9.17. Monitoring the MySQL Server
Section 9.18. Determining Which Table Types the Server Supports
Chapter 10. Importing and Exporting Data
Section 10.1. Introduction
Section 10.2. Importing Data with LOAD DATA and mysqlimport
Section 10.3. Specifying the Datafile Location
Section 10.4. Specifying the Datafile Format
Section 10.5. Dealing with Quotes and Special Characters
Section 10.6. Importing CSV Files
Section 10.7. Reading Files from Different Operating Systems
Section 10.8. Handling Duplicate Index Values
Section 10.9. Getting LOAD DATA to Cough Up More Information
Section 10.10. Don't Assume LOAD DATA Knows More than It Does
Section 10.11. Skipping Datafile Lines
Section 10.12. Specifying Input Column Order
Section 10.13. Skipping Datafile Columns
Section 10.14. Exporting Query Results from MySQL
Section 10.15. Exporting Tables as Raw Data
Section 10.16. Exporting Table Contents or Definitions in SQL Format
Section 10.17. Copying Tables or Databases to Another Server
Section 10.18. Writing Your Own Export Programs
Section 10.19. Converting Datafiles from One Format to Another
Section 10.20. Extracting and Rearranging Datafile Columns
Section 10.21. Validating and Transforming Data
Section 10.22. Validation by Direct Comparison
Section 10.23. Validation by Pattern Matching
Section 10.24. Using Patterns to Match Broad Content Types
Section 10.25. Using Patterns to Match Numeric Values
Section 10.26. Using Patterns to Match Dates or Times
Section 10.27. Using Patterns to Match Email Addresses and URLs
Section 10.28. Validation Using Table Metadata
Section 10.29. Validation Using a Lookup Table
Section 10.30. Converting Two-Digit Year Values to Four-Digit Form
Section 10.31. Performing Validity Checking on Date or Time Subparts
Section 10.32. Writing Date-Processing Utilities
Section 10.33. Using Dates with Missing Components
Section 10.34. Performing Date Conversion Using SQL
Section 10.35. Using Temporary Tables for Data Transformation
Section 10.36. Dealing with NULL Values
Section 10.37. Guessing Table Structure from a Datafile
Section 10.38. A LOAD DATA Diagnostic Utility
Section 10.39. Exchanging Data Between MySQL and Microsoft Access
Section 10.40. Exchanging Data Between MySQL and Microsoft Excel
Section 10.41. Exchanging Data Between MySQL and FileMaker Pro
Section 10.42. Exporting Query Results as XML
Section 10.43. Importing XML into MySQL
Section 10.44. Epilog
Chapter 11. Generating and Using Sequences
Section 11.1. Introduction
Section 11.2. Using AUTO_INCREMENT To Set Up a Sequence Column
Section 11.3. Generating Sequence Values
Section 11.4. Choosing the Type for a Sequence Column
Section 11.5. The Effect of Record Deletions on Sequence Generation
Section 11.6. Retrieving Sequence Values
Section 11.7. Determining Whether to Resequence a Column
Section 11.8. Extending the Range of a Sequence Column
Section 11.9. Renumbering an Existing Sequence
Section 11.10. Reusing Values at the Top of a Sequence
Section 11.11. Ensuring That Rows Are Renumbered in a Particular Order
Section 11.12. Starting a Sequence at a Particular Value
Section 11.13. Sequencing an Unsequenced Table
Section 11.14. Using an AUTO_INCREMENT Column to Create Multiple Sequences
Section 11.15. Managing Multiple SimultaneousAUTO_INCREMENT Values
Section 11.16. Using AUTO_INCREMENT Valuesto Relate Tables
Section 11.17. Using Single-Row Sequence Generators
Section 11.18. Generating Repeating Sequences
Section 11.19. Numbering Query Output Rows Sequentially
Chapter 12. Using Multiple Tables
Section 12.1. Introduction
Section 12.2. Combining Rows in One Table with Rows in Another
Section 12.3. Performing a Join Between Tables in Different Databases
Section 12.4. Referring to Join Output Column Names in Programs
Section 12.5. Finding Rows in One Table That Match Rows in Another
Section 12.6. Finding Rows with No Match in Another Table
Section 12.7. Finding Rows Containing Per-Group Minimum or Maximum Values
Section 12.8. Computing Team Standings
Section 12.9. Producing Master-Detail Lists and Summaries
Section 12.10. Using a Join to Fill in Holes in a List
Section 12.11. Enumerating a Many-to-Many Relationship
Section 12.12. Comparing a Table to Itself
Section 12.13. Calculating Differences Between Successive Rows
Section 12.14. Finding Cumulative Sums and Running Averages
Section 12.15. Using a Join to Control Query Output Order
Section 12.16. Converting Subselects to Join Operations
Section 12.17. Selecting Records in Parallel from Multiple Tables
Section 12.18. Inserting Records in One Table That Include Values from Another
Section 12.19. Updating One Table Based on Values in Another
Section 12.20. Using a Join to Create a Lookup Table from Descriptive Labels
Section 12.21. Deleting Related Rows in Multiple Tables
Section 12.22. Identifying and Removing Unattached Records
Section 12.23. Using Different MySQL Servers Simultaneously
Chapter 13. Statistical Techniques
Section 13.1. Introduction
Section 13.2. Calculating Descriptive Statistics
Section 13.3. Per-Group Descriptive Statistics
Section 13.4. Generating Frequency Distributions
Section 13.5. Counting Missing Values
Section 13.6. Calculating Linear Regressions or Correlation Coefficients
Section 13.7. Generating Random Numbers
Section 13.8. Randomizing a Set of Rows
Section 13.9. Selecting Random Items from a Set of Rows
Section 13.10. Assigning Ranks
Chapter 14. Handling Duplicates
Section 14.1. Introduction
Section 14.2. Preventing Duplicates from Occurring in a Table
Section 14.3. Dealing with Duplicates at Record-Creation Time
Section 14.4. Counting and Identifying Duplicates
Section 14.5. Eliminating Duplicates from a Query Result
Section 14.6. Eliminating Duplicates from a Self-Join Result
Section 14.7. Eliminating Duplicates from a Table
Chapter 15. Performing Transactions
Section 15.1. Introduction
Section 15.2. Verifying Transaction Support Requirements
Section 15.3. Performing Transactions Using SQL
Section 15.4. Performing Transactions from Within Programs
Section 15.5. Using Transactions in Perl Programs
Section 15.6. Using Transactions in PHP Programs
Section 15.7. Using Transactions in Python Programs
Section 15.8. Using Transactions in Java Programs
Section 15.9. Using Alternatives to Transactions
Chapter 16. Introduction to MySQL on the Web
Section 16.1. Introduction
Section 16.2. Basic Web Page Generation
Section 16.3. Using Apache to Run Web Scripts
Section 16.4. Using Tomcat to Run Web Scripts
Section 16.5. Encoding Special Characters in Web Output
Chapter 17. Incorporating Query Resultsinto Web Pages
Section 17.1. Introduction
Section 17.2. Displaying Query Results as Paragraph Text
Section 17.3. Displaying Query Results as Lists
Section 17.4. Displaying Query Results as Tables
Section 17.5. Displaying Query Results as Hyperlinks
Section 17.6. Creating a Navigation Index from Database Content
Section 17.7. Storing Images or Other Binary Data
Section 17.8. Retrieving Images or Other Binary Data
Section 17.9. Serving Banner Ads
Section 17.10. Serving Query Results for Download
Chapter 18. Processing Web Input with MySQL
Section 18.1. Introduction
Section 18.2. Creating Forms in Scripts
Section 18.3. Creating Single-Pick Form Elements from Database Content
Section 18.4. Creating Multiple-Pick Form Elements from Database Content
Section 18.5. Loading a Database Record into a Form
Section 18.6. Collecting Web Input
Section 18.7. Validating Web Input
Section 18.8. Using Web Input to Construct Queries
Section 18.9. Processing File Uploads
Section 18.10. Performing Searches and Presenting the Results
Section 18.11. Generating Previous-Page and Next-Page Links
Section 18.12. Generating "Click to Sort" Table Headings
Section 18.13. Web Page Access Counting
Section 18.14. Web Page Access Logging
Section 18.15. Using MySQL for Apache Logging
Chapter 19. Using MySQL-Based Web Session Management
Section 19.1. Introduction
Section 19.2. Using MySQL-Based Sessions in Perl Applications
Section 19.3. Using MySQL-Based Storage with the PHP Session Manager
Section 19.4. Using MySQL for Session BackingStore with Tomcat
Appendix A. Obtaining MySQL Software
Section A.1. Obtaining Sample Source Code and Data
Section A.2. Obtaining MySQL and Related Software
Appendix B. JSP and Tomcat Primer
Section B.1. Servlet and JavaServer Pages Overview
Section B.2. Setting Up a Tomcat Server
Section B.3. Web Application Structure
Section B.4. Elements of JSP Pages
Appendix C. References
Section C.1. MySQL Resources
Section C.2. Perl Resources
Section C.3. PHP Resources
Section C.4. Python Resources
Section C.5. Java Resources
Section C.6. Apache Resources
Section C.7. Other Resources
Colophon
Index
Preface
The MySQL database management system has become quite popular in recent years. This has
been true especially in the Linux and open source communities, but MySQL's presence in the
commercial sector now is increasing as well. It is well liked for several reasons: MySQL is fast,
and it's easy to set up, use, and administrate. MySQL runs under many varieties of Unix and
Windows, and MySQL-based programs can be written in many languages. MySQL is especially
heavily used in combination with a web server for constructing database-backed web sites that
involve dynamic content generation.
With MySQL's rise in popularity comes the need to address the questions posed by its users
about how to solve specific problems. That is the purpose of MySQL Cookbook. It's designed to
serve as a handy resource to which you can turn when you need quick solutions or techniques
for attacking particular types of questions that come up when you use MySQL. Naturally,
because it's a cookbook, it contains recipes: straightforward instructions you can follow rather
than develop your own code from scratch. It's written using a problem-and-solution format
designed to be extremely practical and to make the contents easy to read and assimilate. It
contains many short sections, each describing how to write a query, apply a technique, or
develop a script to solve a problem of limited and specific scope. This book doesn't attempt to
develop full-fledged applications. Instead, it's intended to assist you in developing such
applications yourself by helping you get past problems that have you stumped.
For example, a common question is, "How can I deal with quotes and special characters in
data values when I'm writing queries?" That's not difficult, but figuring out how to do it is
frustrating when you're not sure where to start. This book demonstrates what to do; it shows
you where to begin and how to proceed from there. This knowledge will serve you repeatedly,
because after you see what's involved, you'll be able to apply the technique to any kind of
data, such as text, images, sound or video clips, news articles, compressed files, PDF files, or
word processing documents. Another common question is, "Can I access tables from two
databases at the same time?" The answer is "Yes," and it's easy to do because it's just a
matter of knowing the proper SQL syntax. But it's hard to do until you see how; this book will
show you. Other things that you'll learn from this book include:
• How to use SQL to select, sort, and summarize records.
• How to find matches or mismatches between records in two tables.
• How to perform a transaction.
• How to determine intervals between dates or times, including age calculations.
• How to remove duplicate records.
• How to store images into MySQL and retrieve them for display in web pages.
• How to convert the legal values of an ENUM column into radio buttons in a web page,
or the values of a SET column into checkboxes.
• How to get LOAD DATA to read your datafiles properly, or find out which values in the
file are bad.
• How to use pattern matching techniques to cope with mismatches between the CCYY-
MM-DD date format that MySQL uses and dates in your datafiles.
• How to copy a table or a database to another server.
• How to resequence a sequence number column, and why you really don't want to.
One part of knowing how to use MySQL is understanding how to communicate with the
server—that is, how to use SQL, the language through which queries are formulated.
Therefore, one major emphasis of this book is on using SQL to formulate queries that answer
particular kinds of questions. One helpful tool for learning and using SQL is the mysql client
program that is included in MySQL distributions. By using this client interactively, you can
send SQL statements to the server and see the results. This is extremely useful because it
provides a direct interface to SQL. The mysql client is so useful, in fact, that the entire first
chapter is devoted to it.
But the ability to issue SQL queries alone is not enough. Information extracted from a
database often needs to be processed further or presented in a particular way to be useful.
What if you have queries with complex interrelationships, such as when you need to use the
results of one query as the basis for others? SQL by itself has little facility for making these
kinds of choices, which makes it difficult to use decision-based logic to determine which
queries to execute. Or what if you need to generate a specialized report with very specific
formatting requirements? This too is difficult to achieve using just SQL. These problems bring
us to the other major emphasis of the book—how to write programs that interact with the
MySQL server through an application programming interface (API). When you know how to
use MySQL from within the context of a programming language, you gain the ability to exploit
MySQL's capabilities in the following ways:
• You can remember the result from a query and use it at a later time.
• You can make decisions based on success or failure of a query, or on the content of
the rows that are returned. Difficulties in implementing control flow disappear when
using an API because the host language provides facilities for expressing decision-
based logic: if-then-else constructs, while loops, subroutines, and so forth.
• You can format and display query results however you like. If you're writing a
command-line script, you can generate plain text. If it's a web-based script, you can
generate an HTML table. If it's an application that extracts information for transfer to
some other system, you might write a datafile expressed in XML.
When you combine SQL with a general purpose programming language and a MySQL client
API, you have an extremely flexible framework for issuing queries and processing their results.
Programming languages increase your expressive capabilities by giving you a great deal of
additional power to perform complex database operations. This doesn't mean this book is
complicated, though. It keeps things simple, showing how to construct small building blocks
by using techniques that are easy to understand and easily mastered.
I'll leave it to you to combine these techniques within your own programs, which you can do to
produce arbitrarily complex applications. After all, the genetic code is based on only four
nucleic acids, but these basic elements have been combined to produce the astonishing array
of biological life we see all around us. Similarly, there are only 12 notes in the scale, but in the
hands of skilled composers, they can be interwoven to produce a rich and endless variety of
music. In the same way, when you take a set of simple recipes, add your imagination, and
apply them to the database programming problems you want to solve, you can produce that
are perhaps not works of art, but certainly applications that are useful and that will help you
and others be more productive.
MySQL APIs Used in This Book
MySQL programming interfaces exist for many languages, including (in alphabetical order) C,
C++, Eiffel, Java, Pascal, Perl, PHP, Python, Ruby, Smalltalk, and Tcl.[]
Given this fact, writing
a MySQL cookbook presents an author with something of a challenge. Clearly the book should
provide recipes for doing many interesting and useful things with MySQL, but which API or
APIs should the book use? Showing an implementation of every recipe in every language
would result either in covering very few recipes or in a very, very large book! It would also
result in a lot of redundancy when implementations in different languages bear a strong
resemblance to each other. On the other hand, it's worthwhile taking advantage of multiple
languages, because one language often will be more suitable than another for solving a
particular type of problem.
[]
To see what APIs are currently available, visit the development portal at the
MySQL web site, located at http://www.mysql.com/portal/development/html/.
To resolve this dilemma, I've picked a small number of APIs from among those that are
available and used them to write the recipes in this book. This limits its scope to a manageable
number of APIs while allowing some latitude to choose from among them. The primary APIs
covered here are:
Perl
Using the DBI module and its MySQL-specific driver
PHP
Using its set of built-in MySQL support functions
Python
Using the DB-API module and its MySQL-specific driver
Java
Using a MySQL-specific driver for the Java Database Connectivity (JDBC) interface
Why these languages? Perl and PHP were easy to pick. Perl is arguably the most widely used
language on the Web, and it became so based on certain strengths such as its text-processing
capabilities. In particular, it's very popular for writing MySQL programs. PHP also is widely
deployed, and its use is increasing steadily. One of PHP's strengths is the ease with which you
can use it to access databases, making it a natural choice for MySQL scripting. Python and
Java are not as popular as Perl or PHP for MySQL programming, but each has significant
numbers of followers. In the Java community in particular, MySQL seems to be making strong
inroads among developers who use JavaServer Pages (JSP) technology to build database-
backed web applications. (An anecdotal observation: After I wrote MySQL (New Riders),
Python and Java were the two languages not covered in that book that readers most often
said they would have liked to have seen addressed. So here they are!)
I believe these languages taken together reflect pretty well the majority of the existing user
base of MySQL programmers. If you prefer some language not shown here, you can still use
this book, but be sure to pay careful attention to Chapter 2, to familiarize yourself with the
book's primary API languages. Knowing how database operations are performed with the APIs
used here will help you understand the recipes in later chapters so that you can translate them
into languages not discussed.
Who This Book Is For
This book should be useful for anybody who uses MySQL, ranging from novices who want to
use a database for personal reasons, to professional database and web developers. The book
should also appeal to people who do not now use MySQL, but would like to. For example, it
should be useful to beginners who want to learn about databases but realize that Oracle isn't
the best choice for that.
If you're relatively new to MySQL, you'll probably find lots of ways to use it here that you
hadn't thought of. If you're more experienced, you'll probably be familiar with many of the
problems addressed here, but you may not have had to solve them before and should find the
book a great timesaver; take advantage of the recipes given in the book and use them in your
own programs rather than figuring out how to write the code from scratch.
The book also can be useful for people who aren't even using MySQL. You might suppose that
because this is a MySQL cookbook and not a PostgreSQL cookbook or an InterBase cookbook
that it won't apply to databases other than MySQL. To some extent that's true, because some
of the SQL constructs are MySQL-specific. On the other hand, many of the queries are
standard SQL that is portable to many other database engines, so you should be able to use
them with little or no modification. And several of our programming language interfaces
provide database-independent access methods; you use them the same way regardless of
which database you're connecting to.
The material ranges from introductory to advanced, so if a recipe describes techniques that
seem obvious to you, skip it. Or if you find that you don't understand a recipe, it may be best
to set it aside for a while and come back to it later, perhaps after reading some of the
preceding recipes.
More advanced readers may wonder on occasion why in a book on MySQL I sometimes
provide explanatory material on certain basic topics that are not directly MySQL-related, such
as how to set environment variables. I decided to do this based on my experience in helping
novice MySQL users. One thing that makes MySQL attractive is that it is easy to use, which
makes it a popular choice for people without extensive background in databases. However,
many of these same people also tend to be thwarted by simple barriers to more effective use
of MySQL, as evidenced by the common question, "How can I avoid having to type the full
pathname of mysql each time I invoke it?" Experienced readers will recognize immediately
that this is simply a matter of appropriately setting the PATH environment variable to include
the directory where mysql is installed. But other readers will not, particularly Windows users
who are used to dealing only with a graphical interface and, more recently, Mac OS X users
who find their familiar user interface now augmented by the powerful but sometimes
mysterious command line provided by the Terminal application. If you are in this situation,
you'll find these more elementary sections helpful in knocking down barriers that keep you
from using MySQL more easily. If you're a more advanced user, just skip over such sections.
What's in This Book
It's very likely when you use this book that you'll have an application in mind you're trying to
develop but are not sure how to implement certain pieces of it. In this case, you'll already
know what type of problem you want to solve, so you should search the table of contents or
the index looking for a recipe that shows how to do what you want. Ideally, the recipe will be
just what you had in mind. Failing that, you should be able to find a recipe for a similar
problem that you can adapt to suit the issue at hand. (I try to explain the principles involved
in developing each technique so that you'll be able to modify it to fit the particular
requirements of your own applications.)
Another way to approach this book is to just read through it with no specific problem in mind.
This can help you because it will give you a broader understanding of the things MySQL can
do, so I recommend that you page through the book occasionally. It's a more effective tool if
you have a general familiarity with it and know the kinds of problems it addresses. The
following paragraphs summarize each chapter, to help give you an overview of the book's
contents.
Chapter 1, describes how to use the standard MySQL command-line client. mysql is often the
first interface to MySQL that people use, and it's important to know how to exploit its
capabilities. This program allows you to issue queries and see the results interactively, so it's
good for quick experimentation. You can also use it in batch mode to execute canned SQL
scripts or send its output into other programs. In addition, the chapter discusses other ways to
use mysql, such as how to number output lines or make long lines more readable, how to
generate various output formats, and how to log mysql sessions.
Chapter 2, demonstrates the basic elements of MySQL programming in each API language:
how to connect to the server, issue queries, retrieve the results, and handle errors. It also
discusses how to handle special characters and NULL values in queries, how to write library
files to encapsulate code for commonly used operations, and various ways to gather the
parameters needed for making connections to the server.
Chapter 3, covers several aspects of the SELECT statement, which is the primary vehicle for
retrieving data from the MySQL server: specifying which columns and rows you want to
retrieve, performing comparisons, dealing with NULL values, selecting one section of a query
result, using temporary tables, and copying results into other tables. Later chapters cover
some of these topics in more detail, but this chapter provides an overview of the concepts on
which they depend. You should read it if you need some introductory background on record
selection, for example, if you don't yet know a lot about SQL.
Chapter 4, describes how to deal with string data. It addresses string comparisons, pattern
matching, breaking apart and combining strings, dealing with case-sensitivity issues, and
performing FULLTEXT searches.
Chapter 5, shows how to work with temporal data. It describes MySQL's date format and how
to display date values in other formats. It also covers conversion between different temporal
units, how to perform date arithmetic to compute intervals or generate one date from another,
leap-year calculations, and how to use MySQL's special TIMESTAMP column type.
Chapter 6, describes how to put the rows of a query result in the order you want. This includes
specifying the sort direction, dealing with NULL values, accounting for string case sensitivity,
and sorting by dates or partial column values. It also provides examples that show how to sort
special kinds of values, such as domain names, IP numbers, and ENUM values.
Chapter 7, shows techniques that are useful for assessing the general characteristics of a set
of data, such as how many values it contains or what the minimum, maximum, or average
values are.
Chapter 8, describes how to alter the structure of tables by adding, dropping, or modifying
columns, and how to set up indexes.
Chapter 9, discusses how to get information about the data a query returns, such as the
number of rows or columns in the result, or the name and type of each column. It also shows
how to ask MySQL what databases and tables are available or about the structure of a table
and its columns.
Chapter 10, describes how to transfer information between MySQL and other programs. This
includes how to convert files from one format to another, extract or rearrange columns in
datafiles, check and validate data, rewrite values such as dates that often come in a variety of
formats, and how to figure out which data values cause problems when you load them into
MySQL with LOAD DATA.
Chapter 11, discusses AUTO_INCREMENT columns, MySQL's mechanism for producing
sequence numbers. It shows how to generate new sequence values or determine the most
recent value, how to resequence a column, how to begin a sequence at a given value, and
how to set up a table so that it can maintain multiple sequences at once. It also shows how to
use AUTO_INCREMENT values to maintain a master-detail relationship between tables,
including some of the pitfalls to avoid.
Chapter 12, shows how to perform joins, which are operations that combine rows in one table
with those from another. It demonstrates how to compare tables to find matches or
mismatches, produce master-detail lists and summaries, enumerate many-to-many
relationships, and update or delete records in one table based on the contents of another.
Chapter 13, illustrates how to produce descriptive statistics, frequency distributions,
regressions, and correlations. It also covers how to randomize a set of rows or pick a row at
random from the set.
Chapter 14, discusses how to identify, count, and remove duplicate records—and how to
prevent them from occurring in the first place.
Chapter 15, shows how to handle multiple SQL statements that must execute together as a
unit. It discusses how to control MySQL's auto-commit mode, how to commit or roll back
transactions, and demonstrates some workarounds you can use if transactional capabilities are
unavailable in your version of MySQL.
Chapter 16, gets you set up to write web-based MySQL scripts. Web programming allows you
to generate dynamic pages or collect information for storage in your database. The chapter
discusses how to configure Apache to run Perl, PHP, and Python scripts, and how to configure
Tomcat to run Java scripts written using JSP notation. It also provides an overview of the Java
Standard Tag Library (JSTL) that is used heavily in JSP pages in the following chapters.
Chapter 17, shows how to use the results of queries to produce various types of HTML
structures, such as paragraphs, lists, tables, hyperlinks, and navigation indexes. It also
describes how to store images into MySQL, retrieve and display them later, and how to send a
downloadable result set to a browser.
Chapter 18, discusses ways to obtain input from users over the Web and use it to create new
database records or as the basis for performing searches. It deals heavily with form
processing, including how to construct form elements, such as radio buttons, pop-up menus,
or checkboxes, based on information contained in your database.
Chapter 19, describes how to write web applications that remember information across
multiple requests, using MySQL for backing store. This is useful when you want to collect
information in stages, or when you need to make decisions based on what the user has done
earlier.
Appendix A, indicates where to get the source code for the examples shown in this book, and
where to get the software you need to use MySQL and write your own database programs.
Appendix B, provides a general overview of JSP and installation instructions for the Tomcat
web server. Read this if you need to install Tomcat or are not familiar with it, or if you're
never written JSP pages.
Appendix C, lists sources of information that provide additional information about topics
covered in this book. It also lists some books that provide introductory background for the
programming languages used here.
As you get into later chapters, you'll sometimes find recipes that assume a knowledge of
topics covered in earlier chapters. This also applies within a chapter, where later sections often
use techniques discussed earlier in the chapter. If you jump into a chapter and find a recipe
that uses a technique with which you're not familiar, check the table of contents or the index
to find out where the technique is covered. You should find that it's been explained earlier. For
example, if you find that a recipe sorts a query result using an ORDER BY clause that you don't
understand, turn to Chapter 6, which discusses various sorting methods and explains how
they work.
Platform Notes
Development of the code in this book took place under MySQL 3.23 and 4.0. Because new
features are added to MySQL on a regular basis, some examples will not work under older
versions. I've tried to point out version dependencies when introducing such features for the
first time.
The MySQL language API modules that I used include DBI 1.20 and up, DBD::mysql 2.0901
and up, MySQLdb 0.9 and up, MM.MySQL 2.0.5 and up, and MySQL Connector/J 2.0.14. DBI
requires Perl 5.004_05 or higher up through DBI 1.20, after which it requires Perl 5.005_03 or
higher. MySQLdb requires Python 1.5.6 or higher. MM.MySQL and MySQL Connector/J require
Java SDK 1.1 or higher.
Language processors include Perl 5.6 and 5.6.1; PHP 3 and 4; Python 1.5.6, 2.2; and 2.3, and
Java SDK 1.3.1. Most PHP scripts shown here will run under either PHP 3 or PHP 4 (although I
strongly recommend PHP 4 over PHP 3). Scripts that require PHP 4 are so noted.
I do not assume that you are using Unix, although that is my own preferred development
platform. Most of the material here should be applicable both to Unix and Windows. The
operating systems I used most for development of the recipes in this book were Mac OS X;
RedHat Linux 6.2, 7.0, and 7.3; and various versions of Windows (Me, 98, NT, and 2000).
I do assume that MySQL is installed already and available for you to use. I also assume that if
you plan to write your own MySQL-based programs, you're reasonably familiar with the
language you'll use. If you need to install software, see Appendix A. If you require background
material on the programming languages used here, see Appendix C.
Random documents with unrelated
content Scribd suggests to you:
future of poverty and debt before him if he marries without a fortune.
I can save him from all this. I am rich enough for both. Say that you
will not stand in my way. I will remove the only obstacle in his path. I
will give up everything. I will stay in this tedious land for his sake. He
shall pursue any career he chooses. Think well what it is to rob such
a man of his only chance of fortune and ease. For if he does not
marry me, he will certainly marry you.”
Olivia sat upright in her chair completely dazed. She forgot to be
indignant. For the first time the truth enunciated by Madame Koller
came home to her. Pembroke was poor. He was extravagant. He
was bent upon entering politics. Olivia had, as most women, a
practical sympathy. She knew very well the horrors of poverty for
such a man, and her portion would be but small.
Madame Koller, seeing that she had made her impression, waited
—and after a while continued. Her voice was low and very sweet.
She seemed pleading for Pembroke’s salvation.
“Pembroke, you know, is already deeply in debt. He cannot
readily accommodate himself to the style of provincial living here. He
would say all these things are trifles. I tell you, Olivia Berkeley, they
are not trifles. They are second nature. Is it not cruel of God to make
us so dependent on these wretched things? It was for these same
wretched things that I endured torture for years—for money and
clothes and carriages—just such things as that.”
Olivia by a great effort recovered herself.
“What you say is true, Madame Koller. But I will not—how can
you ask me such things about a man who has never—never”—she
stopped at a loss to express her meaning, which implied a reproach
at Madame Koller’s want of delicacy.
Madame Koller made a gesture of impatience.
“What are promises?” she cried. “Nevertheless, I want you to see
that if you marry Pembroke it will be his ruin. It would be most wicked
selfishness.”
“Madame Koller,” answered Olivia, rising, “I will not listen to any
more.”
“I have nothing more to say,” responded Madame Koller, rising
too, and drawing her cloak around her. “I did not expect more from
you than conventional tolerance. Had you a heart you would have
felt for me—for him—for yourself. Can you conceive of anything
more noble, or more piteous than two women, one of whom must
make a great sacrifice for the man they both love—come, you need
not deny it, or lose your temper—because I see you have a temper.”
Olivia’s air and manner did certainly indicate dangerous possibilities.
“I repeat, of two women as we are, the one makes the sacrifice—the
other feels it to the quick. You talk though like a boarding-school
miss. You might have got all the phrases you have used out of a
book of deportment.”
“I am as sincere as you are, Madame Koller,” answered Olivia, in
a voice of restrained anger. “I cannot help it that I am more reserved.
I could no more say what you have said—” here a deep flush came
into Olivia’s face—“than I could commit murder.”
Madame Koller stood up, and as she did so, she sighed deeply.
Olivia, for the first time, felt sorry for her.
“Women who love are foolish, desperate, suicidal—anything. I do
not think that you could ever love.”
“Do you think that? I know better. I could love—but not like—not
like—”
“Not like me?”
“Yes, since you have said it. Something—something—would hold
me back from what you speak of so openly.”
“I always said you were as nearly without feeling as the rest of
the people here. Elizabeth Pembroke is the only woman I know of,
among all of us, that ever really loved. But see how curious it was
with her. She defied her father’s curses—yet she did not have the
nerve to marry the man she truly loved, because he happened to be
an officer in the Union army, for fear the Peytons and the Coles, and
the Lesters, and the rest of them, would have turned their backs on
her at church. Bah!”
“I don’t think it was want of nerve on Elizabeth Pembroke’s part,”
replied Olivia. “She was not born to be happy.”
“Nor was I,” cried Madame Koller, despondently.
There was no more said for a minute or two. Then Madame
Koller spoke again.
“Now you know what I feel. I don’t ask anything for myself—I only
wish to show you that you will ruin Pembroke if you marry him.”
An angry light came into Olivia’s eyes. She stood up, straight and
stern, and absolutely grew taller as she looked fixedly at Madame
Koller.
“This is intolerable,” she said. “There is nothing—absolutely
nothing—between Pembroke and me, and yet I am subjected to this
cross-questioning.”
“You would complain a great deal more of it if there were anything
between you,” answered Madame Koller, not without a glimpse of
grotesque humor. “But now you know where I stand—and let me tell
you, Olivia Berkeley, Pembroke is not guiltless toward me, however
he would pretend it”—and without waiting for the angry reply on
Olivia’s lips, she vanished through the open door.
All that evening, as Olivia sat with a book on her lap, not reading,
but watching the flame on the broad hearth, she was turning over in
her mind what Madame Koller had said. It had disturbed her very
much. It had not raised Pembroke at all in her esteem. She begun,
nevertheless, to think with pity over the wretchedness of his fate
should he be condemned to poverty. She fancied him harassed by
debts, by Miles’ helplessness. Her tender heart filled with pity.
“Olivia, my love,” said the Colonel, emerging from behind his
newspaper for a moment. “Pembroke means to try for the
nomination to Congress—and Cave tells me he is pretty sure to get
it. Great pity. A man who goes into public life without out a
competence dooms himself to a dog’s life for the remainder of his
days. It ruined Pembroke’s father thirty years ago.”
Olivia started. This was like an oracle answering her own
thoughts.
She thought, with a little bitter smile that it did not require much
generosity to give up a man on whom one had no claim, and
laughed at the idea of a struggle. At all events she would forget it all.
It was not so easy to forget though. The thought stayed with her, and
went to bed with her, and rose with her next morning.
Meanwhile, alas, for Madame Koller. When she came out, she
looked around in vain for the negro woman who had come with her.
She was not to be seen. They had come by the path that led through
the fields, which made it only a mile from The Beeches to Isleham,
but in going back, she missed her way—and then being a little afraid
of the negroes, she went “around the road,” as they called it. At the
first gate, a man galloped out of the darkness. It was Pembroke. He
recognized her at once, and got off his horse.
“You here,” he cried in surprise—“at this hour”—for it was well on
to seven o’clock, and Madame Koller was not noted for her fondness
for walking.
“Yes,” she answered.
“Is anything the matter at Isleham?” he asked—for she could not
have come from anywhere else.
“Nothing at all,” she replied nervously. “I—I—went over to see
Olivia Berkeley,” she added boldly.
Pembroke could say nothing. After a pause, Madame Koller burst
out.
“Pembroke, that girl is made of iron. She cares nothing for you—
for anybody but herself.”
“And did you find out any of those things by asking her?” he
inquired.
The twilight was so upon them that Madame Koller could not well
see Pembroke’s face, but she realized the tone of suppressed rage
in his voice. She herself had a temper that was stormy, and it flamed
out at that tone.
“Yes, I asked her. Are you a man that you can reproach me with
it?”
It is difficult for a man, if he is a gentleman, to express his wrath
toward a woman. Pembroke was infuriated at the idea that Madame
Koller should go to Olivia Berkeley and ask prying questions. He
ground his teeth with wrath as he looked at Madame Koller standing
before him, in the half light.
“What a price I have had to pay for folly,” he cried furiously. “A
little damned love-making in a garden—” he was so savage that he
was not choice of words and fell into profanity as men naturally do
—“a half dozen notes and bouquets—Great God! Is there anything in
that which should be a curse to a man’s whole life! And I love Olivia
Berkeley. I could make her love me, but—but for you.”
His violence sobered Madame Koller at once.
“There was not much, certainly,” she responded calmly. “The
love-making in the garden and the bouquets would have been little
enough—but unfortunately hearts are so perverse. A great many are
broken by such trifles. It was very amusing to you but not so
amusing altogether to me.”
Pembroke began to be ashamed of himself. But he was still
magnanimous enough not to tell her that she had taken a queer
course about those things.
“I suppose I am to blame,” he said with sulky rage after a
moment. “I’m willing to shoulder all the blame there is—but why
should Olivia Berkeley be insulted and annoyed by this kind of thing?
Do you think you will ever accomplish anything by—” he stopped and
blushed both for himself and her.
“One thing is certain,” he continued. “After what you have said to
Olivia Berkeley, questioning her about me, as you have admitted, I
shall simply carry out my intention of asking her to marry me. She
shall at least know the truth from me. But I think my chances are
desperate. Pshaw! I have no chance at all. It’s rather grotesque,
don’t you think, for a man to ask a woman to marry him when he
knows that she will throw him over and despise him from the bottom
of her heart?”
“That I must decline to discuss with you,” quietly answered
Madam Koller. She was indeed quiet, for at last—and in an instant,
she realized that she must forever give up Pembroke. All that long
journey was for nothing—all those months of wretched loneliness, of
still more wretched hopes and fears, were in vain. She heard
Pembroke saying:
“You had best let me see you home. It is too late for you to be out
alone.”
“You will not,” she replied. “I will not permit you, after what you
have said, to go one step with me.”
Pembroke felt thoroughly ashamed. It was one of the incidents of
his association with Madame Koller and Ahlberg that they always
made him say and do things he was ashamed of. In short, they
demoralized him. He had been betrayed by temper and by
circumstances into things that were utterly against his self-respect—
like this ebullition of rage against a woman. In the plenitude of his
remorse he was humble to the last degree.
“May I,” he asked—“may I, at least accompany you to your own
grounds? It is really not safe for you.”
Madame Koller turned upon him and stamped her foot.
“No, no—always no. Do you think there is any danger on earth
from which I would accept your protection? Go to Olivia Berkeley.
She would marry you in your poverty if it suited her whim, and be a
millstone around your neck. Go to her, I say.”
Pembroke watched her figure disappearing in the dusk along the
faint white line of the road. He stood still with his horse’s bridle in his
hand, turning over bitter things in his mind. He thought he would not
go to Isleham that night. He was depressed and conscience-stricken,
and in no lover-like mood. He mounted his horse and rode slowly
back to Malvern.
CHAPTER XII.
When two weeks had passed, Pembroke still had not gone to
Isleham—but in that time much had happened. The congressional
convention had been held, and the ball had been opened for him by
Cave with great brilliancy and power—and after a hard fight of two
days, Pembroke had got the nomination for Congress. It was of
infinite satisfaction to him in many ways. First because of the honor,
which he honestly coveted—and again because of the ready money
his election would bring. Modest as a congressional salary would be,
it was at least in cash—and that was what he most needed then. He
did not have a walk over. The parties were about evenly divided, and
it was known that the canvass would be close and exciting.
Pembroke warmed to his work when he knew this. It was like Bob
Henry’s trial—it took hold of his intellectual nature. He was called
magnetic—and he had a nerve power, a certain originality about him
that captivated his audiences.
There is nothing that a mixed crowd of whites and blacks at the
South so much hates as a demagogue. Especially is this the case
with the “poor whites” and the negroes. It was from them that
Pembroke knew he must get the votes to elect. When he appeared
on the hustings, he was the same easy, gentlemanly fellow as in a
drawing-room. He slapped no man on the back, nor offered treats,
nor was there any change in his manner. He was naturally affable,
and he made it his object to win the good will of his hearers through
their enlightenment, not their prejudices. The Bob Henry episode did
him immense service. A great revolution had taken place in regard to
Bob Henry. As, when he had been poor and in prison and friendless
and suspected, everybody had been down on him, so now when he
was free and cleared of suspicion, and had been an object of public
attention, he became something of a hero. He worked like a beaver
among his own people for “Marse French.” At “night meetings” and
such, he was powerful—and in the pulpits of the colored people, the
fiat went forth that it “warn’t wuff while fer cullud folks to pay de
capilation tax fer to git young Mr. Hibbs, who warn’ no quality nohow”
into Congress—for the redoubtable Hibbs was Pembroke’s
opponent. This too, had its favorable action on his canvass. As for
Petrarch, he claimed a direct commission from the Lord to send
“Marse French ter Congriss. De Lord, de Great Physicianer, done
spoken it ter me in de middle o’ de night like he did ter little Samson,
sayin’ ‘Petrarch whar is you?’ He say ‘What fur I gin you good
thinkin’ facticals, ’cep’ fur ter do my will? An’ it ain’t Gord’s will dat no
red headed Hibbs be ’lected over ole Marse French Pembroke’s son,
dat allus treated me wid de greatest circumlocution.” Petrarch’s
oratory was not without its effect.
Pembroke’s natural gift of oratory had been revealed to him at
the time of Bob Henry’s acquittal. He cultivated it earnestly, avoiding
hyperbole and exaggeration. There is nothing a Virginian loves so
well as a good talker. Within ten days of the opening of the
campaign, Pembroke knew that he was going to win. Hibbs had a
very bad war record. Pembroke had a very good one. The canvass
therefore to him, was pleasant, exciting, and with but little risk.
But Olivia Berkeley’s place had not been usurped. He had not
meant or desired to fall in love. As he had said truly to Cave, there
were other things for him than marriage. But love had stolen a march
upon him. When he found it out, he accepted the result with great
good humor—and he had enough masculine self-love to have good
hopes of winning her until—until Madame Koller had put her oar in.
But even then, his case did not seem hopeless, after the first burst of
rage and chagrin.
She would not surrender at once—that he felt sure, and he rather
liked the prospect of a siege, thinking to conquer her proud spirit by
a bold stroke at last. But Madame Koller had changed all this. He
was determined to make Olivia Berkeley know how things stood
between Madame Koller and himself—and the best way to do it was
to tell her where his heart was really bestowed.
It was in the latter part of April before a day came that he could
really call his own. He walked over from Malvern late in the
afternoon, and found Olivia, as he thought he should, in the garden.
The walks were trimmed up, and the flower-beds planted. Olivia, in a
straw hat and wearing a great gardening apron full of pockets,
gravely removed her gloves, her apron, and rolled them up before
offering to shake hands with Pembroke.
“Allow me to congratulate our standard-bearer, and to apologize
for my rustic occupations while receiving so distinguished a visitor.”
Pembroke looked rather solemn. He was not in a trifling mood
that afternoon, and he thought Olivia deficient in perception not to
see at once that he had come on a lover’s errand.
Is there anything more charming than an old-fashioned garden in
the spring? The lilac bushes were hanging with purple blossoms,
and great syringa trees were brave in their white glory. The guelder
roses nodded on their tall stems, and a few late violets scented the
air. It was a very quiet garden, and the shrubbery cut it off like a
hermitage. Pembroke had selected his ground well.
Olivia soon saw that something was on his mind, but she did not
suspect what it was. She had heard that Madame Koller was to
leave the country, and she thought perhaps Pembroke needed
consolation. Men often go to one woman to be consoled for the
perfidy of another. Presently as they strolled along, she stooped
down, and plucked some violets.
“I thought they were quite gone,” she said. “Here are four,” and as
she held them out to Pembroke, he took her little hand, inclosing the
violets in his own strong grasp.
There was the time, the place, the opportunity, and Olivia was
more than half won. Yet, half an hour afterward, Pembroke came out
of the garden, looking black as a thunder-cloud, and strode away
down by the path through the fields—a rejected suitor. Olivia
remained in the garden. The cool spring night came on apace. She
could not have described her own emotions to have saved her life—
or what exactly led up to that angry parting—for it will have been
seen before this that Pembroke was subject to sudden gusts of
temper. She had tried to put before him what she felt herself obliged
in honor to say—that the Colonel’s modest fortune was very much
exaggerated—and she had blundered wretchedly in so doing.
Pembroke had rashly assumed that she meant his poverty stood in
the way. Then he had as wretchedly blundered about Madame
Koller, and a few cutting words on both sides had made it impossible
for either to say more. Olivia, pale and red by turns, looked
inexpressibly haughty when Madame Koller’s name was mentioned.
Lovers’ quarrels are proverbially of easy arrangement—but the case
is different when the woman is high strung and the man high
tempered. Olivia received Pembroke’s confession with such cool
questionings that his self-love was cruelly wounded. Pembroke took
his dismissal so debonairly that Olivia was irresistibly impelled to
make it stronger. The love scene, which really began very prettily,
absolutely degenerated into a quarrel. Pembroke openly accused
Olivia of being mercenary. Olivia retaliated by an exasperating
remark, implying that perhaps Madame Koller’s fortune was not
without its charm for him—to which Pembroke, being entirely
innocent, responded with a rude violence that made Olivia more
furiously angry than she ever expected to be in her life. Pembroke
seeing this in her pale face and blazing eyes, stalked down the
garden path, wroth with her and wroth with the whole world.
He, walking fast back through the woods, was filled with rage and
remorse—chiefly with rage. She was a cold-blooded creature—how
she did weigh that money question—but—ah, she had a spirit of her
own—such a spirit as a man might well feel proud to conquer—and
the touch of her warm, soft hand!
Olivia felt that gap, that chasm in existence, when a shadowy
array of vague hopes and fears suddenly falls to the ground.
Pembroke had been certainly too confident and much too
overbearing—but—it was over. When this thought struck her, she
was walking slowly down the broad box-bordered walk to the gate.
The young April moon was just appearing in the evening sky. She
stopped suddenly and stood still. The force of her own words to him
smote her. He would certainly never come back. She turned and flew
swiftly back to the upper part of the garden, and stood in the very
spot by the lilac hedge, and went over it all in her mind. Yes. It was
then over for good—and he probably would not marry for a long,
long time. She remembered having heard Cave and her father speak
of Pembroke’s half joking aversion to matrimony. It would be much
better for him if he did not, as he had made up his mind to enter for a
career. But strange to say this did not warm her heart, which felt as
heavy as a stone.
Presently she went into the house, and was quite affectionate
and gay with her father, playing the piano and reading to him.
“Fathers are the pleasantest relations in the world,” she said, as
she kissed him good-night, earlier in the evening than usual. “No
fallings out—no misunderstandings—perfect constancy. Papa, I
wouldn’t give you up for any man in the world.”
“Wouldn’t you, my dear?” remarked that amiable old cynic
incredulously.
CHAPTER XIII.
One of the drawbacks of Arcadia is that everybody knows
everybody else’s business—and the possibility of this added to
Pembroke’s extreme mortification. He thought with dread of the
Colonel’s elaborate pretense of knowing nothing whatever about the
affair, Mrs. Peyton’s sly rallying, Mr. Cole’s sentimental condolence—
it was all very exasperating. But solely to Olivia’s tact and good
sense both escaped this. Not one soul was the wiser. Olivia,
however she felt, and however skillfully she might avoid meeting
Pembroke alone, was apparently so easy, so natural and self-
possessed, that it put Pembroke on his mettle. Together they
managed to hoodwink the whole county about their private affairs—
even Colonel Berkeley, who, if he suspected anything, was afraid to
let on, and Miles, whose devotion to Olivia became stronger every
day.
Luckily for Pembroke, he could plunge into the heat of his
canvass. After he had lost Olivia, the conviction of her value came to
him with overpowering force. There was no girl like her. She did not
protest and talk about her emotions and analyze them as some
women did—Madame Koller, for example—but Pembroke knew
there was “more to her,” as Cave said, “than a dozen Eliza Peytons.”
Perhaps Cave suspected something, but Pembroke knew he had
nothing to fear from his friend’s manly reticence. But to have lost
Olivia Berkeley! Pembroke sometimes wondered at himself—at the
way in which this loss grew upon him, instead of diminishing with
time, as the case usually is with disappointments. Yet all this time he
was riding from place to place, speaking, corresponding, as eager to
win his election as if he were the happiest of accepted lovers—more
so, in fact.
And then, there was that Ahlberg affair to trouble him. Like all the
men of his race and generation, he firmly believed there were some
cases in which blood must be shed—but a roadside quarrel, in which
nothing but personal dislike figured, did not come under that head.
Pembroke was fully alive to the folly and wickedness of fighting
Ahlberg under the circumstances—but it was now impossible for him
to recede. He could only hope and pray that something would turn
up to prevent a meeting so indefinitely fixed. But if Ahlberg’s going
away were the only thing to count upon, that seemed far enough out
of the question, for he stayed on and on at the village tavern, playing
cards with young Hibbs and one or two frequenters of the place,
riding over to play Madame Koller’s accompaniments, fishing for
invitations to dine at Isleham—in short, doing everything that a man
of his nature and education could do to kill time. Pembroke could not
but think that Ahlberg’s persistence could only mean that he was
really and truly waiting for his revenge. So there were a good many
things to trouble the “white man’s candidate,” who was to make such
a thorough and brilliant canvass, and whose readiness, cheerfulness
and indomitable spirit was everywhere remarked upon.
One night, as Pembroke was riding home after a hard day’s work
in the upper part of the county, and was just entering the long
straggling village street, his horse began to limp painfully. Pembroke
dismounted, and found his trusty sorrel had cast a shoe,—a nail had
entered his foot, and there was a job for the blacksmith. He led the
horse to the blacksmith’s shop, which was still open, although it was
past seven o’clock, and on the promise of having the damage
repaired in half an hour, walked over to the village tavern.
It was in September, and the air was chilly. The landlord ushered
him into what was called the “card room”—the only place there was
a fire. A cheery blaze leaped up the wide old-fashioned chimney, and
by the light of kerosene lamps, Pembroke saw a card party at a
round table in the corner. It was Ahlberg, young Hibbs, his political
opponent, and two or three other idle young men of the county.
According to the provincial etiquette, Pembroke was invited to
join the game, which he courteously declined on the ground that he
was much fatigued and was only waiting for the blacksmith to put his
horse’s shoe on before starting for home. The game then proceeded.
Pembroke felt awkward and ill at ease. He knew he was in the
way, as the loud laughter from Hibbs and his friends, and Ahlberg’s
subdued chuckle had ceased when he came in. They played
seriously—it was écarté, a game that Ahlberg had just taught his
postulants. Young Hibbs had a huge roll of bills on the table before
him, which he somewhat ostentatiously displayed in the presence of
his opponent, whose lack of bills was notorious. Also, Pembroke felt
that his presence induced young Hibbs to bet more recklessly than
ever, as a kind of bravado—and Ahlberg always won, when the
stake was worth any thing.
The waiting seemed interminable to Pembroke seated in front of
the fire. The conversation related solely to the game. Presently
Pembroke started slightly. Ahlberg was giving them some general
views on the subject of écarté. Pembroke himself was a good player,
and he had never heard this scheme of playing advocated.
Over the mantel was an old-fashioned mirror, tilted forward.
Although his back was to the players, Pembroke could see every
motion reflected in the glass. He saw Hibbs lose three times running
in fifteen minutes.
Pembroke’s sight was keen. He fixed it on the glass and a
curious look came into his dark face. Once he made a slight
movement as if to rise, but sat still. A second time he half rose and
sat down again—nobody in the room had seen the motion. Then,
without the slightest warning, he suddenly took three strides over to
the card table and, reaching over, seized Ahlberg by the collar, and
lifted him bodily up from the table into a standing position.
“Produce that king of spades,” he said.
If he had shot Ahlberg no greater surprise could have been
created. Hibbs jumped up, dashing the cards and money in a heap
on the floor, and nearly upsetting the table. One of his companions
grabbed the lamp to save it.
Ahlberg turned a deathly color, and made some inarticulate effort
to be heard, and tried to wrest himself from Pembroke’s grasp. But it
was in vain. Pembroke shook him slightly, but never relaxed his hold.
“The king of spades, I say.”
Without a word Ahlberg reached down, and from some unknown
depths produced the card. He was no coward, but he was
overmastered physically and mentally. He knew in an instant that
Pembroke had seen it all, and there was no shadow of escape for
him.
Pembroke let go of Ahlberg’s collar, and, taking out a white
handkerchief, wiped his hands carefully. Ahlberg had sunk back,
panting, in a chair. The grip of a hand like Pembroke’s in the
neighborhood of the wind-pipe is calculated to shorten the breath.
Hibbs looked dazed, from one to the other, and then to the floor,
where the cards had fallen. The one damning card lay on the table.
“I saw it twice before this, in the glass,” said Pembroke to Hibbs.
“Each time I tried to catch him, but he did it so well I couldn’t. But the
last time it was perfectly plain,—you see. I could see under the table
in the glass. You had better pick up your money, Hibbs.”
At this, Ahlberg spoke up.
“All of it is Monsieur Hibbs’,” he said with elaborate politeness,
recovering his breath a little, “except two fifty-dollar notes, which are
mine.”
Pembroke picked out the two fifty-dollar notes and dashed them
in Ahlberg’s face, who very cleverly caught them and put them in his
pocket.
“Mr. Pembroke,” said Hibbs, stammering and blushing, “I—I—
hope you won’t say anything about this, sir. It would ruin me—I don’t
mean in the canvass, for I tell you truly, sir, I hope you’ll be elected,
and if it wasn’t for the party, I’d give up the fight now. But my mother,
sir, don’t approve—don’t approve of playing for money—and—”
“You are perfectly safe,” answered Pembroke, “and quite right in
your idea of duty to your party, and your dislike to wound your
mother is creditable. But as for this dog, he must leave this county at
once.”
Ahlberg said not a word. He did not lack mere physical courage,
but cheating at cards was, to him, the most heinous offense of which
he could be convicted. He had been caught—it was the fortune of
war—there was nothing to be said or done. At least, it happened in
this out-of-the-way corner of the world, where it could never be
known to anybody—for he did not count his acquaintances in the
country as anybody, unless—perhaps—Madame Koller. At that he
grew pale for the first time. He really wanted Madame Koller’s
money. But, in fact, he was somewhat dazed by Pembroke’s way of
settling the trouble. It really shocked his ethics to see one gentleman
punish another as if he were a bargeman or a coal heaver. These
extraordinary Anglo-Saxons! But one thing was plain with him—if he
did not remain perfectly quiescent Pembroke was quite capable of
throwing him bodily out of the window—and if he had lost his honor,
as he called it, there was no reason why he shouldn’t save his
bones.
Pembroke, however, although he would have sworn that nothing
Ahlberg could do in the way of rascality could surprise him, was as
yet amazed, astounded, and almost puzzled by the promptness with
which Ahlberg acquiesced in the status which Pembroke
established. Ahlberg made no protest of innocence—he did not
bluster, or grow desperate, or break down hysterically, as even a
very bad man might under the circumstances. He simply saw that if
he said anything, he might feel the weight of Pembroke’s arm.
Nothing that he could have said or done was as convincing of his
thorough moral obtuseness as the way in which he accepted his own
exposure.
Just then the landlord opened the door. “Mr. Pembroke, your
horse is at the door. It’s going to be a mighty bad night though—
there’s a cloud coming up. You’d better stay and join them
gentlemen in their game.”
“No, I thank you,” replied Pembroke, and turning to Ahlberg. “Of
course, after what has passed, it is out of the question that I should
fight you. Good God! I’d just as soon think of fighting a jail bird! Don’t
take too long to get out of this county. Good night, Mr. Hibbs—good
night—good night.”
Hibbs accompanied him out, and stood by him while he mounted.
“Mr. Pembroke,” he said, holding his hat in his hand, “I’m very
much obliged for what you have done for me, and what you have
promised. I promise you I’ll never touch a card for money again as
long as I live.”
“And don’t touch a card at all with such an infernal rascal as
Ahlberg,” answered Pembroke, altogether forgetting sundry
agreeable games he had enjoyed with Ahlberg in Paris, and even in
that very county—but it had been a good while ago, and Ahlberg had
not tried any tricks on him.
This relieved Pembroke of a load of care—the folly of that quarrel
was luckily escaped. But he debated seriously with himself whether
he ought not to tell Madame Koller of Ahlberg’s behavior, that she
might be on her guard against him. In a day or two he heard, what
did not surprise him, that Ahlberg was about to leave the country—
but at the same time that Madame Koller and her mother were to
leave The Beeches rather suddenly. Mrs. Peyton met him in the
road, and stopped her carriage to tell him about Eliza Peyton’s
consummate folly in allowing that Ahlberg to stick to her like a burr—
they actually intended crossing in the same steamer. That
determined Pembroke. He rode over to The Beeches, and sitting
face to face with Madame Koller in her drawing-room, told her the
whole story. Pembroke was somewhat shocked to observe how little
she seemed shocked at Ahlberg’s conduct. It was certainly very bad,
but—but—she had known him for so long. Pembroke was amazed
and disgusted. As he was going, after a brief and very business-like
visit, Madame Koller remarked, “And it is so strange about Louis.
The very day after it happened, he was notified of his appointment
as First Secretary in the Russian diplomatic service—or rather his re-
appointment, for he was in it ten years—and he has come into an
excellent property—quite a fortune in fact for a first secretary.”
Pembroke rode back home slowly and thoughtfully. He had never
before realized how totally wanting Madame Koller was in integrity of
mind. Olivia Berkeley now—
CHAPTER XIV.
It takes a long time for a country neighborhood to recover from a
sensation. Three or four years after Madame Koller, or Eliza Peyton
had disappeared along with her mother and Ahlberg, people were
still discussing her wonderful ways. Mr. Cole was paying his court
mildly to Olivia Berkeley, but in his heart of hearts he had not
forgotten his blonde enslaver. The Colonel was the same Colonel—
his shirt-ruffle rushed out of his bosom as impetuously as of old. He
continued to hate the Hibbses. Dashaway had been turned out to
grass, but another screw continued to carry the Colonel’s colors to
defeat on the county race track. Olivia, too, had grown older, and a
great deal prettier. A chisel called the emotions, is always at work
upon the human countenance—a face naturally humane and
expressive grows more so, year by year.
It is not to be expected that she was very happy in that time. Life
in the country, varied by short visits to watering places in the summer
and occasionally to cities in the winter, is dull at best for a girl grown
up in the whirl of civilization. There came a time—after Pembroke,
taking Miles with him had gone to Washington, when life began to
look very black to Olivia Berkeley’s eyes. She suffered for want of an
object in life. She loved her father very much, but that cheerful,
healthful and robustious old person hardly supplied the craving to
love and tend which is innate in every woman’s heart. It is at this
point in their development that women of inferior nature begin to
deteriorate. Not so with Olivia Berkeley. Life puzzled and displeased
her. She found herself full of energy, with many gifts and
accomplishments, condemned in the flower of her youth to the dull
routine of a provincial life in the country. She could not understand it
—neither could she sit down in hopeless resignation and accept it.
She bestirred herself. Books there were in plenty at Isleham—the
piano was an inestimable comforter. She weathered the storm of
ennui in this manner, and came to possess a certain content—to
control the outward signs of inward restlessness. Meanwhile she
read and studied feverishly, foolishly imagining that knowing a great
number of facts would make her happy. Of course it did not—but it
made her less unhappy.
As for Pembroke, the fate which had fallen hard on Olivia
Berkeley had fondly favored him. He was not only elected to
Congress, but he became something of a man after he got there.
The House of Representatives is a peculiar body—peculiarly
unfavorable to age, and peculiarly favorable to youth. Pembroke, still
smarting under his mortification, concluded to dismiss thoughts of
any woman from his mind for the present, and devote himself to the
work before him. With that view, he scanned closely his environment
when he went to Washington. He saw that as a young member he
was not expected to say anything. This left him more leisure to study
his duties. He aspired to be a lawyer—always a lawyer. He found
himself appointed to a committee—and his fellow members on it very
soon found that the quiet young man from Virginia was liable to be
well informed on the legal questions which the House and the
committees are constantly wrangling over. Every man on that
committee became convinced that the quiet young man would some
day make his mark. This was enough to give him a good footing in
the House. His colleagues saw that election after election, the young
man was returned, apparently without effort on his part, for
Pembroke was not a demagogue, and nothing on earth would have
induced him to go into a rough and tumble election campaign. At last
it got so that on the few occasions when he rose in his place, he had
no trouble in catching the Speaker’s eye. He was wise enough not to
be betrayed by his gift of oratory into speech-making—a thing the
House will not tolerate from a young member. He had naturally a
beautiful and penetrating voice and much grace and dignity in
speaking. These were enough without risking making himself
ridiculous by a premature display as an orator. He sometimes thrilled
when the great battles were being fought before his eyes—it was in
the reconstruction time—and longed for the day which he felt would
come when he might go down among the captains and the shouting,
but he had the genius of waiting. Then he was a pleasant man at
dinner—and his four years army service had given him a soldierly
frankness and directness. He lived with Miles in a simple and quiet
way in Washington. He did not go out much, as indeed he had no
time. He became quite cynical to himself about women. The pretty
girls from New York were quite captivated with the young man from
Virginia. They wanted to know all about his lovely old place,
especially one charming bud, Miss de Peyster.
“Come and see it,” Pembroke would answer good-naturedly. “Half
the house was burned up by our friends, the enemy—the other half
is habitable.”
“And haven’t you miles and miles of fields and forests, like an
English nobleman?” the gay creature asked.
“Oh yes. Miles and miles. The taxes eat up the crops, and the
crops eat up the land.”
“How nice,” cried the daughter of the Knickerbockers. “How much
more romantic it is to have a broken down old family mansion and
thousands of acres of land, than to be a stockbroker or a real estate
man—and then to have gone through the whole war—and to have
been promoted on the field—”
Pembroke smiled rather dolefully. His ruined home, his
mortgaged acres, Miles’ life-long trouble, his four years of marching
and starving and fighting, did not appear like romantic incidents in
life, but as cruel blows of fate to him.
But Helena de Peyster was a pleasant girl, and her mother was
gentle, amiable, and well-bred. They had one of the gayest and most
charming houses in Washington, and entertained half the diplomatic
corps at dinner during every week. They would gladly have had
Pembroke oftener. He came in to quiet dinners with them, assumed
a fatherly air with Helena, and liked them cordially. They were good
to Miles too, who sometimes went to them timidly on rainy
afternoons when he would not be likely to find anybody else.
So went the world with Pembroke for some years until one
evening, going to his modest lodgings, he found a letter with Colonel
Berkeley’s big red seal on it awaiting him.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!
ebookfinal.com

More Related Content

PDF
MySQL Cookbook 1st ed Edition Paul Dubois
PDF
MySQL Cookbook 1st ed Edition Paul Dubois
PDF
Mysql Cookbook Solutions For Database Developers And Administrators Dubois
PDF
Mysql Cookbook Solutions For Database Developers And Administrators 4th Editi...
PDF
Mysql Cookbook Solutions For Database Developers And Administrators 4th Editi...
PDF
0888 learning-mysql
PDF
MySQL Notes For Professionals sttudy.pdf
PDF
Learning Mysql Seyed Mm Saied Tahaghoghi Hugh Williams
MySQL Cookbook 1st ed Edition Paul Dubois
MySQL Cookbook 1st ed Edition Paul Dubois
Mysql Cookbook Solutions For Database Developers And Administrators Dubois
Mysql Cookbook Solutions For Database Developers And Administrators 4th Editi...
Mysql Cookbook Solutions For Database Developers And Administrators 4th Editi...
0888 learning-mysql
MySQL Notes For Professionals sttudy.pdf
Learning Mysql Seyed Mm Saied Tahaghoghi Hugh Williams

Similar to MySQL Cookbook 1st ed Edition Paul Dubois (20)

PDF
MySQL notes for professionals
PDF
Mysql notes for professionals
PPT
My sql with querys
PPTX
Lecture2 mysql by okello erick
PDF
Mysql In A Nutshell In A Nutshell Oreilly Second Edition Russell Dyer
PPT
MySql slides (ppt)
PPTX
DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018
PPTX
Lecture3 mysql gui by okello erick
PDF
MySQL for beginners
PDF
PDF
Mysql basics1
PPT
Mysql Fun
 
PPTX
MSAvMySQL.pptx
PDF
Bt0075 rdbms with mysql 2
PPTX
Introduction databases and MYSQL
PPTX
PHP mysql Introduction database
PPTX
MySQL Essential Training
PPT
MySQL notes for professionals
Mysql notes for professionals
My sql with querys
Lecture2 mysql by okello erick
Mysql In A Nutshell In A Nutshell Oreilly Second Edition Russell Dyer
MySql slides (ppt)
DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018
Lecture3 mysql gui by okello erick
MySQL for beginners
Mysql basics1
Mysql Fun
 
MSAvMySQL.pptx
Bt0075 rdbms with mysql 2
Introduction databases and MYSQL
PHP mysql Introduction database
MySQL Essential Training
Ad

Recently uploaded (20)

PDF
Insiders guide to clinical Medicine.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Pre independence Education in Inndia.pdf
PPTX
Cell Structure & Organelles in detailed.
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
master seminar digital applications in india
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Cell Types and Its function , kingdom of life
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Classroom Observation Tools for Teachers
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
Insiders guide to clinical Medicine.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Microbial disease of the cardiovascular and lymphatic systems
Pre independence Education in Inndia.pdf
Cell Structure & Organelles in detailed.
Pharma ospi slides which help in ospi learning
Pharmacology of Heart Failure /Pharmacotherapy of CHF
master seminar digital applications in india
PPH.pptx obstetrics and gynecology in nursing
VCE English Exam - Section C Student Revision Booklet
Renaissance Architecture: A Journey from Faith to Humanism
Supply Chain Operations Speaking Notes -ICLT Program
Cell Types and Its function , kingdom of life
Microbial diseases, their pathogenesis and prophylaxis
102 student loan defaulters named and shamed – Is someone you know on the list?
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Classroom Observation Tools for Teachers
Abdominal Access Techniques with Prof. Dr. R K Mishra
Ad

MySQL Cookbook 1st ed Edition Paul Dubois

  • 1. MySQL Cookbook 1st ed Edition Paul Dubois download pdf https://ebookfinal.com/download/mysql-cookbook-1st-ed-edition-paul- dubois/ Visit ebookfinal.com today to download the complete set of ebook or textbook!
  • 2. Here are some recommended products that we believe you will be interested in. You can click the link to download. MySQL Cookbook 2nd Edition Solutions Examples for Database Developers and DBAs Paul Dubois https://ebookfinal.com/download/mysql-cookbook-2nd-edition-solutions- examples-for-database-developers-and-dbas-paul-dubois/ MySQL Admin Cookbook 1st New edition Edition Daniel Schneller https://ebookfinal.com/download/mysql-admin-cookbook-1st-new-edition- edition-daniel-schneller/ MySQL Cookbook 4th Edition Sveta Smirnova & Alkin Tezuysal https://ebookfinal.com/download/mysql-cookbook-4th-edition-sveta- smirnova-alkin-tezuysal/ Useful Quasicrystals 1st Edition Jean-Marie Dubois https://ebookfinal.com/download/useful-quasicrystals-1st-edition-jean- marie-dubois/
  • 3. Python Cookbook 2nd ed Edition Alex Martelli https://ebookfinal.com/download/python-cookbook-2nd-ed-edition-alex- martelli/ Linux Security Cookbook 1st ed Edition Daniel J. Barrett https://ebookfinal.com/download/linux-security-cookbook-1st-ed- edition-daniel-j-barrett/ Access Data Analysis Cookbook 1st ed Edition Ken Bluttman https://ebookfinal.com/download/access-data-analysis-cookbook-1st-ed- edition-ken-bluttman/ Analog Circuits Cookbook 2nd ed Edition Ian Hickman https://ebookfinal.com/download/analog-circuits-cookbook-2nd-ed- edition-ian-hickman/ MySQL Crash Course Rick Silva https://ebookfinal.com/download/mysql-crash-course-rick-silva/
  • 5. MySQL Cookbook 1st ed Edition Paul Dubois Digital Instant Download Author(s): Paul DuBois ISBN(s): 9780596001452, 0596001452 Edition: 1st ed File Details: PDF, 4.00 MB Year: 2003 Language: english
  • 6. MySQL Cookbook By Paul DuBois Publisher : O'Reilly Pub Date : October 2002
  • 7. ISBN : 0-596-00145-2 Pages : 1022 MySQL Cookbook provides a unique problem-and-solution format that offers practical examples for everyday programming dilemmas. For every problem addressed in the book, there's a worked-out solution or "recipe" -- short, focused pieces of code that you can insert directly into your applications. More than a collection of cut-and-paste code, this book explanation how and why the code works, so you can learn to adapt the techniques to similar situations.
  • 8. Copyright Preface MySQL APIs Used in This Book Who This Book Is For What's in This Book Platform Notes Conventions Used in This Book The Companion Web Site Comments and Questions Additional Resources Acknowledgments Chapter 1. Using the mysql Client Program Section 1.1. Introduction Section 1.2. Setting Up a MySQL User Account Section 1.3. Creating a Database and a Sample Table Section 1.4. Starting and Terminating mysql Section 1.5. Specifying Connection Parameters by Using Option Files Section 1.6. Protecting Option Files Section 1.7. Mixing Command-Line and Option File Parameters Section 1.8. What to Do if mysql Cannot Be Found Section 1.9. Setting Environment Variables Section 1.10. Issuing Queries Section 1.11. Selecting a Database Section 1.12. Canceling a Partially Entered Query Section 1.13. Repeating and Editing Queries Section 1.14. Using Auto-Completion for Database and Table Names Section 1.15. Using SQL Variables in Queries Section 1.16. Telling mysql to Read Queries from a File Section 1.17. Telling mysql to Read Queries from Other Programs Section 1.18. Specifying Queries on the Command Line Section 1.19. Using Copy and Paste as a mysql Input Source Section 1.20. Preventing Query Output from Scrolling off the Screen Section 1.21. Sending Query Output to a File or to a Program Section 1.22. Selecting Tabular or Tab-Delimited Query Output Format Section 1.23. Specifying Arbitrary Output Column Delimiters Section 1.24. Producing HTML Output Section 1.25. Producing XML Output Section 1.26. Suppressing Column Headings in Query Output Section 1.27. Numbering Query Output Lines Section 1.28. Making Long Output Lines More Readable Section 1.29. Controlling mysql's Verbosity Level Section 1.30. Logging Interactive mysql Sessions
  • 9. Section 1.31. Creating mysql Scripts from Previously Executed Queries Section 1.32. Using mysql as a Calculator Section 1.33. Using mysql in Shell Scripts Chapter 2. Writing MySQL-Based Programs Section 2.1. Introduction Section 2.2. Connecting to the MySQL Server, Selecting a Database, and Disconnecting Section 2.3. Checking for Errors Section 2.4. Writing Library Files Section 2.5. Issuing Queries and Retrieving Results Section 2.6. Moving Around Within a Result Set Section 2.7. Using Prepared Statements and Placeholders in Queries Section 2.8. Including Special Characters and NULL Values in Queries Section 2.9. Handling NULL Values in Result Sets Section 2.10. Writing an Object-Oriented MySQL Interface for PHP Section 2.11. Ways of Obtaining Connection Parameters Section 2.12. Conclusion and Words of Advice Chapter 3. Record Selection Techniques Section 3.1. Introduction Section 3.2. Specifying Which Columns to Display Section 3.3. Avoiding Output Column Order Problems When Writing Programs Section 3.4. Giving Names to Output Columns Section 3.5. Using Column Aliases to Make Programs Easier to Write Section 3.6. Combining Columns to Construct Composite Values Section 3.7. Specifying Which Rows to Select Section 3.8. WHERE Clauses and Column Aliases Section 3.9. Displaying Comparisons to Find Out How Something Works Section 3.10. Reversing or Negating Query Conditions Section 3.11. Removing Duplicate Rows Section 3.12. Working with NULL Values Section 3.13. Negating a Condition on a Column That Contains NULL Values Section 3.14. Writing Comparisons Involving NULL in Programs Section 3.15. Mapping NULL Values to Other Values for Display Section 3.16. Sorting a Result Set Section 3.17. Selecting Records from the Beginning or End of a Result Set Section 3.18. Pulling a Section from the Middle of a Result Set Section 3.19. Choosing Appropriate LIMIT Values Section 3.20. Calculating LIMIT Values from Expressions Section 3.21. What to Do When LIMIT Requires the "Wrong" Sort Order Section 3.22. Selecting a Result Set into an Existing Table Section 3.23. Creating a Destination Table on the Fly from a Result Set Section 3.24. Moving Records Between Tables Safely
  • 10. Section 3.25. Creating Temporary Tables Section 3.26. Cloning a Table Exactly Section 3.27. Generating Unique Table Names Chapter 4. Working with Strings Section 4.1. Introduction Section 4.2. Writing Strings That Include Quotes or Special Characters Section 4.3. Preserving Trailing Spaces in String Columns Section 4.4. Testing String Equality or Relative Ordering Section 4.5. Decomposing or Combining Strings Section 4.6. Checking Whether a String Contains a Substring Section 4.7. Pattern Matching with SQL Patterns Section 4.8. Pattern Matching with Regular Expressions Section 4.9. Matching Pattern Metacharacters Literally Section 4.10. Controlling Case Sensitivity in String Comparisons Section 4.11. Controlling Case Sensitivity in Pattern Matching Section 4.12. Using FULLTEXT Searches Section 4.13. Using a FULLTEXT Search with Short Words Section 4.14. Requiring or Excluding FULLTEXT Search Words Section 4.15. Performing Phrase Searches with a FULLTEXT Index Chapter 5. Working with Dates and Times Section 5.1. Introduction Section 5.2. Changing MySQL's Date Format Section 5.3. Telling MySQL How to Display Dates or Times Section 5.4. Determining the Current Date or Time Section 5.5. Decomposing Dates and Times Using Formatting Functions Section 5.6. Decomposing Dates or Times Using Component-Extraction Functions Section 5.7. Decomposing Dates or Times Using String Functions Section 5.8. Synthesizing Dates or Times Using Formatting Functions Section 5.9. Synthesizing Dates or Times Using Component-Extraction Functions Section 5.10. Combining a Date and a Time into a Date-and-Time Value Section 5.11. Converting Between Times and Seconds Section 5.12. Converting Between Dates and Days Section 5.13. Converting Between Date-and-Time Values and Seconds Section 5.14. Adding a Temporal Interval to a Time Section 5.15. Calculating Intervals Between Times Section 5.16. Breaking Down Time Intervals into Components Section 5.17. Adding a Temporal Interval to a Date Section 5.18. Calculating Intervals Between Dates Section 5.19. Canonizing Not-Quite-ISO Date Strings Section 5.20. Calculating Ages Section 5.21. Shifting Dates by a Known Amount
  • 11. Section 5.22. Finding First and Last Days of Months Section 5.23. Finding the Length of a Month Section 5.24. Calculating One Date from Another by Substring Replacement Section 5.25. Finding the Day of the Week for a Date Section 5.26. Finding Dates for Days of the Current Week Section 5.27. Finding Dates for Weekdays of Other Weeks Section 5.28. Performing Leap Year Calculations Section 5.29. Treating Dates or Times as Numbers Section 5.30. Forcing MySQL to Treat Strings as Temporal Values Section 5.31. Selecting Records Based on Their Temporal Characteristics Section 5.32. Using TIMESTAMP Values Section 5.33. Recording a Row's Last Modification Time Section 5.34. Recording a Row's Creation Time Section 5.35. Performing Calculations with TIMESTAMP Values Section 5.36. Displaying TIMESTAMP Values in Readable Form Chapter 6. Sorting Query Results Section 6.1. Introduction Section 6.2. Using ORDER BY to Sort Query Results Section 6.3. Sorting Subsets of a Table Section 6.4. Sorting Expression Results Section 6.5. Displaying One Set of Values While Sorting by Another Section 6.6. Sorting and NULL Values Section 6.7. Controlling Case Sensitivity of String Sorts Section 6.8. Date-Based Sorting Section 6.9. Sorting by Calendar Day Section 6.10. Sorting by Day of Week Section 6.11. Sorting by Time of Day Section 6.12. Sorting Using Substrings of Column Values Section 6.13. Sorting by Fixed-Length Substrings Section 6.14. Sorting by Variable-Length Substrings Section 6.15. Sorting Hostnames in Domain Order Section 6.16. Sorting Dotted-Quad IP Values in Numeric Order Section 6.17. Floating Specific Values to the Head or Tail of the Sort Order Section 6.18. Sorting in User-Defined Orders Section 6.19. Sorting ENUM Values Chapter 7. Generating Summaries Section 7.1. Introduction Section 7.2. Summarizing with COUNT( ) Section 7.3. Summarizing with MIN( ) and MAX( ) Section 7.4. Summarizing with SUM( ) and AVG( ) Section 7.5. Using DISTINCT to Eliminate Duplicates
  • 12. Section 7.6. Finding Values Associated with Minimum and Maximum Values Section 7.7. Controlling String Case Sensitivity for MIN( ) and MAX( ) Section 7.8. Dividing a Summary into Subgroups Section 7.9. Summaries and NULL Values Section 7.10. Selecting Only Groups with Certain Characteristics Section 7.11. Determining Whether Values are Unique Section 7.12. Grouping by Expression Results Section 7.13. Categorizing Non-Categorical Data Section 7.14. Controlling Summary Display Order Section 7.15. Finding Smallest or Largest Summary Values Section 7.16. Date-Based Summaries Section 7.17. Working with Per-Group and Overall Summary Values Simultaneously Section 7.18. Generating a Report That Includes a Summary and a List Chapter 8. Modifying Tables with ALTER TABLE Section 8.1. Introduction Section 8.2. Dropping, Adding, or Repositioning a Column Section 8.3. Changing a Column Definition or Name Section 8.4. The Effect of ALTER TABLE on Null and Default Value Attributes Section 8.5. Changing a Column's Default Value Section 8.6. Changing a Table Type Section 8.7. Renaming a Table Section 8.8. Adding or Dropping Indexes Section 8.9. Eliminating Duplicates by Adding an Index Section 8.10. Using ALTER TABLE to Normalize a Table Chapter 9. Obtaining and Using Metadata Section 9.1. Introduction Section 9.2. Obtaining the Number of Rows Affected by a Query Section 9.3. Obtaining Result Set Metadata Section 9.4. Determining Presence or Absence of a Result Set Section 9.5. Formatting Query Results for Display Section 9.6. Getting Table Structure Information Section 9.7. Getting ENUM and SET Column Information Section 9.8. Database-Independent Methods of Obtaining Table Information Section 9.9. Applying Table Structure Information Section 9.10. Listing Tables and Databases Section 9.11. Testing Whether a Table Exists Section 9.12. Testing Whether a Database Exists Section 9.13. Getting Server Metadata Section 9.14. Writing Applications That Adapt to the MySQL Server Version Section 9.15. Determining the Current Database Section 9.16. Determining the Current MySQL User
  • 13. Section 9.17. Monitoring the MySQL Server Section 9.18. Determining Which Table Types the Server Supports Chapter 10. Importing and Exporting Data Section 10.1. Introduction Section 10.2. Importing Data with LOAD DATA and mysqlimport Section 10.3. Specifying the Datafile Location Section 10.4. Specifying the Datafile Format Section 10.5. Dealing with Quotes and Special Characters Section 10.6. Importing CSV Files Section 10.7. Reading Files from Different Operating Systems Section 10.8. Handling Duplicate Index Values Section 10.9. Getting LOAD DATA to Cough Up More Information Section 10.10. Don't Assume LOAD DATA Knows More than It Does Section 10.11. Skipping Datafile Lines Section 10.12. Specifying Input Column Order Section 10.13. Skipping Datafile Columns Section 10.14. Exporting Query Results from MySQL Section 10.15. Exporting Tables as Raw Data Section 10.16. Exporting Table Contents or Definitions in SQL Format Section 10.17. Copying Tables or Databases to Another Server Section 10.18. Writing Your Own Export Programs Section 10.19. Converting Datafiles from One Format to Another Section 10.20. Extracting and Rearranging Datafile Columns Section 10.21. Validating and Transforming Data Section 10.22. Validation by Direct Comparison Section 10.23. Validation by Pattern Matching Section 10.24. Using Patterns to Match Broad Content Types Section 10.25. Using Patterns to Match Numeric Values Section 10.26. Using Patterns to Match Dates or Times Section 10.27. Using Patterns to Match Email Addresses and URLs Section 10.28. Validation Using Table Metadata Section 10.29. Validation Using a Lookup Table Section 10.30. Converting Two-Digit Year Values to Four-Digit Form Section 10.31. Performing Validity Checking on Date or Time Subparts Section 10.32. Writing Date-Processing Utilities Section 10.33. Using Dates with Missing Components Section 10.34. Performing Date Conversion Using SQL Section 10.35. Using Temporary Tables for Data Transformation Section 10.36. Dealing with NULL Values Section 10.37. Guessing Table Structure from a Datafile Section 10.38. A LOAD DATA Diagnostic Utility Section 10.39. Exchanging Data Between MySQL and Microsoft Access
  • 14. Section 10.40. Exchanging Data Between MySQL and Microsoft Excel Section 10.41. Exchanging Data Between MySQL and FileMaker Pro Section 10.42. Exporting Query Results as XML Section 10.43. Importing XML into MySQL Section 10.44. Epilog Chapter 11. Generating and Using Sequences Section 11.1. Introduction Section 11.2. Using AUTO_INCREMENT To Set Up a Sequence Column Section 11.3. Generating Sequence Values Section 11.4. Choosing the Type for a Sequence Column Section 11.5. The Effect of Record Deletions on Sequence Generation Section 11.6. Retrieving Sequence Values Section 11.7. Determining Whether to Resequence a Column Section 11.8. Extending the Range of a Sequence Column Section 11.9. Renumbering an Existing Sequence Section 11.10. Reusing Values at the Top of a Sequence Section 11.11. Ensuring That Rows Are Renumbered in a Particular Order Section 11.12. Starting a Sequence at a Particular Value Section 11.13. Sequencing an Unsequenced Table Section 11.14. Using an AUTO_INCREMENT Column to Create Multiple Sequences Section 11.15. Managing Multiple SimultaneousAUTO_INCREMENT Values Section 11.16. Using AUTO_INCREMENT Valuesto Relate Tables Section 11.17. Using Single-Row Sequence Generators Section 11.18. Generating Repeating Sequences Section 11.19. Numbering Query Output Rows Sequentially Chapter 12. Using Multiple Tables Section 12.1. Introduction Section 12.2. Combining Rows in One Table with Rows in Another Section 12.3. Performing a Join Between Tables in Different Databases Section 12.4. Referring to Join Output Column Names in Programs Section 12.5. Finding Rows in One Table That Match Rows in Another Section 12.6. Finding Rows with No Match in Another Table Section 12.7. Finding Rows Containing Per-Group Minimum or Maximum Values Section 12.8. Computing Team Standings Section 12.9. Producing Master-Detail Lists and Summaries Section 12.10. Using a Join to Fill in Holes in a List Section 12.11. Enumerating a Many-to-Many Relationship Section 12.12. Comparing a Table to Itself Section 12.13. Calculating Differences Between Successive Rows Section 12.14. Finding Cumulative Sums and Running Averages Section 12.15. Using a Join to Control Query Output Order
  • 15. Section 12.16. Converting Subselects to Join Operations Section 12.17. Selecting Records in Parallel from Multiple Tables Section 12.18. Inserting Records in One Table That Include Values from Another Section 12.19. Updating One Table Based on Values in Another Section 12.20. Using a Join to Create a Lookup Table from Descriptive Labels Section 12.21. Deleting Related Rows in Multiple Tables Section 12.22. Identifying and Removing Unattached Records Section 12.23. Using Different MySQL Servers Simultaneously Chapter 13. Statistical Techniques Section 13.1. Introduction Section 13.2. Calculating Descriptive Statistics Section 13.3. Per-Group Descriptive Statistics Section 13.4. Generating Frequency Distributions Section 13.5. Counting Missing Values Section 13.6. Calculating Linear Regressions or Correlation Coefficients Section 13.7. Generating Random Numbers Section 13.8. Randomizing a Set of Rows Section 13.9. Selecting Random Items from a Set of Rows Section 13.10. Assigning Ranks Chapter 14. Handling Duplicates Section 14.1. Introduction Section 14.2. Preventing Duplicates from Occurring in a Table Section 14.3. Dealing with Duplicates at Record-Creation Time Section 14.4. Counting and Identifying Duplicates Section 14.5. Eliminating Duplicates from a Query Result Section 14.6. Eliminating Duplicates from a Self-Join Result Section 14.7. Eliminating Duplicates from a Table Chapter 15. Performing Transactions Section 15.1. Introduction Section 15.2. Verifying Transaction Support Requirements Section 15.3. Performing Transactions Using SQL Section 15.4. Performing Transactions from Within Programs Section 15.5. Using Transactions in Perl Programs Section 15.6. Using Transactions in PHP Programs Section 15.7. Using Transactions in Python Programs Section 15.8. Using Transactions in Java Programs Section 15.9. Using Alternatives to Transactions Chapter 16. Introduction to MySQL on the Web Section 16.1. Introduction
  • 16. Section 16.2. Basic Web Page Generation Section 16.3. Using Apache to Run Web Scripts Section 16.4. Using Tomcat to Run Web Scripts Section 16.5. Encoding Special Characters in Web Output Chapter 17. Incorporating Query Resultsinto Web Pages Section 17.1. Introduction Section 17.2. Displaying Query Results as Paragraph Text Section 17.3. Displaying Query Results as Lists Section 17.4. Displaying Query Results as Tables Section 17.5. Displaying Query Results as Hyperlinks Section 17.6. Creating a Navigation Index from Database Content Section 17.7. Storing Images or Other Binary Data Section 17.8. Retrieving Images or Other Binary Data Section 17.9. Serving Banner Ads Section 17.10. Serving Query Results for Download Chapter 18. Processing Web Input with MySQL Section 18.1. Introduction Section 18.2. Creating Forms in Scripts Section 18.3. Creating Single-Pick Form Elements from Database Content Section 18.4. Creating Multiple-Pick Form Elements from Database Content Section 18.5. Loading a Database Record into a Form Section 18.6. Collecting Web Input Section 18.7. Validating Web Input Section 18.8. Using Web Input to Construct Queries Section 18.9. Processing File Uploads Section 18.10. Performing Searches and Presenting the Results Section 18.11. Generating Previous-Page and Next-Page Links Section 18.12. Generating "Click to Sort" Table Headings Section 18.13. Web Page Access Counting Section 18.14. Web Page Access Logging Section 18.15. Using MySQL for Apache Logging Chapter 19. Using MySQL-Based Web Session Management Section 19.1. Introduction Section 19.2. Using MySQL-Based Sessions in Perl Applications Section 19.3. Using MySQL-Based Storage with the PHP Session Manager Section 19.4. Using MySQL for Session BackingStore with Tomcat Appendix A. Obtaining MySQL Software Section A.1. Obtaining Sample Source Code and Data Section A.2. Obtaining MySQL and Related Software
  • 17. Appendix B. JSP and Tomcat Primer Section B.1. Servlet and JavaServer Pages Overview Section B.2. Setting Up a Tomcat Server Section B.3. Web Application Structure Section B.4. Elements of JSP Pages Appendix C. References Section C.1. MySQL Resources Section C.2. Perl Resources Section C.3. PHP Resources Section C.4. Python Resources Section C.5. Java Resources Section C.6. Apache Resources Section C.7. Other Resources Colophon Index
  • 18. Preface The MySQL database management system has become quite popular in recent years. This has been true especially in the Linux and open source communities, but MySQL's presence in the commercial sector now is increasing as well. It is well liked for several reasons: MySQL is fast, and it's easy to set up, use, and administrate. MySQL runs under many varieties of Unix and Windows, and MySQL-based programs can be written in many languages. MySQL is especially heavily used in combination with a web server for constructing database-backed web sites that involve dynamic content generation. With MySQL's rise in popularity comes the need to address the questions posed by its users about how to solve specific problems. That is the purpose of MySQL Cookbook. It's designed to serve as a handy resource to which you can turn when you need quick solutions or techniques for attacking particular types of questions that come up when you use MySQL. Naturally, because it's a cookbook, it contains recipes: straightforward instructions you can follow rather than develop your own code from scratch. It's written using a problem-and-solution format designed to be extremely practical and to make the contents easy to read and assimilate. It contains many short sections, each describing how to write a query, apply a technique, or develop a script to solve a problem of limited and specific scope. This book doesn't attempt to develop full-fledged applications. Instead, it's intended to assist you in developing such applications yourself by helping you get past problems that have you stumped. For example, a common question is, "How can I deal with quotes and special characters in data values when I'm writing queries?" That's not difficult, but figuring out how to do it is frustrating when you're not sure where to start. This book demonstrates what to do; it shows you where to begin and how to proceed from there. This knowledge will serve you repeatedly, because after you see what's involved, you'll be able to apply the technique to any kind of data, such as text, images, sound or video clips, news articles, compressed files, PDF files, or word processing documents. Another common question is, "Can I access tables from two databases at the same time?" The answer is "Yes," and it's easy to do because it's just a matter of knowing the proper SQL syntax. But it's hard to do until you see how; this book will show you. Other things that you'll learn from this book include: • How to use SQL to select, sort, and summarize records. • How to find matches or mismatches between records in two tables. • How to perform a transaction. • How to determine intervals between dates or times, including age calculations. • How to remove duplicate records. • How to store images into MySQL and retrieve them for display in web pages. • How to convert the legal values of an ENUM column into radio buttons in a web page, or the values of a SET column into checkboxes. • How to get LOAD DATA to read your datafiles properly, or find out which values in the file are bad.
  • 19. • How to use pattern matching techniques to cope with mismatches between the CCYY- MM-DD date format that MySQL uses and dates in your datafiles. • How to copy a table or a database to another server. • How to resequence a sequence number column, and why you really don't want to. One part of knowing how to use MySQL is understanding how to communicate with the server—that is, how to use SQL, the language through which queries are formulated. Therefore, one major emphasis of this book is on using SQL to formulate queries that answer particular kinds of questions. One helpful tool for learning and using SQL is the mysql client program that is included in MySQL distributions. By using this client interactively, you can send SQL statements to the server and see the results. This is extremely useful because it provides a direct interface to SQL. The mysql client is so useful, in fact, that the entire first chapter is devoted to it. But the ability to issue SQL queries alone is not enough. Information extracted from a database often needs to be processed further or presented in a particular way to be useful. What if you have queries with complex interrelationships, such as when you need to use the results of one query as the basis for others? SQL by itself has little facility for making these kinds of choices, which makes it difficult to use decision-based logic to determine which queries to execute. Or what if you need to generate a specialized report with very specific formatting requirements? This too is difficult to achieve using just SQL. These problems bring us to the other major emphasis of the book—how to write programs that interact with the MySQL server through an application programming interface (API). When you know how to use MySQL from within the context of a programming language, you gain the ability to exploit MySQL's capabilities in the following ways: • You can remember the result from a query and use it at a later time. • You can make decisions based on success or failure of a query, or on the content of the rows that are returned. Difficulties in implementing control flow disappear when using an API because the host language provides facilities for expressing decision- based logic: if-then-else constructs, while loops, subroutines, and so forth. • You can format and display query results however you like. If you're writing a command-line script, you can generate plain text. If it's a web-based script, you can generate an HTML table. If it's an application that extracts information for transfer to some other system, you might write a datafile expressed in XML. When you combine SQL with a general purpose programming language and a MySQL client API, you have an extremely flexible framework for issuing queries and processing their results. Programming languages increase your expressive capabilities by giving you a great deal of additional power to perform complex database operations. This doesn't mean this book is complicated, though. It keeps things simple, showing how to construct small building blocks by using techniques that are easy to understand and easily mastered. I'll leave it to you to combine these techniques within your own programs, which you can do to produce arbitrarily complex applications. After all, the genetic code is based on only four
  • 20. nucleic acids, but these basic elements have been combined to produce the astonishing array of biological life we see all around us. Similarly, there are only 12 notes in the scale, but in the hands of skilled composers, they can be interwoven to produce a rich and endless variety of music. In the same way, when you take a set of simple recipes, add your imagination, and apply them to the database programming problems you want to solve, you can produce that are perhaps not works of art, but certainly applications that are useful and that will help you and others be more productive. MySQL APIs Used in This Book MySQL programming interfaces exist for many languages, including (in alphabetical order) C, C++, Eiffel, Java, Pascal, Perl, PHP, Python, Ruby, Smalltalk, and Tcl.[] Given this fact, writing a MySQL cookbook presents an author with something of a challenge. Clearly the book should provide recipes for doing many interesting and useful things with MySQL, but which API or APIs should the book use? Showing an implementation of every recipe in every language would result either in covering very few recipes or in a very, very large book! It would also result in a lot of redundancy when implementations in different languages bear a strong resemblance to each other. On the other hand, it's worthwhile taking advantage of multiple languages, because one language often will be more suitable than another for solving a particular type of problem. [] To see what APIs are currently available, visit the development portal at the MySQL web site, located at http://www.mysql.com/portal/development/html/. To resolve this dilemma, I've picked a small number of APIs from among those that are available and used them to write the recipes in this book. This limits its scope to a manageable number of APIs while allowing some latitude to choose from among them. The primary APIs covered here are: Perl Using the DBI module and its MySQL-specific driver PHP Using its set of built-in MySQL support functions Python Using the DB-API module and its MySQL-specific driver Java Using a MySQL-specific driver for the Java Database Connectivity (JDBC) interface Why these languages? Perl and PHP were easy to pick. Perl is arguably the most widely used language on the Web, and it became so based on certain strengths such as its text-processing
  • 21. capabilities. In particular, it's very popular for writing MySQL programs. PHP also is widely deployed, and its use is increasing steadily. One of PHP's strengths is the ease with which you can use it to access databases, making it a natural choice for MySQL scripting. Python and Java are not as popular as Perl or PHP for MySQL programming, but each has significant numbers of followers. In the Java community in particular, MySQL seems to be making strong inroads among developers who use JavaServer Pages (JSP) technology to build database- backed web applications. (An anecdotal observation: After I wrote MySQL (New Riders), Python and Java were the two languages not covered in that book that readers most often said they would have liked to have seen addressed. So here they are!) I believe these languages taken together reflect pretty well the majority of the existing user base of MySQL programmers. If you prefer some language not shown here, you can still use this book, but be sure to pay careful attention to Chapter 2, to familiarize yourself with the book's primary API languages. Knowing how database operations are performed with the APIs used here will help you understand the recipes in later chapters so that you can translate them into languages not discussed. Who This Book Is For This book should be useful for anybody who uses MySQL, ranging from novices who want to use a database for personal reasons, to professional database and web developers. The book should also appeal to people who do not now use MySQL, but would like to. For example, it should be useful to beginners who want to learn about databases but realize that Oracle isn't the best choice for that. If you're relatively new to MySQL, you'll probably find lots of ways to use it here that you hadn't thought of. If you're more experienced, you'll probably be familiar with many of the problems addressed here, but you may not have had to solve them before and should find the book a great timesaver; take advantage of the recipes given in the book and use them in your own programs rather than figuring out how to write the code from scratch. The book also can be useful for people who aren't even using MySQL. You might suppose that because this is a MySQL cookbook and not a PostgreSQL cookbook or an InterBase cookbook that it won't apply to databases other than MySQL. To some extent that's true, because some of the SQL constructs are MySQL-specific. On the other hand, many of the queries are standard SQL that is portable to many other database engines, so you should be able to use them with little or no modification. And several of our programming language interfaces provide database-independent access methods; you use them the same way regardless of which database you're connecting to. The material ranges from introductory to advanced, so if a recipe describes techniques that seem obvious to you, skip it. Or if you find that you don't understand a recipe, it may be best to set it aside for a while and come back to it later, perhaps after reading some of the preceding recipes.
  • 22. More advanced readers may wonder on occasion why in a book on MySQL I sometimes provide explanatory material on certain basic topics that are not directly MySQL-related, such as how to set environment variables. I decided to do this based on my experience in helping novice MySQL users. One thing that makes MySQL attractive is that it is easy to use, which makes it a popular choice for people without extensive background in databases. However, many of these same people also tend to be thwarted by simple barriers to more effective use of MySQL, as evidenced by the common question, "How can I avoid having to type the full pathname of mysql each time I invoke it?" Experienced readers will recognize immediately that this is simply a matter of appropriately setting the PATH environment variable to include the directory where mysql is installed. But other readers will not, particularly Windows users who are used to dealing only with a graphical interface and, more recently, Mac OS X users who find their familiar user interface now augmented by the powerful but sometimes mysterious command line provided by the Terminal application. If you are in this situation, you'll find these more elementary sections helpful in knocking down barriers that keep you from using MySQL more easily. If you're a more advanced user, just skip over such sections. What's in This Book It's very likely when you use this book that you'll have an application in mind you're trying to develop but are not sure how to implement certain pieces of it. In this case, you'll already know what type of problem you want to solve, so you should search the table of contents or the index looking for a recipe that shows how to do what you want. Ideally, the recipe will be just what you had in mind. Failing that, you should be able to find a recipe for a similar problem that you can adapt to suit the issue at hand. (I try to explain the principles involved in developing each technique so that you'll be able to modify it to fit the particular requirements of your own applications.) Another way to approach this book is to just read through it with no specific problem in mind. This can help you because it will give you a broader understanding of the things MySQL can do, so I recommend that you page through the book occasionally. It's a more effective tool if you have a general familiarity with it and know the kinds of problems it addresses. The following paragraphs summarize each chapter, to help give you an overview of the book's contents. Chapter 1, describes how to use the standard MySQL command-line client. mysql is often the first interface to MySQL that people use, and it's important to know how to exploit its capabilities. This program allows you to issue queries and see the results interactively, so it's good for quick experimentation. You can also use it in batch mode to execute canned SQL scripts or send its output into other programs. In addition, the chapter discusses other ways to use mysql, such as how to number output lines or make long lines more readable, how to generate various output formats, and how to log mysql sessions. Chapter 2, demonstrates the basic elements of MySQL programming in each API language: how to connect to the server, issue queries, retrieve the results, and handle errors. It also discusses how to handle special characters and NULL values in queries, how to write library
  • 23. files to encapsulate code for commonly used operations, and various ways to gather the parameters needed for making connections to the server. Chapter 3, covers several aspects of the SELECT statement, which is the primary vehicle for retrieving data from the MySQL server: specifying which columns and rows you want to retrieve, performing comparisons, dealing with NULL values, selecting one section of a query result, using temporary tables, and copying results into other tables. Later chapters cover some of these topics in more detail, but this chapter provides an overview of the concepts on which they depend. You should read it if you need some introductory background on record selection, for example, if you don't yet know a lot about SQL. Chapter 4, describes how to deal with string data. It addresses string comparisons, pattern matching, breaking apart and combining strings, dealing with case-sensitivity issues, and performing FULLTEXT searches. Chapter 5, shows how to work with temporal data. It describes MySQL's date format and how to display date values in other formats. It also covers conversion between different temporal units, how to perform date arithmetic to compute intervals or generate one date from another, leap-year calculations, and how to use MySQL's special TIMESTAMP column type. Chapter 6, describes how to put the rows of a query result in the order you want. This includes specifying the sort direction, dealing with NULL values, accounting for string case sensitivity, and sorting by dates or partial column values. It also provides examples that show how to sort special kinds of values, such as domain names, IP numbers, and ENUM values. Chapter 7, shows techniques that are useful for assessing the general characteristics of a set of data, such as how many values it contains or what the minimum, maximum, or average values are. Chapter 8, describes how to alter the structure of tables by adding, dropping, or modifying columns, and how to set up indexes. Chapter 9, discusses how to get information about the data a query returns, such as the number of rows or columns in the result, or the name and type of each column. It also shows how to ask MySQL what databases and tables are available or about the structure of a table and its columns. Chapter 10, describes how to transfer information between MySQL and other programs. This includes how to convert files from one format to another, extract or rearrange columns in datafiles, check and validate data, rewrite values such as dates that often come in a variety of formats, and how to figure out which data values cause problems when you load them into MySQL with LOAD DATA. Chapter 11, discusses AUTO_INCREMENT columns, MySQL's mechanism for producing sequence numbers. It shows how to generate new sequence values or determine the most
  • 24. recent value, how to resequence a column, how to begin a sequence at a given value, and how to set up a table so that it can maintain multiple sequences at once. It also shows how to use AUTO_INCREMENT values to maintain a master-detail relationship between tables, including some of the pitfalls to avoid. Chapter 12, shows how to perform joins, which are operations that combine rows in one table with those from another. It demonstrates how to compare tables to find matches or mismatches, produce master-detail lists and summaries, enumerate many-to-many relationships, and update or delete records in one table based on the contents of another. Chapter 13, illustrates how to produce descriptive statistics, frequency distributions, regressions, and correlations. It also covers how to randomize a set of rows or pick a row at random from the set. Chapter 14, discusses how to identify, count, and remove duplicate records—and how to prevent them from occurring in the first place. Chapter 15, shows how to handle multiple SQL statements that must execute together as a unit. It discusses how to control MySQL's auto-commit mode, how to commit or roll back transactions, and demonstrates some workarounds you can use if transactional capabilities are unavailable in your version of MySQL. Chapter 16, gets you set up to write web-based MySQL scripts. Web programming allows you to generate dynamic pages or collect information for storage in your database. The chapter discusses how to configure Apache to run Perl, PHP, and Python scripts, and how to configure Tomcat to run Java scripts written using JSP notation. It also provides an overview of the Java Standard Tag Library (JSTL) that is used heavily in JSP pages in the following chapters. Chapter 17, shows how to use the results of queries to produce various types of HTML structures, such as paragraphs, lists, tables, hyperlinks, and navigation indexes. It also describes how to store images into MySQL, retrieve and display them later, and how to send a downloadable result set to a browser. Chapter 18, discusses ways to obtain input from users over the Web and use it to create new database records or as the basis for performing searches. It deals heavily with form processing, including how to construct form elements, such as radio buttons, pop-up menus, or checkboxes, based on information contained in your database. Chapter 19, describes how to write web applications that remember information across multiple requests, using MySQL for backing store. This is useful when you want to collect information in stages, or when you need to make decisions based on what the user has done earlier. Appendix A, indicates where to get the source code for the examples shown in this book, and where to get the software you need to use MySQL and write your own database programs.
  • 25. Appendix B, provides a general overview of JSP and installation instructions for the Tomcat web server. Read this if you need to install Tomcat or are not familiar with it, or if you're never written JSP pages. Appendix C, lists sources of information that provide additional information about topics covered in this book. It also lists some books that provide introductory background for the programming languages used here. As you get into later chapters, you'll sometimes find recipes that assume a knowledge of topics covered in earlier chapters. This also applies within a chapter, where later sections often use techniques discussed earlier in the chapter. If you jump into a chapter and find a recipe that uses a technique with which you're not familiar, check the table of contents or the index to find out where the technique is covered. You should find that it's been explained earlier. For example, if you find that a recipe sorts a query result using an ORDER BY clause that you don't understand, turn to Chapter 6, which discusses various sorting methods and explains how they work. Platform Notes Development of the code in this book took place under MySQL 3.23 and 4.0. Because new features are added to MySQL on a regular basis, some examples will not work under older versions. I've tried to point out version dependencies when introducing such features for the first time. The MySQL language API modules that I used include DBI 1.20 and up, DBD::mysql 2.0901 and up, MySQLdb 0.9 and up, MM.MySQL 2.0.5 and up, and MySQL Connector/J 2.0.14. DBI requires Perl 5.004_05 or higher up through DBI 1.20, after which it requires Perl 5.005_03 or higher. MySQLdb requires Python 1.5.6 or higher. MM.MySQL and MySQL Connector/J require Java SDK 1.1 or higher. Language processors include Perl 5.6 and 5.6.1; PHP 3 and 4; Python 1.5.6, 2.2; and 2.3, and Java SDK 1.3.1. Most PHP scripts shown here will run under either PHP 3 or PHP 4 (although I strongly recommend PHP 4 over PHP 3). Scripts that require PHP 4 are so noted. I do not assume that you are using Unix, although that is my own preferred development platform. Most of the material here should be applicable both to Unix and Windows. The operating systems I used most for development of the recipes in this book were Mac OS X; RedHat Linux 6.2, 7.0, and 7.3; and various versions of Windows (Me, 98, NT, and 2000). I do assume that MySQL is installed already and available for you to use. I also assume that if you plan to write your own MySQL-based programs, you're reasonably familiar with the language you'll use. If you need to install software, see Appendix A. If you require background material on the programming languages used here, see Appendix C.
  • 26. Random documents with unrelated content Scribd suggests to you:
  • 27. future of poverty and debt before him if he marries without a fortune. I can save him from all this. I am rich enough for both. Say that you will not stand in my way. I will remove the only obstacle in his path. I will give up everything. I will stay in this tedious land for his sake. He shall pursue any career he chooses. Think well what it is to rob such a man of his only chance of fortune and ease. For if he does not marry me, he will certainly marry you.” Olivia sat upright in her chair completely dazed. She forgot to be indignant. For the first time the truth enunciated by Madame Koller came home to her. Pembroke was poor. He was extravagant. He was bent upon entering politics. Olivia had, as most women, a practical sympathy. She knew very well the horrors of poverty for such a man, and her portion would be but small. Madame Koller, seeing that she had made her impression, waited —and after a while continued. Her voice was low and very sweet. She seemed pleading for Pembroke’s salvation. “Pembroke, you know, is already deeply in debt. He cannot readily accommodate himself to the style of provincial living here. He would say all these things are trifles. I tell you, Olivia Berkeley, they are not trifles. They are second nature. Is it not cruel of God to make us so dependent on these wretched things? It was for these same wretched things that I endured torture for years—for money and clothes and carriages—just such things as that.” Olivia by a great effort recovered herself. “What you say is true, Madame Koller. But I will not—how can you ask me such things about a man who has never—never”—she stopped at a loss to express her meaning, which implied a reproach at Madame Koller’s want of delicacy. Madame Koller made a gesture of impatience. “What are promises?” she cried. “Nevertheless, I want you to see that if you marry Pembroke it will be his ruin. It would be most wicked selfishness.” “Madame Koller,” answered Olivia, rising, “I will not listen to any more.”
  • 28. “I have nothing more to say,” responded Madame Koller, rising too, and drawing her cloak around her. “I did not expect more from you than conventional tolerance. Had you a heart you would have felt for me—for him—for yourself. Can you conceive of anything more noble, or more piteous than two women, one of whom must make a great sacrifice for the man they both love—come, you need not deny it, or lose your temper—because I see you have a temper.” Olivia’s air and manner did certainly indicate dangerous possibilities. “I repeat, of two women as we are, the one makes the sacrifice—the other feels it to the quick. You talk though like a boarding-school miss. You might have got all the phrases you have used out of a book of deportment.” “I am as sincere as you are, Madame Koller,” answered Olivia, in a voice of restrained anger. “I cannot help it that I am more reserved. I could no more say what you have said—” here a deep flush came into Olivia’s face—“than I could commit murder.” Madame Koller stood up, and as she did so, she sighed deeply. Olivia, for the first time, felt sorry for her. “Women who love are foolish, desperate, suicidal—anything. I do not think that you could ever love.” “Do you think that? I know better. I could love—but not like—not like—” “Not like me?” “Yes, since you have said it. Something—something—would hold me back from what you speak of so openly.” “I always said you were as nearly without feeling as the rest of the people here. Elizabeth Pembroke is the only woman I know of, among all of us, that ever really loved. But see how curious it was with her. She defied her father’s curses—yet she did not have the nerve to marry the man she truly loved, because he happened to be an officer in the Union army, for fear the Peytons and the Coles, and the Lesters, and the rest of them, would have turned their backs on her at church. Bah!”
  • 29. “I don’t think it was want of nerve on Elizabeth Pembroke’s part,” replied Olivia. “She was not born to be happy.” “Nor was I,” cried Madame Koller, despondently. There was no more said for a minute or two. Then Madame Koller spoke again. “Now you know what I feel. I don’t ask anything for myself—I only wish to show you that you will ruin Pembroke if you marry him.” An angry light came into Olivia’s eyes. She stood up, straight and stern, and absolutely grew taller as she looked fixedly at Madame Koller. “This is intolerable,” she said. “There is nothing—absolutely nothing—between Pembroke and me, and yet I am subjected to this cross-questioning.” “You would complain a great deal more of it if there were anything between you,” answered Madame Koller, not without a glimpse of grotesque humor. “But now you know where I stand—and let me tell you, Olivia Berkeley, Pembroke is not guiltless toward me, however he would pretend it”—and without waiting for the angry reply on Olivia’s lips, she vanished through the open door. All that evening, as Olivia sat with a book on her lap, not reading, but watching the flame on the broad hearth, she was turning over in her mind what Madame Koller had said. It had disturbed her very much. It had not raised Pembroke at all in her esteem. She begun, nevertheless, to think with pity over the wretchedness of his fate should he be condemned to poverty. She fancied him harassed by debts, by Miles’ helplessness. Her tender heart filled with pity. “Olivia, my love,” said the Colonel, emerging from behind his newspaper for a moment. “Pembroke means to try for the nomination to Congress—and Cave tells me he is pretty sure to get it. Great pity. A man who goes into public life without out a competence dooms himself to a dog’s life for the remainder of his days. It ruined Pembroke’s father thirty years ago.”
  • 30. Olivia started. This was like an oracle answering her own thoughts. She thought, with a little bitter smile that it did not require much generosity to give up a man on whom one had no claim, and laughed at the idea of a struggle. At all events she would forget it all. It was not so easy to forget though. The thought stayed with her, and went to bed with her, and rose with her next morning. Meanwhile, alas, for Madame Koller. When she came out, she looked around in vain for the negro woman who had come with her. She was not to be seen. They had come by the path that led through the fields, which made it only a mile from The Beeches to Isleham, but in going back, she missed her way—and then being a little afraid of the negroes, she went “around the road,” as they called it. At the first gate, a man galloped out of the darkness. It was Pembroke. He recognized her at once, and got off his horse. “You here,” he cried in surprise—“at this hour”—for it was well on to seven o’clock, and Madame Koller was not noted for her fondness for walking. “Yes,” she answered. “Is anything the matter at Isleham?” he asked—for she could not have come from anywhere else. “Nothing at all,” she replied nervously. “I—I—went over to see Olivia Berkeley,” she added boldly. Pembroke could say nothing. After a pause, Madame Koller burst out. “Pembroke, that girl is made of iron. She cares nothing for you— for anybody but herself.” “And did you find out any of those things by asking her?” he inquired. The twilight was so upon them that Madame Koller could not well see Pembroke’s face, but she realized the tone of suppressed rage in his voice. She herself had a temper that was stormy, and it flamed out at that tone.
  • 31. “Yes, I asked her. Are you a man that you can reproach me with it?” It is difficult for a man, if he is a gentleman, to express his wrath toward a woman. Pembroke was infuriated at the idea that Madame Koller should go to Olivia Berkeley and ask prying questions. He ground his teeth with wrath as he looked at Madame Koller standing before him, in the half light. “What a price I have had to pay for folly,” he cried furiously. “A little damned love-making in a garden—” he was so savage that he was not choice of words and fell into profanity as men naturally do —“a half dozen notes and bouquets—Great God! Is there anything in that which should be a curse to a man’s whole life! And I love Olivia Berkeley. I could make her love me, but—but for you.” His violence sobered Madame Koller at once. “There was not much, certainly,” she responded calmly. “The love-making in the garden and the bouquets would have been little enough—but unfortunately hearts are so perverse. A great many are broken by such trifles. It was very amusing to you but not so amusing altogether to me.” Pembroke began to be ashamed of himself. But he was still magnanimous enough not to tell her that she had taken a queer course about those things. “I suppose I am to blame,” he said with sulky rage after a moment. “I’m willing to shoulder all the blame there is—but why should Olivia Berkeley be insulted and annoyed by this kind of thing? Do you think you will ever accomplish anything by—” he stopped and blushed both for himself and her. “One thing is certain,” he continued. “After what you have said to Olivia Berkeley, questioning her about me, as you have admitted, I shall simply carry out my intention of asking her to marry me. She shall at least know the truth from me. But I think my chances are desperate. Pshaw! I have no chance at all. It’s rather grotesque, don’t you think, for a man to ask a woman to marry him when he
  • 32. knows that she will throw him over and despise him from the bottom of her heart?” “That I must decline to discuss with you,” quietly answered Madam Koller. She was indeed quiet, for at last—and in an instant, she realized that she must forever give up Pembroke. All that long journey was for nothing—all those months of wretched loneliness, of still more wretched hopes and fears, were in vain. She heard Pembroke saying: “You had best let me see you home. It is too late for you to be out alone.” “You will not,” she replied. “I will not permit you, after what you have said, to go one step with me.” Pembroke felt thoroughly ashamed. It was one of the incidents of his association with Madame Koller and Ahlberg that they always made him say and do things he was ashamed of. In short, they demoralized him. He had been betrayed by temper and by circumstances into things that were utterly against his self-respect— like this ebullition of rage against a woman. In the plenitude of his remorse he was humble to the last degree. “May I,” he asked—“may I, at least accompany you to your own grounds? It is really not safe for you.” Madame Koller turned upon him and stamped her foot. “No, no—always no. Do you think there is any danger on earth from which I would accept your protection? Go to Olivia Berkeley. She would marry you in your poverty if it suited her whim, and be a millstone around your neck. Go to her, I say.” Pembroke watched her figure disappearing in the dusk along the faint white line of the road. He stood still with his horse’s bridle in his hand, turning over bitter things in his mind. He thought he would not go to Isleham that night. He was depressed and conscience-stricken, and in no lover-like mood. He mounted his horse and rode slowly back to Malvern.
  • 33. CHAPTER XII. When two weeks had passed, Pembroke still had not gone to Isleham—but in that time much had happened. The congressional convention had been held, and the ball had been opened for him by Cave with great brilliancy and power—and after a hard fight of two days, Pembroke had got the nomination for Congress. It was of infinite satisfaction to him in many ways. First because of the honor, which he honestly coveted—and again because of the ready money his election would bring. Modest as a congressional salary would be, it was at least in cash—and that was what he most needed then. He did not have a walk over. The parties were about evenly divided, and it was known that the canvass would be close and exciting. Pembroke warmed to his work when he knew this. It was like Bob Henry’s trial—it took hold of his intellectual nature. He was called magnetic—and he had a nerve power, a certain originality about him that captivated his audiences. There is nothing that a mixed crowd of whites and blacks at the South so much hates as a demagogue. Especially is this the case with the “poor whites” and the negroes. It was from them that Pembroke knew he must get the votes to elect. When he appeared on the hustings, he was the same easy, gentlemanly fellow as in a drawing-room. He slapped no man on the back, nor offered treats, nor was there any change in his manner. He was naturally affable, and he made it his object to win the good will of his hearers through their enlightenment, not their prejudices. The Bob Henry episode did him immense service. A great revolution had taken place in regard to Bob Henry. As, when he had been poor and in prison and friendless and suspected, everybody had been down on him, so now when he was free and cleared of suspicion, and had been an object of public attention, he became something of a hero. He worked like a beaver among his own people for “Marse French.” At “night meetings” and such, he was powerful—and in the pulpits of the colored people, the
  • 34. fiat went forth that it “warn’t wuff while fer cullud folks to pay de capilation tax fer to git young Mr. Hibbs, who warn’ no quality nohow” into Congress—for the redoubtable Hibbs was Pembroke’s opponent. This too, had its favorable action on his canvass. As for Petrarch, he claimed a direct commission from the Lord to send “Marse French ter Congriss. De Lord, de Great Physicianer, done spoken it ter me in de middle o’ de night like he did ter little Samson, sayin’ ‘Petrarch whar is you?’ He say ‘What fur I gin you good thinkin’ facticals, ’cep’ fur ter do my will? An’ it ain’t Gord’s will dat no red headed Hibbs be ’lected over ole Marse French Pembroke’s son, dat allus treated me wid de greatest circumlocution.” Petrarch’s oratory was not without its effect. Pembroke’s natural gift of oratory had been revealed to him at the time of Bob Henry’s acquittal. He cultivated it earnestly, avoiding hyperbole and exaggeration. There is nothing a Virginian loves so well as a good talker. Within ten days of the opening of the campaign, Pembroke knew that he was going to win. Hibbs had a very bad war record. Pembroke had a very good one. The canvass therefore to him, was pleasant, exciting, and with but little risk. But Olivia Berkeley’s place had not been usurped. He had not meant or desired to fall in love. As he had said truly to Cave, there were other things for him than marriage. But love had stolen a march upon him. When he found it out, he accepted the result with great good humor—and he had enough masculine self-love to have good hopes of winning her until—until Madame Koller had put her oar in. But even then, his case did not seem hopeless, after the first burst of rage and chagrin. She would not surrender at once—that he felt sure, and he rather liked the prospect of a siege, thinking to conquer her proud spirit by a bold stroke at last. But Madame Koller had changed all this. He was determined to make Olivia Berkeley know how things stood between Madame Koller and himself—and the best way to do it was to tell her where his heart was really bestowed. It was in the latter part of April before a day came that he could really call his own. He walked over from Malvern late in the
  • 35. afternoon, and found Olivia, as he thought he should, in the garden. The walks were trimmed up, and the flower-beds planted. Olivia, in a straw hat and wearing a great gardening apron full of pockets, gravely removed her gloves, her apron, and rolled them up before offering to shake hands with Pembroke. “Allow me to congratulate our standard-bearer, and to apologize for my rustic occupations while receiving so distinguished a visitor.” Pembroke looked rather solemn. He was not in a trifling mood that afternoon, and he thought Olivia deficient in perception not to see at once that he had come on a lover’s errand. Is there anything more charming than an old-fashioned garden in the spring? The lilac bushes were hanging with purple blossoms, and great syringa trees were brave in their white glory. The guelder roses nodded on their tall stems, and a few late violets scented the air. It was a very quiet garden, and the shrubbery cut it off like a hermitage. Pembroke had selected his ground well. Olivia soon saw that something was on his mind, but she did not suspect what it was. She had heard that Madame Koller was to leave the country, and she thought perhaps Pembroke needed consolation. Men often go to one woman to be consoled for the perfidy of another. Presently as they strolled along, she stooped down, and plucked some violets. “I thought they were quite gone,” she said. “Here are four,” and as she held them out to Pembroke, he took her little hand, inclosing the violets in his own strong grasp. There was the time, the place, the opportunity, and Olivia was more than half won. Yet, half an hour afterward, Pembroke came out of the garden, looking black as a thunder-cloud, and strode away down by the path through the fields—a rejected suitor. Olivia remained in the garden. The cool spring night came on apace. She could not have described her own emotions to have saved her life— or what exactly led up to that angry parting—for it will have been seen before this that Pembroke was subject to sudden gusts of temper. She had tried to put before him what she felt herself obliged
  • 36. in honor to say—that the Colonel’s modest fortune was very much exaggerated—and she had blundered wretchedly in so doing. Pembroke had rashly assumed that she meant his poverty stood in the way. Then he had as wretchedly blundered about Madame Koller, and a few cutting words on both sides had made it impossible for either to say more. Olivia, pale and red by turns, looked inexpressibly haughty when Madame Koller’s name was mentioned. Lovers’ quarrels are proverbially of easy arrangement—but the case is different when the woman is high strung and the man high tempered. Olivia received Pembroke’s confession with such cool questionings that his self-love was cruelly wounded. Pembroke took his dismissal so debonairly that Olivia was irresistibly impelled to make it stronger. The love scene, which really began very prettily, absolutely degenerated into a quarrel. Pembroke openly accused Olivia of being mercenary. Olivia retaliated by an exasperating remark, implying that perhaps Madame Koller’s fortune was not without its charm for him—to which Pembroke, being entirely innocent, responded with a rude violence that made Olivia more furiously angry than she ever expected to be in her life. Pembroke seeing this in her pale face and blazing eyes, stalked down the garden path, wroth with her and wroth with the whole world. He, walking fast back through the woods, was filled with rage and remorse—chiefly with rage. She was a cold-blooded creature—how she did weigh that money question—but—ah, she had a spirit of her own—such a spirit as a man might well feel proud to conquer—and the touch of her warm, soft hand! Olivia felt that gap, that chasm in existence, when a shadowy array of vague hopes and fears suddenly falls to the ground. Pembroke had been certainly too confident and much too overbearing—but—it was over. When this thought struck her, she was walking slowly down the broad box-bordered walk to the gate. The young April moon was just appearing in the evening sky. She stopped suddenly and stood still. The force of her own words to him smote her. He would certainly never come back. She turned and flew swiftly back to the upper part of the garden, and stood in the very spot by the lilac hedge, and went over it all in her mind. Yes. It was
  • 37. then over for good—and he probably would not marry for a long, long time. She remembered having heard Cave and her father speak of Pembroke’s half joking aversion to matrimony. It would be much better for him if he did not, as he had made up his mind to enter for a career. But strange to say this did not warm her heart, which felt as heavy as a stone. Presently she went into the house, and was quite affectionate and gay with her father, playing the piano and reading to him. “Fathers are the pleasantest relations in the world,” she said, as she kissed him good-night, earlier in the evening than usual. “No fallings out—no misunderstandings—perfect constancy. Papa, I wouldn’t give you up for any man in the world.” “Wouldn’t you, my dear?” remarked that amiable old cynic incredulously.
  • 38. CHAPTER XIII. One of the drawbacks of Arcadia is that everybody knows everybody else’s business—and the possibility of this added to Pembroke’s extreme mortification. He thought with dread of the Colonel’s elaborate pretense of knowing nothing whatever about the affair, Mrs. Peyton’s sly rallying, Mr. Cole’s sentimental condolence— it was all very exasperating. But solely to Olivia’s tact and good sense both escaped this. Not one soul was the wiser. Olivia, however she felt, and however skillfully she might avoid meeting Pembroke alone, was apparently so easy, so natural and self- possessed, that it put Pembroke on his mettle. Together they managed to hoodwink the whole county about their private affairs— even Colonel Berkeley, who, if he suspected anything, was afraid to let on, and Miles, whose devotion to Olivia became stronger every day. Luckily for Pembroke, he could plunge into the heat of his canvass. After he had lost Olivia, the conviction of her value came to him with overpowering force. There was no girl like her. She did not protest and talk about her emotions and analyze them as some women did—Madame Koller, for example—but Pembroke knew there was “more to her,” as Cave said, “than a dozen Eliza Peytons.” Perhaps Cave suspected something, but Pembroke knew he had nothing to fear from his friend’s manly reticence. But to have lost Olivia Berkeley! Pembroke sometimes wondered at himself—at the way in which this loss grew upon him, instead of diminishing with time, as the case usually is with disappointments. Yet all this time he was riding from place to place, speaking, corresponding, as eager to win his election as if he were the happiest of accepted lovers—more so, in fact. And then, there was that Ahlberg affair to trouble him. Like all the men of his race and generation, he firmly believed there were some cases in which blood must be shed—but a roadside quarrel, in which
  • 39. nothing but personal dislike figured, did not come under that head. Pembroke was fully alive to the folly and wickedness of fighting Ahlberg under the circumstances—but it was now impossible for him to recede. He could only hope and pray that something would turn up to prevent a meeting so indefinitely fixed. But if Ahlberg’s going away were the only thing to count upon, that seemed far enough out of the question, for he stayed on and on at the village tavern, playing cards with young Hibbs and one or two frequenters of the place, riding over to play Madame Koller’s accompaniments, fishing for invitations to dine at Isleham—in short, doing everything that a man of his nature and education could do to kill time. Pembroke could not but think that Ahlberg’s persistence could only mean that he was really and truly waiting for his revenge. So there were a good many things to trouble the “white man’s candidate,” who was to make such a thorough and brilliant canvass, and whose readiness, cheerfulness and indomitable spirit was everywhere remarked upon. One night, as Pembroke was riding home after a hard day’s work in the upper part of the county, and was just entering the long straggling village street, his horse began to limp painfully. Pembroke dismounted, and found his trusty sorrel had cast a shoe,—a nail had entered his foot, and there was a job for the blacksmith. He led the horse to the blacksmith’s shop, which was still open, although it was past seven o’clock, and on the promise of having the damage repaired in half an hour, walked over to the village tavern. It was in September, and the air was chilly. The landlord ushered him into what was called the “card room”—the only place there was a fire. A cheery blaze leaped up the wide old-fashioned chimney, and by the light of kerosene lamps, Pembroke saw a card party at a round table in the corner. It was Ahlberg, young Hibbs, his political opponent, and two or three other idle young men of the county. According to the provincial etiquette, Pembroke was invited to join the game, which he courteously declined on the ground that he was much fatigued and was only waiting for the blacksmith to put his horse’s shoe on before starting for home. The game then proceeded.
  • 40. Pembroke felt awkward and ill at ease. He knew he was in the way, as the loud laughter from Hibbs and his friends, and Ahlberg’s subdued chuckle had ceased when he came in. They played seriously—it was écarté, a game that Ahlberg had just taught his postulants. Young Hibbs had a huge roll of bills on the table before him, which he somewhat ostentatiously displayed in the presence of his opponent, whose lack of bills was notorious. Also, Pembroke felt that his presence induced young Hibbs to bet more recklessly than ever, as a kind of bravado—and Ahlberg always won, when the stake was worth any thing. The waiting seemed interminable to Pembroke seated in front of the fire. The conversation related solely to the game. Presently Pembroke started slightly. Ahlberg was giving them some general views on the subject of écarté. Pembroke himself was a good player, and he had never heard this scheme of playing advocated. Over the mantel was an old-fashioned mirror, tilted forward. Although his back was to the players, Pembroke could see every motion reflected in the glass. He saw Hibbs lose three times running in fifteen minutes. Pembroke’s sight was keen. He fixed it on the glass and a curious look came into his dark face. Once he made a slight movement as if to rise, but sat still. A second time he half rose and sat down again—nobody in the room had seen the motion. Then, without the slightest warning, he suddenly took three strides over to the card table and, reaching over, seized Ahlberg by the collar, and lifted him bodily up from the table into a standing position. “Produce that king of spades,” he said. If he had shot Ahlberg no greater surprise could have been created. Hibbs jumped up, dashing the cards and money in a heap on the floor, and nearly upsetting the table. One of his companions grabbed the lamp to save it. Ahlberg turned a deathly color, and made some inarticulate effort to be heard, and tried to wrest himself from Pembroke’s grasp. But it was in vain. Pembroke shook him slightly, but never relaxed his hold.
  • 41. “The king of spades, I say.” Without a word Ahlberg reached down, and from some unknown depths produced the card. He was no coward, but he was overmastered physically and mentally. He knew in an instant that Pembroke had seen it all, and there was no shadow of escape for him. Pembroke let go of Ahlberg’s collar, and, taking out a white handkerchief, wiped his hands carefully. Ahlberg had sunk back, panting, in a chair. The grip of a hand like Pembroke’s in the neighborhood of the wind-pipe is calculated to shorten the breath. Hibbs looked dazed, from one to the other, and then to the floor, where the cards had fallen. The one damning card lay on the table. “I saw it twice before this, in the glass,” said Pembroke to Hibbs. “Each time I tried to catch him, but he did it so well I couldn’t. But the last time it was perfectly plain,—you see. I could see under the table in the glass. You had better pick up your money, Hibbs.” At this, Ahlberg spoke up. “All of it is Monsieur Hibbs’,” he said with elaborate politeness, recovering his breath a little, “except two fifty-dollar notes, which are mine.” Pembroke picked out the two fifty-dollar notes and dashed them in Ahlberg’s face, who very cleverly caught them and put them in his pocket. “Mr. Pembroke,” said Hibbs, stammering and blushing, “I—I— hope you won’t say anything about this, sir. It would ruin me—I don’t mean in the canvass, for I tell you truly, sir, I hope you’ll be elected, and if it wasn’t for the party, I’d give up the fight now. But my mother, sir, don’t approve—don’t approve of playing for money—and—” “You are perfectly safe,” answered Pembroke, “and quite right in your idea of duty to your party, and your dislike to wound your mother is creditable. But as for this dog, he must leave this county at once.”
  • 42. Ahlberg said not a word. He did not lack mere physical courage, but cheating at cards was, to him, the most heinous offense of which he could be convicted. He had been caught—it was the fortune of war—there was nothing to be said or done. At least, it happened in this out-of-the-way corner of the world, where it could never be known to anybody—for he did not count his acquaintances in the country as anybody, unless—perhaps—Madame Koller. At that he grew pale for the first time. He really wanted Madame Koller’s money. But, in fact, he was somewhat dazed by Pembroke’s way of settling the trouble. It really shocked his ethics to see one gentleman punish another as if he were a bargeman or a coal heaver. These extraordinary Anglo-Saxons! But one thing was plain with him—if he did not remain perfectly quiescent Pembroke was quite capable of throwing him bodily out of the window—and if he had lost his honor, as he called it, there was no reason why he shouldn’t save his bones. Pembroke, however, although he would have sworn that nothing Ahlberg could do in the way of rascality could surprise him, was as yet amazed, astounded, and almost puzzled by the promptness with which Ahlberg acquiesced in the status which Pembroke established. Ahlberg made no protest of innocence—he did not bluster, or grow desperate, or break down hysterically, as even a very bad man might under the circumstances. He simply saw that if he said anything, he might feel the weight of Pembroke’s arm. Nothing that he could have said or done was as convincing of his thorough moral obtuseness as the way in which he accepted his own exposure. Just then the landlord opened the door. “Mr. Pembroke, your horse is at the door. It’s going to be a mighty bad night though— there’s a cloud coming up. You’d better stay and join them gentlemen in their game.” “No, I thank you,” replied Pembroke, and turning to Ahlberg. “Of course, after what has passed, it is out of the question that I should fight you. Good God! I’d just as soon think of fighting a jail bird! Don’t take too long to get out of this county. Good night, Mr. Hibbs—good night—good night.”
  • 43. Hibbs accompanied him out, and stood by him while he mounted. “Mr. Pembroke,” he said, holding his hat in his hand, “I’m very much obliged for what you have done for me, and what you have promised. I promise you I’ll never touch a card for money again as long as I live.” “And don’t touch a card at all with such an infernal rascal as Ahlberg,” answered Pembroke, altogether forgetting sundry agreeable games he had enjoyed with Ahlberg in Paris, and even in that very county—but it had been a good while ago, and Ahlberg had not tried any tricks on him. This relieved Pembroke of a load of care—the folly of that quarrel was luckily escaped. But he debated seriously with himself whether he ought not to tell Madame Koller of Ahlberg’s behavior, that she might be on her guard against him. In a day or two he heard, what did not surprise him, that Ahlberg was about to leave the country— but at the same time that Madame Koller and her mother were to leave The Beeches rather suddenly. Mrs. Peyton met him in the road, and stopped her carriage to tell him about Eliza Peyton’s consummate folly in allowing that Ahlberg to stick to her like a burr— they actually intended crossing in the same steamer. That determined Pembroke. He rode over to The Beeches, and sitting face to face with Madame Koller in her drawing-room, told her the whole story. Pembroke was somewhat shocked to observe how little she seemed shocked at Ahlberg’s conduct. It was certainly very bad, but—but—she had known him for so long. Pembroke was amazed and disgusted. As he was going, after a brief and very business-like visit, Madame Koller remarked, “And it is so strange about Louis. The very day after it happened, he was notified of his appointment as First Secretary in the Russian diplomatic service—or rather his re- appointment, for he was in it ten years—and he has come into an excellent property—quite a fortune in fact for a first secretary.” Pembroke rode back home slowly and thoughtfully. He had never before realized how totally wanting Madame Koller was in integrity of mind. Olivia Berkeley now—
  • 44. CHAPTER XIV. It takes a long time for a country neighborhood to recover from a sensation. Three or four years after Madame Koller, or Eliza Peyton had disappeared along with her mother and Ahlberg, people were still discussing her wonderful ways. Mr. Cole was paying his court mildly to Olivia Berkeley, but in his heart of hearts he had not forgotten his blonde enslaver. The Colonel was the same Colonel— his shirt-ruffle rushed out of his bosom as impetuously as of old. He continued to hate the Hibbses. Dashaway had been turned out to grass, but another screw continued to carry the Colonel’s colors to defeat on the county race track. Olivia, too, had grown older, and a great deal prettier. A chisel called the emotions, is always at work upon the human countenance—a face naturally humane and expressive grows more so, year by year. It is not to be expected that she was very happy in that time. Life in the country, varied by short visits to watering places in the summer and occasionally to cities in the winter, is dull at best for a girl grown up in the whirl of civilization. There came a time—after Pembroke, taking Miles with him had gone to Washington, when life began to look very black to Olivia Berkeley’s eyes. She suffered for want of an object in life. She loved her father very much, but that cheerful, healthful and robustious old person hardly supplied the craving to love and tend which is innate in every woman’s heart. It is at this point in their development that women of inferior nature begin to deteriorate. Not so with Olivia Berkeley. Life puzzled and displeased her. She found herself full of energy, with many gifts and accomplishments, condemned in the flower of her youth to the dull routine of a provincial life in the country. She could not understand it —neither could she sit down in hopeless resignation and accept it. She bestirred herself. Books there were in plenty at Isleham—the piano was an inestimable comforter. She weathered the storm of ennui in this manner, and came to possess a certain content—to
  • 45. control the outward signs of inward restlessness. Meanwhile she read and studied feverishly, foolishly imagining that knowing a great number of facts would make her happy. Of course it did not—but it made her less unhappy. As for Pembroke, the fate which had fallen hard on Olivia Berkeley had fondly favored him. He was not only elected to Congress, but he became something of a man after he got there. The House of Representatives is a peculiar body—peculiarly unfavorable to age, and peculiarly favorable to youth. Pembroke, still smarting under his mortification, concluded to dismiss thoughts of any woman from his mind for the present, and devote himself to the work before him. With that view, he scanned closely his environment when he went to Washington. He saw that as a young member he was not expected to say anything. This left him more leisure to study his duties. He aspired to be a lawyer—always a lawyer. He found himself appointed to a committee—and his fellow members on it very soon found that the quiet young man from Virginia was liable to be well informed on the legal questions which the House and the committees are constantly wrangling over. Every man on that committee became convinced that the quiet young man would some day make his mark. This was enough to give him a good footing in the House. His colleagues saw that election after election, the young man was returned, apparently without effort on his part, for Pembroke was not a demagogue, and nothing on earth would have induced him to go into a rough and tumble election campaign. At last it got so that on the few occasions when he rose in his place, he had no trouble in catching the Speaker’s eye. He was wise enough not to be betrayed by his gift of oratory into speech-making—a thing the House will not tolerate from a young member. He had naturally a beautiful and penetrating voice and much grace and dignity in speaking. These were enough without risking making himself ridiculous by a premature display as an orator. He sometimes thrilled when the great battles were being fought before his eyes—it was in the reconstruction time—and longed for the day which he felt would come when he might go down among the captains and the shouting, but he had the genius of waiting. Then he was a pleasant man at dinner—and his four years army service had given him a soldierly
  • 46. frankness and directness. He lived with Miles in a simple and quiet way in Washington. He did not go out much, as indeed he had no time. He became quite cynical to himself about women. The pretty girls from New York were quite captivated with the young man from Virginia. They wanted to know all about his lovely old place, especially one charming bud, Miss de Peyster. “Come and see it,” Pembroke would answer good-naturedly. “Half the house was burned up by our friends, the enemy—the other half is habitable.” “And haven’t you miles and miles of fields and forests, like an English nobleman?” the gay creature asked. “Oh yes. Miles and miles. The taxes eat up the crops, and the crops eat up the land.” “How nice,” cried the daughter of the Knickerbockers. “How much more romantic it is to have a broken down old family mansion and thousands of acres of land, than to be a stockbroker or a real estate man—and then to have gone through the whole war—and to have been promoted on the field—” Pembroke smiled rather dolefully. His ruined home, his mortgaged acres, Miles’ life-long trouble, his four years of marching and starving and fighting, did not appear like romantic incidents in life, but as cruel blows of fate to him. But Helena de Peyster was a pleasant girl, and her mother was gentle, amiable, and well-bred. They had one of the gayest and most charming houses in Washington, and entertained half the diplomatic corps at dinner during every week. They would gladly have had Pembroke oftener. He came in to quiet dinners with them, assumed a fatherly air with Helena, and liked them cordially. They were good to Miles too, who sometimes went to them timidly on rainy afternoons when he would not be likely to find anybody else. So went the world with Pembroke for some years until one evening, going to his modest lodgings, he found a letter with Colonel Berkeley’s big red seal on it awaiting him.
  • 47. Welcome to our website – the ideal destination for book lovers and knowledge seekers. With a mission to inspire endlessly, we offer a vast collection of books, ranging from classic literary works to specialized publications, self-development books, and children's literature. Each book is a new journey of discovery, expanding knowledge and enriching the soul of the reade Our website is not just a platform for buying books, but a bridge connecting readers to the timeless values of culture and wisdom. With an elegant, user-friendly interface and an intelligent search system, we are committed to providing a quick and convenient shopping experience. Additionally, our special promotions and home delivery services ensure that you save time and fully enjoy the joy of reading. Let us accompany you on the journey of exploring knowledge and personal growth! ebookfinal.com