... | ... |
@@ -1458,7 +1458,7 @@ L<DBIx::Custom Wiki|https://github.com/yuki-kimoto/DBIx-Custom/wiki> |
1458 | 1458 |
my $cache = $dbi->cache; |
1459 | 1459 |
$dbi = $dbi->cache(1); |
1460 | 1460 |
|
1461 |
-Enable caching of L<DBIx::Custom::Query>, |
|
1461 |
+Enable caching L<DBIx::Custom::Query>, |
|
1462 | 1462 |
default to 1. |
1463 | 1463 |
|
1464 | 1464 |
=head2 C<data_source> |
... | ... |
@@ -1491,7 +1491,7 @@ default to the following values. |
1491 | 1491 |
} |
1492 | 1492 |
|
1493 | 1493 |
You should not change C<AutoCommit> value directly |
1494 |
-to check if the process is in transaction correctly. |
|
1494 |
+to check if the process is in transaction. |
|
1495 | 1495 |
L<DBIx::Custom> determin the process is in transaction |
1496 | 1496 |
if AutoCommit is 0. |
1497 | 1497 |
|
... | ... |
@@ -1571,6 +1571,13 @@ You can use three column name to apply filter to column data. |
1571 | 1571 |
2. table.column : book.author |
1572 | 1572 |
3. table__column : book__author |
1573 | 1573 |
|
1574 |
+=head2 C<cache_method> |
|
1575 |
+ |
|
1576 |
+ $dbi = $dbi->cache_method(\&cache_method); |
|
1577 |
+ $cache_method = $dbi->cache_method |
|
1578 |
+ |
|
1579 |
+Method to set and get caches. |
|
1580 |
+ |
|
1574 | 1581 |
=head2 C<connect> |
1575 | 1582 |
|
1576 | 1583 |
my $dbi = DBIx::Custom->connect(data_source => "dbi:mysql:database=dbname", |
... | ... |
@@ -1616,87 +1623,246 @@ or the count of affected rows if insert, update, delete statement is executed. |
1616 | 1623 |
|
1617 | 1624 |
=head2 C<delete> |
1618 | 1625 |
|
1619 |
- $dbi->delete(table => $table, |
|
1620 |
- where => \%where, |
|
1621 |
- append => $append, |
|
1622 |
- filter => \@filter, |
|
1623 |
- query => 1); |
|
1624 |
- |
|
1625 |
-Execute delete statement. |
|
1626 |
-C<delete> method have C<table>, C<where>, C<append>, and C<filter> arguments. |
|
1627 |
-C<table> is a table name. |
|
1628 |
-C<where> is where clause. this must be hash reference. |
|
1629 |
-C<append> is a string added at the end of the SQL statement. |
|
1630 |
-C<filter> is filters when parameter binding is executed. |
|
1631 |
-C<query> is if you don't execute sql and get L<DBIx::Custom::Query> object as return value. |
|
1632 |
-default to 0. This is EXPERIMENTAL. |
|
1633 |
-Return value of C<delete()> is the count of affected rows. |
|
1626 |
+ $dbi->delete(table => 'book', where => {title => 'Perl'}); |
|
1627 |
+ |
|
1628 |
+Delete statement. |
|
1629 |
+ |
|
1630 |
+The following opitons are currently available. |
|
1631 |
+ |
|
1632 |
+=item C<table> |
|
1633 |
+ |
|
1634 |
+Table name. |
|
1635 |
+ |
|
1636 |
+ $dbi->delete(table => 'book'); |
|
1637 |
+ |
|
1638 |
+=item C<where> |
|
1639 |
+ |
|
1640 |
+Where clause. This is hash reference or L<DBIx::Custom::Where> object. |
|
1641 |
+ |
|
1642 |
+ # Hash reference |
|
1643 |
+ $dbi->delete(where => {title => 'Perl'}); |
|
1644 |
+ |
|
1645 |
+ # DBIx::Custom::Where object |
|
1646 |
+ my $where = $dbi->where( |
|
1647 |
+ clause => ['and', '{= author}', '{like title}'], |
|
1648 |
+ param => {author => 'Ken', title => '%Perl%'} |
|
1649 |
+ ); |
|
1650 |
+ $dbi->delete(where => $where); |
|
1651 |
+ |
|
1652 |
+=item C<append> |
|
1653 |
+ |
|
1654 |
+Append statement to last of SQL. This is string. |
|
1655 |
+ |
|
1656 |
+ $dbi->delete(append => 'order by title'); |
|
1657 |
+ |
|
1658 |
+=item C<filter> |
|
1659 |
+ |
|
1660 |
+Filter, executed before data is send to database. This is array reference. |
|
1661 |
+Filter value is code reference or |
|
1662 |
+filter name registerd by C<register_filter()>. |
|
1663 |
+ |
|
1664 |
+ # Basic |
|
1665 |
+ $dbi->delete( |
|
1666 |
+ filter => [ |
|
1667 |
+ title => sub { uc $_[0] } |
|
1668 |
+ author => sub { uc $_[0] } |
|
1669 |
+ ] |
|
1670 |
+ ); |
|
1671 |
+ |
|
1672 |
+ # At once |
|
1673 |
+ $dbi->delete( |
|
1674 |
+ filter => [ |
|
1675 |
+ [qw/title author/] => sub { uc $_[0] } |
|
1676 |
+ ] |
|
1677 |
+ ); |
|
1678 |
+ |
|
1679 |
+ # Filter name |
|
1680 |
+ $dbi->delete( |
|
1681 |
+ filter => [ |
|
1682 |
+ title => 'upper_case', |
|
1683 |
+ author => 'upper_case' |
|
1684 |
+ ] |
|
1685 |
+ ); |
|
1686 |
+ |
|
1687 |
+These filters are added to the C<out> filters, set by C<apply_filter()>. |
|
1688 |
+ |
|
1689 |
+=item C<query EXPERIMENTAL> |
|
1690 |
+ |
|
1691 |
+Get L<DBIx::Custom::Query> object instead of executing SQL. |
|
1692 |
+This is true or false value. |
|
1693 |
+ |
|
1694 |
+ my $query = $dbi->delete(query => 1); |
|
1695 |
+ |
|
1696 |
+You can check SQL. |
|
1697 |
+ |
|
1698 |
+ my $sql = $query->sql; |
|
1634 | 1699 |
|
1635 | 1700 |
=head2 C<delete_all> |
1636 | 1701 |
|
1637 | 1702 |
$dbi->delete_all(table => $table); |
1638 | 1703 |
|
1639 |
-Execute delete statement to delete all rows. |
|
1640 |
-Arguments is same as C<delete> method, |
|
1641 |
-except that C<delete_all> don't have C<where> argument. |
|
1642 |
-Return value of C<delete_all()> is the count of affected rows. |
|
1704 |
+Delete statement to delete all rows. |
|
1705 |
+Options is same as C<delete()>. |
|
1643 | 1706 |
|
1644 |
-=head3 C<delete_at() EXPERIMENTAL> |
|
1707 |
+=head2 C<delete_at() EXPERIMENTAL> |
|
1645 | 1708 |
|
1646 |
-To delete row by using primary key, use C<delete_at()> |
|
1709 |
+Delete statement, using primary key. |
|
1647 | 1710 |
|
1648 | 1711 |
$dbi->delete_at( |
1649 | 1712 |
table => 'book', |
1650 |
- primary_key => ['id'], |
|
1651 |
- where => ['123'] |
|
1713 |
+ primary_key => 'id', |
|
1714 |
+ where => '5' |
|
1652 | 1715 |
); |
1653 | 1716 |
|
1654 |
-In this example, row which id column is 123 is deleted. |
|
1655 |
-NOTE that you must pass array reference as C<where>. |
|
1717 |
+This method is same as C<delete()> exept that |
|
1718 |
+C<primary_key> is specified and C<where> is constant value or array refrence. |
|
1719 |
+all option of C<delete()> is available. |
|
1656 | 1720 |
|
1657 |
-You can also write arguments like this. |
|
1721 |
+=head2 C<primary_key> |
|
1658 | 1722 |
|
1659 |
- $dbi->delete_at( |
|
1660 |
- table => 'book', |
|
1661 |
- primary_key => ['id'], |
|
1662 |
- param => {id => '123'} |
|
1663 |
- ); |
|
1723 |
+Primary key. This is constant value or array reference. |
|
1724 |
+ |
|
1725 |
+ # Constant value |
|
1726 |
+ $dbi->delete(primary_key => 'id'); |
|
1727 |
+ |
|
1728 |
+ # Array reference |
|
1729 |
+ $dbi->delete(primary_key => ['id1', 'id2' ]); |
|
1730 |
+ |
|
1731 |
+This is used to create where clause. |
|
1732 |
+ |
|
1733 |
+=head2 C<where> |
|
1734 |
+ |
|
1735 |
+Where clause, created from primary key information. |
|
1736 |
+This is constant value or array reference. |
|
1737 |
+ |
|
1738 |
+ # Constant value |
|
1739 |
+ $dbi->delete(where => 5); |
|
1740 |
+ |
|
1741 |
+ # Array reference |
|
1742 |
+ $dbi->delete(where => [3, 5]); |
|
1743 |
+ |
|
1744 |
+In first examle, the following SQL is created. |
|
1745 |
+ |
|
1746 |
+ delete from book where id = ?; |
|
1747 |
+ |
|
1748 |
+Place holder is set to 5. |
|
1664 | 1749 |
|
1665 | 1750 |
=head2 C<insert> |
1666 | 1751 |
|
1667 |
- $dbi->insert(table => $table, |
|
1668 |
- param => \%param, |
|
1669 |
- append => $append, |
|
1670 |
- filter => \@filter, |
|
1671 |
- query => 1); |
|
1752 |
+ $dbi->insert( |
|
1753 |
+ table => 'book', |
|
1754 |
+ param => {title => 'Perl', author => 'Ken'} |
|
1755 |
+ ); |
|
1756 |
+ |
|
1757 |
+Insert statement. |
|
1758 |
+ |
|
1759 |
+The following opitons are currently available. |
|
1760 |
+ |
|
1761 |
+=item C<table> |
|
1762 |
+ |
|
1763 |
+Table name. |
|
1764 |
+ |
|
1765 |
+ $dbi->insert(table => 'book'); |
|
1766 |
+ |
|
1767 |
+=item C<param> |
|
1768 |
+ |
|
1769 |
+=item C<param> |
|
1770 |
+ |
|
1771 |
+Insert data. This is hash reference. |
|
1772 |
+ |
|
1773 |
+ $dbi->insert(param => {title => 'Perl'}); |
|
1774 |
+ |
|
1775 |
+=item C<append> |
|
1776 |
+ |
|
1777 |
+Append statement to last of SQL. This is string. |
|
1778 |
+ |
|
1779 |
+ $dbi->insert(append => 'order by title'); |
|
1780 |
+ |
|
1781 |
+=item C<filter> |
|
1782 |
+ |
|
1783 |
+Filter, executed before data is send to database. This is array reference. |
|
1784 |
+Filter value is code reference or |
|
1785 |
+filter name registerd by C<register_filter()>. |
|
1786 |
+ |
|
1787 |
+ # Basic |
|
1788 |
+ $dbi->insert( |
|
1789 |
+ filter => [ |
|
1790 |
+ title => sub { uc $_[0] } |
|
1791 |
+ author => sub { uc $_[0] } |
|
1792 |
+ ] |
|
1793 |
+ ); |
|
1794 |
+ |
|
1795 |
+ # At once |
|
1796 |
+ $dbi->insert( |
|
1797 |
+ filter => [ |
|
1798 |
+ [qw/title author/] => sub { uc $_[0] } |
|
1799 |
+ ] |
|
1800 |
+ ); |
|
1801 |
+ |
|
1802 |
+ # Filter name |
|
1803 |
+ $dbi->insert( |
|
1804 |
+ filter => [ |
|
1805 |
+ title => 'upper_case', |
|
1806 |
+ author => 'upper_case' |
|
1807 |
+ ] |
|
1808 |
+ ); |
|
1809 |
+ |
|
1810 |
+These filters are added to the C<out> filters, set by C<apply_filter()>. |
|
1811 |
+ |
|
1812 |
+=item C<query EXPERIMENTAL> |
|
1813 |
+ |
|
1814 |
+Get L<DBIx::Custom::Query> object instead of executing SQL. |
|
1815 |
+This is true or false value. |
|
1816 |
+ |
|
1817 |
+ my $query = $dbi->insert(query => 1); |
|
1672 | 1818 |
|
1673 |
-Execute insert statement. |
|
1674 |
-C<insert> method have C<table>, C<param>, C<append> |
|
1675 |
-and C<filter> arguments. |
|
1676 |
-C<table> is a table name. |
|
1677 |
-C<param> is the pairs of column name value. this must be hash reference. |
|
1678 |
-C<append> is a string added at the end of the SQL statement. |
|
1679 |
-C<filter> is filters when parameter binding is executed. |
|
1680 |
-C<query> is if you don't execute sql and get L<DBIx::Custom::Query> object as return value. |
|
1681 |
-default to 0. This is EXPERIMENTAL. |
|
1682 |
-This is overwrites C<default_bind_filter>. |
|
1683 |
-Return value of C<insert()> is the count of affected rows. |
|
1819 |
+You can check SQL. |
|
1684 | 1820 |
|
1685 |
-=head3 C<insert_at() EXPERIMENTAL> |
|
1821 |
+ my $sql = $query->sql; |
|
1822 |
+ |
|
1823 |
+=head2 C<insert_at() EXPERIMENTAL> |
|
1686 | 1824 |
|
1687 |
-To insert row by using primary key, use C<insert_at()> |
|
1825 |
+Insert statement, using primary key. |
|
1688 | 1826 |
|
1689 | 1827 |
$dbi->insert_at( |
1690 | 1828 |
table => 'book', |
1691 |
- primary_key => ['id'], |
|
1692 |
- where => ['123'], |
|
1693 |
- param => {name => 'Ken'} |
|
1829 |
+ primary_key => 'id', |
|
1830 |
+ where => '5', |
|
1831 |
+ param => {title => 'Perl'} |
|
1694 | 1832 |
); |
1695 | 1833 |
|
1696 |
-In this example, row which id column is 123 is inserted. |
|
1697 |
-NOTE that you must pass array reference as C<where>. |
|
1698 |
-If C<param> contains primary key, |
|
1699 |
-the key and value is delete from C<param>. |
|
1834 |
+This method is same as C<insert()> exept that |
|
1835 |
+C<primary_key> is specified and C<where> is constant value or array refrence. |
|
1836 |
+all option of C<insert()> is available. |
|
1837 |
+ |
|
1838 |
+=head2 C<primary_key> |
|
1839 |
+ |
|
1840 |
+Primary key. This is constant value or array reference. |
|
1841 |
+ |
|
1842 |
+ # Constant value |
|
1843 |
+ $dbi->insert(primary_key => 'id'); |
|
1844 |
+ |
|
1845 |
+ # Array reference |
|
1846 |
+ $dbi->insert(primary_key => ['id1', 'id2' ]); |
|
1847 |
+ |
|
1848 |
+This is used to create parts of insert data. |
|
1849 |
+ |
|
1850 |
+=head2 C<where> |
|
1851 |
+ |
|
1852 |
+Parts of Insert data, create from primary key information. |
|
1853 |
+This is constant value or array reference. |
|
1854 |
+ |
|
1855 |
+ # Constant value |
|
1856 |
+ $dbi->insert(where => 5); |
|
1857 |
+ |
|
1858 |
+ # Array reference |
|
1859 |
+ $dbi->insert(where => [3, 5]); |
|
1860 |
+ |
|
1861 |
+In first examle, the following SQL is created. |
|
1862 |
+ |
|
1863 |
+ insert into book (id, title) values (?, ?); |
|
1864 |
+ |
|
1865 |
+Place holders are set to 5 and 'Perl'. |
|
1700 | 1866 |
|
1701 | 1867 |
=head2 C<insert_param EXPERIMENTAL> |
1702 | 1868 |
|
... | ... |
@@ -1944,14 +2110,14 @@ In above select, the following SQL is created. |
1944 | 2110 |
|
1945 | 2111 |
=item C<append> |
1946 | 2112 |
|
1947 |
-Appended statement to last of SQL. This is string. |
|
2113 |
+Append statement to last of SQL. This is string. |
|
1948 | 2114 |
|
1949 | 2115 |
$dbi->select(append => 'order by title'); |
1950 | 2116 |
|
1951 | 2117 |
=item C<filter> |
1952 | 2118 |
|
1953 |
-Filter, executed before data is send to database. This is array reference |
|
1954 |
-and filter value is code reference or |
|
2119 |
+Filter, executed before data is send to database. This is array reference. |
|
2120 |
+Filter value is code reference or |
|
1955 | 2121 |
filter name registerd by C<register_filter()>. |
1956 | 2122 |
|
1957 | 2123 |
# Basic |
... | ... |
@@ -1977,22 +2143,22 @@ filter name registerd by C<register_filter()>. |
1977 | 2143 |
] |
1978 | 2144 |
); |
1979 | 2145 |
|
1980 |
-These filters are added to the C<out> filters set by C<apply_filter()>. |
|
2146 |
+These filters are added to the C<out> filters, set by C<apply_filter()>. |
|
1981 | 2147 |
|
1982 | 2148 |
=item C<query EXPERIMENTAL> |
1983 | 2149 |
|
1984 | 2150 |
Get L<DBIx::Custom::Query> object instead of executing SQL. |
1985 | 2151 |
This is true or false value. |
1986 | 2152 |
|
1987 |
- my $query = $dbi->select(query => 1, ...); |
|
2153 |
+ my $query = $dbi->select(query => 1); |
|
1988 | 2154 |
|
1989 |
-You can check executing SQL by this object. |
|
2155 |
+You can check SQL. |
|
1990 | 2156 |
|
1991 | 2157 |
my $sql = $query->sql; |
1992 | 2158 |
|
1993 | 2159 |
=back |
1994 | 2160 |
|
1995 |
-=head3 C<select_at() EXPERIMENTAL> |
|
2161 |
+=head2 C<select_at() EXPERIMENTAL> |
|
1996 | 2162 |
|
1997 | 2163 |
Select statement, using primary key. |
1998 | 2164 |
|
... | ... |
@@ -2002,8 +2168,8 @@ Select statement, using primary key. |
2002 | 2168 |
where => '5' |
2003 | 2169 |
); |
2004 | 2170 |
|
2005 |
-This method is same as select method exept that |
|
2006 |
-primary_key is specified and C<where> is array reference. |
|
2171 |
+This method is same as C<select()> exept that |
|
2172 |
+C<primary_key> is specified and C<where> is constant value or array refrence. |
|
2007 | 2173 |
all option of C<select()> is available. |
2008 | 2174 |
|
2009 | 2175 |
=head2 C<primary_key> |
... | ... |
@@ -2016,9 +2182,11 @@ Primary key. This is constant value or array reference. |
2016 | 2182 |
# Array reference |
2017 | 2183 |
$dbi->select(primary_key => ['id1', 'id2' ]); |
2018 | 2184 |
|
2185 |
+This is used to create where clause. |
|
2186 |
+ |
|
2019 | 2187 |
=head2 C<where> |
2020 | 2188 |
|
2021 |
-Where clause, created by primary key infromation. |
|
2189 |
+Where clause, created from primary key information. |
|
2022 | 2190 |
This is constant value or array reference. |
2023 | 2191 |
|
2024 | 2192 |
# Constant value |
... | ... |
@@ -2035,33 +2203,78 @@ Place holder is set to 5. |
2035 | 2203 |
|
2036 | 2204 |
=head2 C<update> |
2037 | 2205 |
|
2038 |
- $dbi->update(table => $table, |
|
2039 |
- param => \%params, |
|
2040 |
- where => \%where, |
|
2041 |
- append => $append, |
|
2042 |
- filter => \@filter, |
|
2043 |
- query => 1) |
|
2044 |
- |
|
2045 |
-Execute update statement. |
|
2046 |
-C<update> method have C<table>, C<param>, C<where>, C<append> |
|
2047 |
-and C<filter> arguments. |
|
2048 |
-C<table> is a table name. |
|
2049 |
-C<param> is column-value pairs. this must be hash reference. |
|
2050 |
-C<where> is where clause. this must be hash reference. |
|
2051 |
-C<append> is a string added at the end of the SQL statement. |
|
2052 |
-C<filter> is filters when parameter binding is executed. |
|
2053 |
-C<query> is if you don't execute sql and get L<DBIx::Custom::Query> object as return value. |
|
2054 |
-default to 0. This is EXPERIMENTAL. |
|
2055 |
-This is overwrites C<default_bind_filter>. |
|
2056 |
-Return value of C<update()> is the count of affected rows. |
|
2206 |
+ $dbi->update( |
|
2207 |
+ table => 'book', |
|
2208 |
+ param => {title => 'Perl'}, |
|
2209 |
+ where => {id => 4} |
|
2210 |
+ ); |
|
2057 | 2211 |
|
2058 |
-=head2 C<update_param EXPERIMENTAL> |
|
2212 |
+Update statement. |
|
2059 | 2213 |
|
2060 |
- my $update_param = $dbi->update_param({title => 'a', age => 2}); |
|
2214 |
+The following opitons are currently available. |
|
2061 | 2215 |
|
2062 |
-Create update parameter tag. |
|
2216 |
+=over 4 |
|
2217 |
+ |
|
2218 |
+Table name. |
|
2219 |
+ |
|
2220 |
+ $dbi->update(table => 'book'); |
|
2221 |
+ |
|
2222 |
+=item C<param> |
|
2223 |
+ |
|
2224 |
+Update data. This is hash reference. |
|
2225 |
+ |
|
2226 |
+ $dbi->update(param => {title => 'Perl'}); |
|
2227 |
+ |
|
2228 |
+=item C<where> |
|
2229 |
+ |
|
2230 |
+Where clause. This is hash reference or L<DBIx::Custom::Where> object. |
|
2231 |
+ |
|
2232 |
+ # Hash reference |
|
2233 |
+ $dbi->update(where => {author => 'Ken', 'title' => 'Perl'}); |
|
2234 |
+ |
|
2235 |
+ # DBIx::Custom::Where object |
|
2236 |
+ my $where = $dbi->where( |
|
2237 |
+ clause => ['and', '{= author}', '{like title}'], |
|
2238 |
+ param => {author => 'Ken', title => '%Perl%'} |
|
2239 |
+ ); |
|
2240 |
+ $dbi->update(where => $where); |
|
2241 |
+ |
|
2242 |
+=item C<append> |
|
2243 |
+ |
|
2244 |
+Append statement to last of SQL. This is string. |
|
2245 |
+ |
|
2246 |
+ $dbi->update(append => 'order by title'); |
|
2247 |
+ |
|
2248 |
+=item C<filter> |
|
2249 |
+ |
|
2250 |
+Filter, executed before data is send to database. This is array reference. |
|
2251 |
+Filter value is code reference or |
|
2252 |
+filter name registerd by C<register_filter()>. |
|
2253 |
+ |
|
2254 |
+ # Basic |
|
2255 |
+ $dbi->update( |
|
2256 |
+ filter => [ |
|
2257 |
+ title => sub { uc $_[0] } |
|
2258 |
+ author => sub { uc $_[0] } |
|
2259 |
+ ] |
|
2260 |
+ ); |
|
2261 |
+ |
|
2262 |
+ # At once |
|
2263 |
+ $dbi->update( |
|
2264 |
+ filter => [ |
|
2265 |
+ [qw/title author/] => sub { uc $_[0] } |
|
2266 |
+ ] |
|
2267 |
+ ); |
|
2268 |
+ |
|
2269 |
+ # Filter name |
|
2270 |
+ $dbi->update( |
|
2271 |
+ filter => [ |
|
2272 |
+ title => 'upper_case', |
|
2273 |
+ author => 'upper_case' |
|
2274 |
+ ] |
|
2275 |
+ ); |
|
2063 | 2276 |
|
2064 |
- {title => 'a', age => 2} -> {update_param title age} |
|
2277 |
+These filters are added to the C<out> filters, set by C<apply_filter()>. |
|
2065 | 2278 |
|
2066 | 2279 |
=head2 C<model EXPERIMENTAL> |
2067 | 2280 |
|
... | ... |
@@ -2074,40 +2287,75 @@ Create update parameter tag. |
2074 | 2287 |
|
2075 | 2288 |
Set and get a L<DBIx::Custom::Model> object, |
2076 | 2289 |
|
2077 |
-=head2 C<setup_model EXPERIMENTAL> |
|
2290 |
+=item C<query EXPERIMENTAL> |
|
2078 | 2291 |
|
2079 |
- $dbi->setup_model; |
|
2292 |
+Get L<DBIx::Custom::Query> object instead of executing SQL. |
|
2293 |
+This is true or false value. |
|
2080 | 2294 |
|
2081 |
-Setup all model objects. |
|
2082 |
-C<columns> and C<primary_key> is automatically set. |
|
2295 |
+ my $query = $dbi->update(query => 1); |
|
2296 |
+ |
|
2297 |
+You can check SQL. |
|
2298 |
+ |
|
2299 |
+ my $sql = $query->sql; |
|
2083 | 2300 |
|
2084 | 2301 |
=head2 C<update_all> |
2085 | 2302 |
|
2086 |
- $dbi->update_all(table => $table, |
|
2087 |
- param => \%params, |
|
2088 |
- filter => \@filter, |
|
2089 |
- append => $append); |
|
2303 |
+ $dbi->update_all(table => 'book', param => {title => 'Perl'}); |
|
2090 | 2304 |
|
2091 |
-Execute update statement to update all rows. |
|
2092 |
-Arguments is same as C<update> method, |
|
2093 |
-except that C<update_all> don't have C<where> argument. |
|
2094 |
-Return value of C<update_all()> is the count of affected rows. |
|
2305 |
+Update statement to update all rows. |
|
2306 |
+Options is same as C<update()>. |
|
2095 | 2307 |
|
2096 |
-=head3 C<update_at() EXPERIMENTAL> |
|
2308 |
+=head2 C<update_at() EXPERIMENTAL> |
|
2097 | 2309 |
|
2098 |
-To update row by using primary key, use C<update_at()> |
|
2310 |
+Update statement, using primary key. |
|
2099 | 2311 |
|
2100 | 2312 |
$dbi->update_at( |
2101 | 2313 |
table => 'book', |
2102 |
- primary_key => ['id'], |
|
2103 |
- where => ['123'], |
|
2104 |
- param => {name => 'Ken'} |
|
2314 |
+ primary_key => 'id', |
|
2315 |
+ where => '5', |
|
2316 |
+ param => {title => 'Perl'} |
|
2105 | 2317 |
); |
2106 | 2318 |
|
2107 |
-In this example, row which id column is 123 is updated. |
|
2108 |
-NOTE that you must pass array reference as C<where>. |
|
2109 |
-If C<param> contains primary key, |
|
2110 |
-the key and value is delete from C<param>. |
|
2319 |
+This method is same as C<update()> exept that |
|
2320 |
+C<primary_key> is specified and C<where> is constant value or array refrence. |
|
2321 |
+all option of C<update()> is available. |
|
2322 |
+ |
|
2323 |
+=head2 C<primary_key> |
|
2324 |
+ |
|
2325 |
+Primary key. This is constant value or array reference. |
|
2326 |
+ |
|
2327 |
+ # Constant value |
|
2328 |
+ $dbi->update(primary_key => 'id'); |
|
2329 |
+ |
|
2330 |
+ # Array reference |
|
2331 |
+ $dbi->update(primary_key => ['id1', 'id2' ]); |
|
2332 |
+ |
|
2333 |
+This is used to create where clause. |
|
2334 |
+ |
|
2335 |
+=head2 C<where> |
|
2336 |
+ |
|
2337 |
+Where clause, created from primary key information. |
|
2338 |
+This is constant value or array reference. |
|
2339 |
+ |
|
2340 |
+ # Constant value |
|
2341 |
+ $dbi->update(where => 5); |
|
2342 |
+ |
|
2343 |
+ # Array reference |
|
2344 |
+ $dbi->update(where => [3, 5]); |
|
2345 |
+ |
|
2346 |
+In first examle, the following SQL is created. |
|
2347 |
+ |
|
2348 |
+ update book set title = ? where id = ? |
|
2349 |
+ |
|
2350 |
+Place holders are set to 'Perl' and 5. |
|
2351 |
+ |
|
2352 |
+=head2 C<update_param EXPERIMENTAL> |
|
2353 |
+ |
|
2354 |
+ my $update_param = $dbi->update_param({title => 'a', age => 2}); |
|
2355 |
+ |
|
2356 |
+Create update parameter tag. |
|
2357 |
+ |
|
2358 |
+ {update_param title age} |
|
2111 | 2359 |
|
2112 | 2360 |
=head2 C<where EXPERIMENTAL> |
2113 | 2361 |
|
... | ... |
@@ -2118,12 +2366,12 @@ the key and value is delete from C<param>. |
2118 | 2366 |
|
2119 | 2367 |
Create a new L<DBIx::Custom::Where> object. |
2120 | 2368 |
|
2121 |
-=head2 C<cache_method> |
|
2369 |
+=head2 C<setup_model EXPERIMENTAL> |
|
2122 | 2370 |
|
2123 |
- $dbi = $dbi->cache_method(\&cache_method); |
|
2124 |
- $cache_method = $dbi->cache_method |
|
2371 |
+ $dbi->setup_model; |
|
2125 | 2372 |
|
2126 |
-Method to set and get caches. |
|
2373 |
+Setup all model objects. |
|
2374 |
+C<columns> and C<primary_key> is automatically set. |
|
2127 | 2375 |
|
2128 | 2376 |
=head1 Tags |
2129 | 2377 |
|