|
| 1 | +################# |
| 2 | +Database Commands |
| 3 | +################# |
| 4 | + |
| 5 | +CodeIgniter provides some simple commands for databse management. |
| 6 | + |
| 7 | +.. contents:: |
| 8 | + :local: |
| 9 | + :depth: 2 |
| 10 | + |
| 11 | +************************* |
| 12 | +Showing Table Information |
| 13 | +************************* |
| 14 | + |
| 15 | +List the Tables in Your Database |
| 16 | +================================ |
| 17 | + |
| 18 | +db:table --show |
| 19 | +--------------- |
| 20 | + |
| 21 | +To list all the tables in your database straight from your favorite terminal, |
| 22 | +you can use the ``db:table --show`` command:: |
| 23 | + |
| 24 | + > php spark db:table --show |
| 25 | + |
| 26 | +When using this command it is assumed that a table exists. |
| 27 | +Otherwise, CodeIgniter will complain that the database has no tables. |
| 28 | + |
| 29 | +Retrieve Some Records |
| 30 | +===================== |
| 31 | + |
| 32 | +db:table |
| 33 | +-------- |
| 34 | + |
| 35 | +When you have a table named ``my_table``, you can see the field names and the records of a table:: |
| 36 | + |
| 37 | + > php spark db:table my_table |
| 38 | + |
| 39 | +You can also pass a few options:: |
| 40 | + |
| 41 | + > php spark db:table my_table --limit-rows 50 --limit-field-value 20 --desc |
| 42 | + |
| 43 | +The option ``--limit-rows 50`` limits the number of rows to 50 rows. |
| 44 | + |
| 45 | +The option ``--limit-field-value 20`` limits the length of the field values to 20 characters, to prevent confusion of the table output in the terminal. |
| 46 | + |
| 47 | +The option ``--desc`` sets the sort direction to "DESC". |
| 48 | + |
| 49 | +Retrieve Field Metadata |
| 50 | +======================= |
| 51 | + |
| 52 | +db:table --metadata |
| 53 | +------------------- |
| 54 | + |
| 55 | +When you have a table named ``my_table``, you can see metadata like the column type, max length of the table with the ``--metadata`` option:: |
| 56 | + |
| 57 | + > php spark db:table my_table --metadata |
| 58 | + |
| 59 | +When using this command it is assumed that the table exists. |
| 60 | +Otherwise, CodeIgniter will show a table list to select. |
| 61 | +Also, you can use this command as ``db:table --metadata``. |
0 commit comments