| | 609 | </li> |
|---|
| | 610 | <li>formatter |
|---|
| | 611 | <p>The results of any queries that are executed can be printed in different formats. |
|---|
| | 612 | Output will always be sent to a file, unless you set the <em>usefile</em> attribute to <em>false</em>. |
|---|
| | 613 | The path to the output file file can be specified by the <em>outfile</em> attribute; there is a default filename that |
|---|
| | 614 | will be returned by the formatter if no output file is specified.</p> |
|---|
| | 615 | <p>There are three predefined formatters - one prints the query results in XML format, |
|---|
| | 616 | the other emits plain text. Custom formatters that |
|---|
| | 617 | extend phing.tasks.pdo.PDOResultFormatter can be specified.</p> |
|---|
| | 618 | <h3>Attributes</h3> |
|---|
| | 619 | <table> |
|---|
| | 620 | <thead> |
|---|
| | 621 | <tr> |
|---|
| | 622 | <th>Name</th> |
|---|
| | 623 | <th>Type</th> |
|---|
| | 624 | <th>Description</th> |
|---|
| | 625 | <th>Default</th> |
|---|
| | 626 | <th>Required</th> |
|---|
| | 627 | </tr> |
|---|
| | 628 | </thead> |
|---|
| | 629 | <tbody> |
|---|
| | 630 | <tr> |
|---|
| | 631 | <td>type</td> |
|---|
| | 632 | <td>String</td> |
|---|
| | 633 | <td> Use a predefined formatter (either <em>xml</em> or <em>plain</em>). </td> |
|---|
| | 634 | <td>n/a</td> |
|---|
| | 635 | <td rowspan="2">One of these attributes is required. </td> |
|---|
| | 636 | </tr> |
|---|
| | 637 | <tr> |
|---|
| | 638 | <td>classname</td> |
|---|
| | 639 | <td>String</td> |
|---|
| | 640 | <td> Name of a custom formatter class (must extend phing.tasks.ext.pdo.PDOResultFormatter). </td> |
|---|
| | 641 | <td>n/a</td> |
|---|
| | 642 | </tr> |
|---|
| | 643 | <tr> |
|---|
| | 644 | <td>usefile</td> |
|---|
| | 645 | <td>Boolean</td> |
|---|
| | 646 | <td> Boolean that determines whether output should be sent to a file. </td> |
|---|
| | 647 | <td>true</td> |
|---|
| | 648 | <td>No</td> |
|---|
| | 649 | </tr> |
|---|
| | 650 | <tr> |
|---|
| | 651 | <td>outfile</td> |
|---|
| | 652 | <td>File</td> |
|---|
| | 653 | <td>Path to file in which to store result. </td> |
|---|
| | 654 | <td>Depends on formatter</td> |
|---|
| | 655 | <td>No</td> |
|---|
| | 656 | </tr> |
|---|
| | 657 | <tr> |
|---|
| | 658 | <td>showheaders</td> |
|---|
| | 659 | <td>Boolean</td> |
|---|
| | 660 | <td>(only applies to plain formatter) Whether to show column headers.</td> |
|---|
| | 661 | <td>false</td> |
|---|
| | 662 | <td>No</td> |
|---|
| | 663 | </tr> |
|---|
| | 664 | <tr> |
|---|
| | 665 | <td>coldelim</td> |
|---|
| | 666 | <td>String</td> |
|---|
| | 667 | <td>(only applies to plain formatter) The column delimiter.</td> |
|---|
| | 668 | <td>,</td> |
|---|
| | 669 | <td>No</td> |
|---|
| | 670 | </tr> |
|---|
| | 671 | <tr> |
|---|
| | 672 | <td>rowdelim</td> |
|---|
| | 673 | <td>String</td> |
|---|
| | 674 | <td>(only applies to plain formatter) The row delimiter.</td> |
|---|
| | 675 | <td>\n</td> |
|---|
| | 676 | <td>No</td> |
|---|
| | 677 | </tr> |
|---|
| | 678 | <tr> |
|---|
| | 679 | <td>encoding</td> |
|---|
| | 680 | <td>String</td> |
|---|
| | 681 | <td>(only applies to XML formatter) The xml document encoding.</td> |
|---|
| | 682 | <td>(PHP default)</td> |
|---|
| | 683 | <td>No</td> |
|---|
| | 684 | </tr> |
|---|
| | 685 | <tr> |
|---|
| | 686 | <td>formatoutput</td> |
|---|
| | 687 | <td>Boolean</td> |
|---|
| | 688 | <td>(only applies to XML formatter) Whether to format XML output.</td> |
|---|
| | 689 | <td>true</td> |
|---|
| | 690 | <td>No</td> |
|---|
| | 691 | </tr> |
|---|
| | 692 | </tbody> |
|---|
| | 693 | </table> |
|---|
| | 694 | <h3>Examples</h3> |
|---|
| | 695 | <pre><pdo url="pgsql:host=localhost dbname=test"> |
|---|
| | 696 | <fileset dir="sqlfiles"> |
|---|
| | 697 | <include name="*.sql"/> |
|---|
| | 698 | </fileset> |
|---|
| | 699 | |
|---|
| | 700 | <!-- xml formatter --> |
|---|
| | 701 | <formatter type="xml" output="output.xml"/> |
|---|
| | 702 | |
|---|
| | 703 | <!-- custom formatter --> |
|---|
| | 704 | <formatter classname="path.to.CustomFormatterClass"> |
|---|
| | 705 | <param name="someClassAttrib" value="some-value"/> |
|---|
| | 706 | </formatter> |
|---|
| | 707 | |
|---|
| | 708 | <!-- No output file + usefile=false means it goes to phing log --> |
|---|
| | 709 | <formatter type="plain" usefile="false" /><br /></pdo> |
|---|
| | 710 | </pre> |
|---|
| | 711 | |
|---|