Location: PHPKode > projects > Simple Web Account Manager > swam-1.0beta2/phpdoc/__filesource/fsource_swam__databaseSwamSqliteDatabase.class.inc.html
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<!-- template designed by Marco Von Ballmoos -->
			<title>File Source for SwamSqliteDatabase.class.inc</title>
			<link rel="stylesheet" href="../media/stylesheet.css" />
			<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
		</head>
		<body>
						<h1>Source for file SwamSqliteDatabase.class.inc</h1>
<p>Documentation is available at <a href="../swam/_database---SwamSqliteDatabase.class.inc.html">SwamSqliteDatabase.class.inc</a></p>
<div class="src-code">
<div class="src-code"><ol><li><div class="src-line"><a name="a1"></a><span class="src-php">&lt;?php</span></div></li>
<li><div class="src-line"><a name="a2"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a3"></a><span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a4"></a><span class="src-comm">*&nbsp;SWAM&nbsp;(Simple&nbsp;Web&nbsp;Account&nbsp;Manager)&nbsp;is&nbsp;a&nbsp;personal&nbsp;finance&nbsp;manager</span></div></li>
<li><div class="src-line"><a name="a5"></a><span class="src-comm">*&nbsp;written&nbsp;in&nbsp;PHP.</span></div></li>
<li><div class="src-line"><a name="a6"></a><span class="src-comm">*&nbsp;Copyright&nbsp;(C)&nbsp;2004-2009&nbsp;Mathieu&nbsp;Peltier.</span></div></li>
<li><div class="src-line"><a name="a7"></a><span class="src-comm">*&nbsp;Contact:&nbsp;mpeltier&nbsp;at&nbsp;users.sourceforge.net</span></div></li>
<li><div class="src-line"><a name="a8"></a><span class="src-comm">*</span></div></li>
<li><div class="src-line"><a name="a9"></a><span class="src-comm">*&nbsp;This&nbsp;program&nbsp;is&nbsp;free&nbsp;software:&nbsp;you&nbsp;can&nbsp;redistribute&nbsp;it&nbsp;and/or&nbsp;modify</span></div></li>
<li><div class="src-line"><a name="a10"></a><span class="src-comm">*&nbsp;it&nbsp;under&nbsp;the&nbsp;terms&nbsp;of&nbsp;the&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License&nbsp;as&nbsp;published&nbsp;by</span></div></li>
<li><div class="src-line"><a name="a11"></a><span class="src-comm">*&nbsp;the&nbsp;Free&nbsp;Software&nbsp;Foundation,&nbsp;either&nbsp;version&nbsp;3&nbsp;of&nbsp;the&nbsp;License,&nbsp;or</span></div></li>
<li><div class="src-line"><a name="a12"></a><span class="src-comm">*&nbsp;(at&nbsp;your&nbsp;option)&nbsp;any&nbsp;later&nbsp;version.</span></div></li>
<li><div class="src-line"><a name="a13"></a><span class="src-comm">*</span></div></li>
<li><div class="src-line"><a name="a14"></a><span class="src-comm">*&nbsp;This&nbsp;program&nbsp;is&nbsp;distributed&nbsp;in&nbsp;the&nbsp;hope&nbsp;that&nbsp;it&nbsp;will&nbsp;be&nbsp;useful,&nbsp;but</span></div></li>
<li><div class="src-line"><a name="a15"></a><span class="src-comm">*&nbsp;WITHOUT&nbsp;ANY&nbsp;WARRANTY;&nbsp;without&nbsp;even&nbsp;the&nbsp;implied&nbsp;warranty&nbsp;of</span></div></li>
<li><div class="src-line"><a name="a16"></a><span class="src-comm">*&nbsp;MERCHANTABILITY&nbsp;or&nbsp;FITNESS&nbsp;FOR&nbsp;A&nbsp;PARTICULAR&nbsp;PURPOSE.&nbsp;See&nbsp;the&nbsp;GNU</span></div></li>
<li><div class="src-line"><a name="a17"></a><span class="src-comm">*&nbsp;General&nbsp;Public&nbsp;License&nbsp;for&nbsp;more&nbsp;details.</span></div></li>
<li><div class="src-line"><a name="a18"></a><span class="src-comm">*</span></div></li>
<li><div class="src-line"><a name="a19"></a><span class="src-comm">*&nbsp;You&nbsp;should&nbsp;have&nbsp;received&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License</span></div></li>
<li><div class="src-line"><a name="a20"></a><span class="src-comm">*&nbsp;along&nbsp;with&nbsp;this&nbsp;program.&nbsp;If&nbsp;not,&nbsp;see&nbsp;&lt;http://www.gnu.org/licenses/&gt;.</span></div></li>
<li><div class="src-line"><a name="a21"></a><span class="src-comm">*</span></div></li>
<li><div class="src-line"><a name="a22"></a><span class="src-comm">*&nbsp;Initial&nbsp;developer(s):&nbsp;Mathieu&nbsp;Peltier.</span></div></li>
<li><div class="src-line"><a name="a23"></a><span class="src-comm">*&nbsp;Contributor(s):</span></div></li>
<li><div class="src-line"><a name="a24"></a><span class="src-comm">*/</span></div></li>
<li><div class="src-line"><a name="a25"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a26"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a27"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@package</span><span class="src-doc">&nbsp;swam</span></div></li>
<li><div class="src-line"><a name="a28"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@author</span><span class="src-doc">&nbsp;Mathieu&nbsp;Peltier&nbsp;&lt;hide@address.com&gt;</span></div></li>
<li><div class="src-line"><a name="a29"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a30"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a31"></a><span class="src-inc">require_once</span><span class="src-sym">(</span><span class="src-str">'pre.inc'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a32"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a33"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a34"></a><span class="src-doc">&nbsp;*&nbsp;SQLite&nbsp;IDatabase&nbsp;implementation.</span></div></li>
<li><div class="src-line"><a name="a35"></a><span class="src-doc">&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a36"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@package</span><span class="src-doc">&nbsp;swam</span></div></li>
<li><div class="src-line"><a name="a37"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a38"></a><span class="src-key">class&nbsp;</span><a href="../swam/SwamSqliteDatabase.html">SwamSqliteDatabase</a>&nbsp;<span class="src-key">extends&nbsp;</span><a href="../swam/Database.html">Database</a>&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a39"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a40"></a>&nbsp;&nbsp;<span class="src-doc">/**&nbsp;Contains&nbsp;SQL&nbsp;create&nbsp;statement&nbsp;to&nbsp;use&nbsp;for&nbsp;table&nbsp;creation.&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a41"></a>&nbsp;&nbsp;<span class="src-key">private&nbsp;</span><span class="src-var">$tables</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a42"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a43"></a>&nbsp;&nbsp;<span class="src-doc">/**&nbsp;The&nbsp;database&nbsp;file.&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a44"></a>&nbsp;&nbsp;<span class="src-key">private&nbsp;</span><span class="src-var">$database_file</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a45"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a46"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;-----------------------------</span></div></li>
<li><div class="src-line"><a name="a47"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;Constructor</span></div></li>
<li><div class="src-line"><a name="a48"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;-----------------------------</span></div></li>
<li><div class="src-line"><a name="a49"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a50"></a>&nbsp;&nbsp;<span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a51"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*&nbsp;Creates&nbsp;a&nbsp;new&nbsp;SwamSqliteDatabase&nbsp;object.</span></div></li>
<li><div class="src-line"><a name="a52"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a53"></a>&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../swam/SwamSqliteDatabase.html#method__construct">__construct</a><span class="src-sym">(</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a54"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a55"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Sanity&nbsp;checks</span></div></li>
<li><div class="src-line"><a name="a56"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><a href="http://www.php.net/substr">substr</a><span class="src-sym">(</span><span class="src-id"><a href="../swam/_config.inc.html#defineSWAM_DATASOURCE">SWAM_DATASOURCE</a></span><span class="src-sym">,&nbsp;</span><span class="src-num">0</span><span class="src-sym">,&nbsp;</span><span class="src-num">7</span><span class="src-sym">)&nbsp;</span>==&nbsp;<span class="src-str">'sqlite2:'</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a57"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;dsn&nbsp;begins&nbsp;with&nbsp;sqlite2:</span></div></li>
<li><div class="src-line"><a name="a58"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">database_file&nbsp;</span>=&nbsp;<a href="http://www.php.net/substr">substr</a><span class="src-sym">(</span><span class="src-id"><a href="../swam/_config.inc.html#defineSWAM_DATASOURCE">SWAM_DATASOURCE</a></span><span class="src-sym">,&nbsp;</span><span class="src-num">8</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a59"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}&nbsp;</span><span class="src-key">else&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a60"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;dsn&nbsp;begins&nbsp;with&nbsp;sqlite:</span></div></li>
<li><div class="src-line"><a name="a61"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">database_file&nbsp;</span>=&nbsp;<a href="http://www.php.net/substr">substr</a><span class="src-sym">(</span><span class="src-id"><a href="../swam/_config.inc.html#defineSWAM_DATASOURCE">SWAM_DATASOURCE</a></span><span class="src-sym">,&nbsp;</span><span class="src-num">7</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a62"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a63"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><a href="http://www.php.net/is_file">is_file</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">database_file</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a64"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/is_readable">is_readable</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">database_file</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a65"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw&nbsp;<span class="src-key">new&nbsp;</span><span class="src-id"><a href="../swam/DatabaseException.html">DatabaseException</a></span><span class="src-sym">(</span><span class="src-id"><a href="../swam/Utils.html">Utils</a></span><span class="src-sym">::</span><a href="../swam/Utils.html#methodsafe_sprintf">safe_sprintf</a><span class="src-sym">(</span><a href="http://www.php.net/_">_</a><span class="src-sym">(</span><span class="src-str">'Cannot&nbsp;access&nbsp;to&nbsp;the&nbsp;database&nbsp;file&nbsp;%s.'</span><span class="src-sym">)</span><span class="src-sym">,&nbsp;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">database_file</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a66"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a67"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/is_writable">is_writable</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">database_file</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a68"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw&nbsp;<span class="src-key">new&nbsp;</span><span class="src-id"><a href="../swam/DatabaseException.html">DatabaseException</a></span><span class="src-sym">(</span><span class="src-id"><a href="../swam/Utils.html">Utils</a></span><span class="src-sym">::</span><a href="../swam/Utils.html#methodsafe_sprintf">safe_sprintf</a><span class="src-sym">(</span><a href="http://www.php.net/_">_</a><span class="src-sym">(</span><span class="src-str">'Cannot&nbsp;write&nbsp;into&nbsp;the&nbsp;database&nbsp;file&nbsp;%s.'</span><span class="src-sym">)</span><span class="src-sym">,&nbsp;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">database_file</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a69"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a70"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a71"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a72"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">tables&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a73"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a74"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">tables</span><span class="src-sym">[</span><span class="src-str">'t_user'</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-str">'CREATE&nbsp;TABLE&nbsp;t_user(</span></div></li>
<li><div class="src-line"><a name="a75"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;user_id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INTEGER&nbsp;NOT&nbsp;NULL&nbsp;PRIMARY&nbsp;KEY&nbsp;AUTOINCREMENT,</span></div></li>
<li><div class="src-line"><a name="a76"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;first_name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR('&nbsp;</span>.&nbsp;<span class="src-id"><a href="../swam/User.html">User</a></span><span class="src-sym">::</span><span class="src-id">FIRST_NAME_MAX_LENGTH&nbsp;</span>.&nbsp;<span class="src-str">'),</span></div></li>
<li><div class="src-line"><a name="a77"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;last_name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR('&nbsp;</span>.&nbsp;<span class="src-id"><a href="../swam/User.html">User</a></span><span class="src-sym">::</span><span class="src-id">LAST_NAME_MAX_LENGTH&nbsp;</span>.&nbsp;<span class="src-str">'),</span></div></li>
<li><div class="src-line"><a name="a78"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;email&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR('&nbsp;</span>.&nbsp;<span class="src-id"><a href="../swam/User.html">User</a></span><span class="src-sym">::</span><span class="src-id">EMAIL_MAX_LENGTH&nbsp;</span>.&nbsp;<span class="src-str">')&nbsp;NOT&nbsp;NULL,</span></div></li>
<li><div class="src-line"><a name="a79"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;login&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR('&nbsp;</span>.&nbsp;<span class="src-id"><a href="../swam/User.html">User</a></span><span class="src-sym">::</span><span class="src-id">LOGIN_MAX_LENGTH&nbsp;</span>.&nbsp;<span class="src-str">')&nbsp;NOT&nbsp;NULL&nbsp;UNIQUE,</span></div></li>
<li><div class="src-line"><a name="a80"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;crypted_password&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR('&nbsp;</span>.&nbsp;<span class="src-id"><a href="../swam/User.html">User</a></span><span class="src-sym">::</span><span class="src-id">PASSWORD_MAX_LENGTH&nbsp;</span>.&nbsp;<span class="src-str">')&nbsp;NOT&nbsp;NULL,</span></div></li>
<li><div class="src-line"><a name="a81"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;show_closed_accounts&nbsp;&nbsp;DEFAULT&nbsp;0,</span></div></li>
<li><div class="src-line"><a name="a82"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;is_valid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BOOLEAN&nbsp;DEFAULT&nbsp;0,</span></div></li>
<li><div class="src-line"><a name="a83"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;confirmation_hash&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR(50)&nbsp;NOT&nbsp;NULL</span></div></li>
<li><div class="src-line"><a name="a84"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;)'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a85"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a86"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">tables</span><span class="src-sym">[</span><span class="src-str">'t_account'</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-str">'CREATE&nbsp;TABLE&nbsp;t_account(</span></div></li>
<li><div class="src-line"><a name="a87"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;account_id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INTEGER&nbsp;NOT&nbsp;NULL&nbsp;PRIMARY&nbsp;KEY&nbsp;AUTOINCREMENT,</span></div></li>
<li><div class="src-line"><a name="a88"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;owner_id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INTEGER&nbsp;CONSTRAINT&nbsp;fk_owner_id&nbsp;REFERENCES&nbsp;t_user(user_id)&nbsp;ON&nbsp;UPDATE&nbsp;CASCADE&nbsp;ON&nbsp;DELETE&nbsp;CASCADE,</span></div></li>
<li><div class="src-line"><a name="a89"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR('&nbsp;</span>.&nbsp;<span class="src-id"><a href="../swam/Account.html">Account</a></span><span class="src-sym">::</span><span class="src-id">NAME_MAX_LENGTH&nbsp;</span>.&nbsp;<span class="src-str">')&nbsp;NOT&nbsp;NULL,</span></div></li>
<li><div class="src-line"><a name="a90"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;bank_name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR('&nbsp;</span>.&nbsp;<span class="src-id"><a href="../swam/Account.html">Account</a></span><span class="src-sym">::</span><span class="src-id">BANK_NAME_MAX_LENGTH&nbsp;</span>.&nbsp;<span class="src-str">')&nbsp;NOT&nbsp;NULL,</span></div></li>
<li><div class="src-line"><a name="a91"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;currency_code&nbsp;&nbsp;VARCHAR(3)&nbsp;NOT&nbsp;NULL,</span></div></li>
<li><div class="src-line"><a name="a92"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;comment&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR('&nbsp;</span>.&nbsp;<span class="src-id"><a href="../swam/Account.html">Account</a></span><span class="src-sym">::</span><span class="src-id">COMMENT_MAX_LENGTH&nbsp;</span>.&nbsp;<span class="src-str">'),</span></div></li>
<li><div class="src-line"><a name="a93"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;is_opened&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BOOLEAN&nbsp;DEFAULT&nbsp;0,</span></div></li>
<li><div class="src-line"><a name="a94"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;UNIQUE(name,&nbsp;bank_name)</span></div></li>
<li><div class="src-line"><a name="a95"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;)'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a96"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a97"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">tables</span><span class="src-sym">[</span><span class="src-str">'t_transaction'</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-str">'CREATE&nbsp;TABLE&nbsp;t_transaction(</span></div></li>
<li><div class="src-line"><a name="a98"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;transaction_id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INTEGER&nbsp;NOT&nbsp;NULL&nbsp;PRIMARY&nbsp;KEY&nbsp;AUTOINCREMENT,</span></div></li>
<li><div class="src-line"><a name="a99"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR('&nbsp;</span>.&nbsp;<span class="src-id"><a href="../swam/Transaction.html">Transaction</a></span><span class="src-sym">::</span><span class="src-id">NAME_MAX_LENGTH&nbsp;</span>.&nbsp;<span class="src-str">'),</span></div></li>
<li><div class="src-line"><a name="a100"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;account_id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INTEGER&nbsp;NOT&nbsp;NULL&nbsp;CONSTRAINT&nbsp;fk_account_id&nbsp;REFERENCES&nbsp;t_account(account_id)&nbsp;ON&nbsp;UPDATE&nbsp;CASCADE&nbsp;ON&nbsp;DELETE&nbsp;CASCADE,</span></div></li>
<li><div class="src-line"><a name="a101"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;amount&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DECIMAL(10,&nbsp;2),</span></div></li>
<li><div class="src-line"><a name="a102"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;is_debit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BOOLEAN&nbsp;DEFAULT&nbsp;1,</span></div></li>
<li><div class="src-line"><a name="a103"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;mean_of_payment_code&nbsp;&nbsp;VARCHAR(20),</span></div></li>
<li><div class="src-line"><a name="a104"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DATE,</span></div></li>
<li><div class="src-line"><a name="a105"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;comment&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR('&nbsp;</span>.&nbsp;<span class="src-id"><a href="../swam/Transaction.html">Transaction</a></span><span class="src-sym">::</span><span class="src-id">COMMENT_MAX_LENGTH&nbsp;</span>.&nbsp;<span class="src-str">'),</span></div></li>
<li><div class="src-line"><a name="a106"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;is_valid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BOOLEAN&nbsp;DEFAULT&nbsp;0</span></div></li>
<li><div class="src-line"><a name="a107"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;)'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a108"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a109"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">tables</span><span class="src-sym">[</span><span class="src-str">'t_transaction_template'</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-str">'CREATE&nbsp;TABLE&nbsp;t_transaction_template(</span></div></li>
<li><div class="src-line"><a name="a110"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;transaction_template_id&nbsp;&nbsp;INTEGER&nbsp;NOT&nbsp;NULL&nbsp;PRIMARY&nbsp;KEY&nbsp;AUTOINCREMENT,</span></div></li>
<li><div class="src-line"><a name="a111"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR('&nbsp;</span>.&nbsp;<span class="src-id"><a href="../swam/Transaction.html">Transaction</a></span><span class="src-sym">::</span><span class="src-id">NAME_MAX_LENGTH&nbsp;</span>.&nbsp;<span class="src-str">'),</span></div></li>
<li><div class="src-line"><a name="a112"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;account_id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INTEGER&nbsp;NOT&nbsp;NULL&nbsp;CONSTRAINT&nbsp;fk_account_id&nbsp;REFERENCES&nbsp;t_account(account_id)&nbsp;ON&nbsp;UPDATE&nbsp;CASCADE&nbsp;ON&nbsp;DELETE&nbsp;CASCADE,</span></div></li>
<li><div class="src-line"><a name="a113"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;amount&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DECIMAL(10,&nbsp;2),</span></div></li>
<li><div class="src-line"><a name="a114"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;is_debit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BOOLEAN&nbsp;DEFAULT&nbsp;1,</span></div></li>
<li><div class="src-line"><a name="a115"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;mean_of_payment_code&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR(20),</span></div></li>
<li><div class="src-line"><a name="a116"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INTEGER,</span></div></li>
<li><div class="src-line"><a name="a117"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;comment&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR('&nbsp;</span>.&nbsp;<span class="src-id"><a href="../swam/Transaction.html">Transaction</a></span><span class="src-sym">::</span><span class="src-id">COMMENT_MAX_LENGTH&nbsp;</span>.&nbsp;<span class="src-str">'),</span></div></li>
<li><div class="src-line"><a name="a118"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;is_valid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BOOLEAN&nbsp;DEFAULT&nbsp;0</span></div></li>
<li><div class="src-line"><a name="a119"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;)'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a120"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a121"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a122"></a>&nbsp;&nbsp;<span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a123"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*&nbsp;Gets&nbsp;the&nbsp;database&nbsp;file.</span></div></li>
<li><div class="src-line"><a name="a124"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a125"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc-type">string&nbsp;</span></div></li>
<li><div class="src-line"><a name="a126"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a127"></a>&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../swam/SwamSqliteDatabase.html#methodget_database_file">get_database_file</a><span class="src-sym">(</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a128"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">database_file</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a129"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a130"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a131"></a>&nbsp;&nbsp;<span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a132"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*&nbsp;</span><span class="src-doc-coretag">@see</span><span class="src-doc">&nbsp;Database::get_create_statement($table)</span></div></li>
<li><div class="src-line"><a name="a133"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a134"></a>&nbsp;&nbsp;<span class="src-key">protected&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../swam/SwamSqliteDatabase.html#methodget_create_statement">get_create_statement</a><span class="src-sym">(</span><span class="src-var">$table</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a135"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-id"><a href="../swam/Utils.html">Utils</a></span><span class="src-sym">::</span><a href="../swam/Utils.html#methodget_string">get_string</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">tables</span><span class="src-sym">,&nbsp;</span><span class="src-var">$table</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a136"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a137"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a138"></a>&nbsp;&nbsp;<span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a139"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*&nbsp;Makes&nbsp;sure&nbsp;that&nbsp;database&nbsp;file&nbsp;permissions&nbsp;are&nbsp;0600.</span></div></li>
<li><div class="src-line"><a name="a140"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a141"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*&nbsp;TODO:&nbsp;is&nbsp;there&nbsp;any&nbsp;PDO&nbsp;driver&nbsp;option&nbsp;for&nbsp;doing&nbsp;this?&nbsp;Another</span></div></li>
<li><div class="src-line"><a name="a142"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*&nbsp;solution&nbsp;would&nbsp;be&nbsp;to&nbsp;use&nbsp;the&nbsp;SQLiteDatabase&nbsp;constructor&nbsp;while</span></div></li>
<li><div class="src-line"><a name="a143"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*&nbsp;setting&nbsp;the&nbsp;mode&nbsp;parameter,&nbsp;but&nbsp;this&nbsp;feature&nbsp;is&nbsp;currently&nbsp;not</span></div></li>
<li><div class="src-line"><a name="a144"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*&nbsp;working,&nbsp;as&nbsp;reported&nbsp;at:</span></div></li>
<li><div class="src-line"><a name="a145"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*&nbsp;http://www.php.net/manual/en/function.sqlite-open.php</span></div></li>
<li><div class="src-line"><a name="a146"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a147"></a>&nbsp;&nbsp;<span class="src-key">private&nbsp;</span><span class="src-key">function&nbsp;</span><span class="src-id">set_database_file_permissions</span><span class="src-sym">(</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a148"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-sym">@</span><a href="http://www.php.net/chmod">chmod</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">database_file</span><span class="src-sym">,&nbsp;</span><span class="src-num">0600</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a149"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw&nbsp;<span class="src-key">new&nbsp;</span><span class="src-id"><a href="../swam/DatabaseException.html">DatabaseException</a></span><span class="src-sym">(</span><span class="src-id"><a href="../swam/Utils.html">Utils</a></span><span class="src-sym">::</span><a href="../swam/Utils.html#methodsafe_sprintf">safe_sprintf</a><span class="src-sym">(</span><a href="http://www.php.net/_">_</a><span class="src-sym">(</span><span class="src-str">'Failed&nbsp;to&nbsp;set&nbsp;database&nbsp;file&nbsp;permissions&nbsp;%s.'</span><span class="src-sym">)</span><span class="src-sym">,&nbsp;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">database_file</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a150"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a151"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a152"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a153"></a>&nbsp;&nbsp;<span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a154"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*&nbsp;As&nbsp;SQLite&nbsp;does&nbsp;not&nbsp;support&nbsp;foreign&nbsp;keys&nbsp;-&nbsp;the&nbsp;REFERENCES</span></div></li>
<li><div class="src-line"><a name="a155"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*&nbsp;contraints&nbsp;are&nbsp;parsed&nbsp;but&nbsp;ignored&nbsp;-&nbsp;FOREIGN&nbsp;KEY&nbsp;and&nbsp;ON&nbsp;DELETE</span></div></li>
<li><div class="src-line"><a name="a156"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*&nbsp;CASCADE&nbsp;constraints&nbsp;are&nbsp;simulated&nbsp;using&nbsp;triggers&nbsp;obtained&nbsp;from</span></div></li>
<li><div class="src-line"><a name="a157"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*&nbsp;online&nbsp;generator:</span></div></li>
<li><div class="src-line"><a name="a158"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*&nbsp;http://www.rcs-comp.com/site/index.php/view/Utilities-SQLite_foreign_key_trigger_generator.</span></div></li>
<li><div class="src-line"><a name="a159"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*&nbsp;See&nbsp;also:&nbsp;http://www.sqlite.org/cvstrac/wiki?p=ForeignKeyTriggers</span></div></li>
<li><div class="src-line"><a name="a160"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a161"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*&nbsp;</span><span class="src-doc-coretag">@see</span><span class="src-doc">&nbsp;Database::initialize($create_demo_user)</span></div></li>
<li><div class="src-line"><a name="a162"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a163"></a>&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../swam/SwamSqliteDatabase.html#methodinitialize">initialize</a><span class="src-sym">(</span><span class="src-var">$create_demo_user</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a164"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a165"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$dbh&nbsp;</span>=&nbsp;<span class="src-id">parent</span><span class="src-sym">::</span><a href="../swam/Database.html#methodget_connection">get_connection</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a166"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$dbh</span><span class="src-sym">-&gt;</span><span class="src-id">exec</span><span class="src-sym">(</span><a href="http://www.php.net/sprintf">sprintf</a><span class="src-sym">(</span><span class="src-str">&quot;PRAGMA&nbsp;encoding&nbsp;=&nbsp;'%s'&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-id"><a href="../swam/_constants.inc.html#defineSWAM_CHARSET">SWAM_CHARSET</a></span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a167"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a168"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-id">parent</span><span class="src-sym">::</span><a href="../swam/Database.html#methodinitialize">initialize</a><span class="src-sym">(</span><span class="src-var">$create_demo_user</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a169"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a170"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*&nbsp;t_account&nbsp;table&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a171"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a172"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Foreign&nbsp;key&nbsp;preventing&nbsp;insert</span></div></li>
<li><div class="src-line"><a name="a173"></a>&nbsp;&nbsp;&nbsp;&nbsp;try&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a174"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$dbh</span><span class="src-sym">-&gt;</span><span class="src-id">exec</span><span class="src-sym">(</span><span class="src-str">'DROP&nbsp;TRIGGER&nbsp;fki_t_account_owner_id_t_user_user_id'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a175"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}&nbsp;</span>catch&nbsp;<span class="src-sym">(</span><span class="src-id">PDOException&nbsp;</span><span class="src-var">$ignore</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a176"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;TODO:&nbsp;rethrow&nbsp;if&nbsp;exception&nbsp;is&nbsp;not&nbsp;&quot;Trigger&nbsp;not&nbsp;found&quot;</span></div></li>
<li><div class="src-line"><a name="a177"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a178"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$dbh</span><span class="src-sym">-&gt;</span><span class="src-id">exec</span><span class="src-sym">(</span><span class="src-str">&quot;CREATE&nbsp;TRIGGER&nbsp;fki_t_account_owner_id_t_user_user_id</span></div></li>
<li><div class="src-line"><a name="a179"></a><span class="src-str">BEFORE&nbsp;INSERT&nbsp;ON&nbsp;[t_account]</span></div></li>
<li><div class="src-line"><a name="a180"></a><span class="src-str">FOR&nbsp;EACH&nbsp;ROW&nbsp;BEGIN</span></div></li>
<li><div class="src-line"><a name="a181"></a><span class="src-str">&nbsp;&nbsp;SELECT&nbsp;RAISE(ROLLBACK,&nbsp;'insert&nbsp;on&nbsp;table&nbsp;\&quot;t_account\&quot;&nbsp;violates&nbsp;foreign&nbsp;key&nbsp;constraint&nbsp;\&quot;fki_t_account_owner_id_t_user_user_id\&quot;')</span></div></li>
<li><div class="src-line"><a name="a182"></a><span class="src-str">&nbsp;&nbsp;WHERE&nbsp;NEW.owner_id&nbsp;IS&nbsp;NOT&nbsp;NULL&nbsp;AND&nbsp;(SELECT&nbsp;user_id&nbsp;FROM&nbsp;t_user&nbsp;WHERE&nbsp;user_id&nbsp;=&nbsp;NEW.owner_id)&nbsp;IS&nbsp;NULL;</span></div></li>
<li><div class="src-line"><a name="a183"></a><span class="src-str">END;&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a184"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a185"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Foreign&nbsp;key&nbsp;preventing&nbsp;update</span></div></li>
<li><div class="src-line"><a name="a186"></a>&nbsp;&nbsp;&nbsp;&nbsp;try&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a187"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$dbh</span><span class="src-sym">-&gt;</span><span class="src-id">exec</span><span class="src-sym">(</span><span class="src-str">'DROP&nbsp;TRIGGER&nbsp;fku_t_account_owner_id_t_user_user_id'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a188"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}&nbsp;</span>catch&nbsp;<span class="src-sym">(</span><span class="src-id">PDOException&nbsp;</span><span class="src-var">$ignore</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a189"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;TODO:&nbsp;rethrow&nbsp;if&nbsp;exception&nbsp;is&nbsp;not&nbsp;&quot;Trigger&nbsp;not&nbsp;found&quot;</span></div></li>
<li><div class="src-line"><a name="a190"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a191"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$dbh</span><span class="src-sym">-&gt;</span><span class="src-id">exec</span><span class="src-sym">(</span><span class="src-str">&quot;CREATE&nbsp;TRIGGER&nbsp;fku_t_account_owner_id_t_user_user_id</span></div></li>
<li><div class="src-line"><a name="a192"></a><span class="src-str">BEFORE&nbsp;UPDATE&nbsp;ON&nbsp;[t_account]</span></div></li>
<li><div class="src-line"><a name="a193"></a><span class="src-str">FOR&nbsp;EACH&nbsp;ROW&nbsp;BEGIN</span></div></li>
<li><div class="src-line"><a name="a194"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;SELECT&nbsp;RAISE(ROLLBACK,&nbsp;'update&nbsp;on&nbsp;table&nbsp;\&quot;t_account\&quot;&nbsp;violates&nbsp;foreign&nbsp;key&nbsp;constraint&nbsp;\&quot;fku_t_account_owner_id_t_user_user_id\&quot;')</span></div></li>
<li><div class="src-line"><a name="a195"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHERE&nbsp;NEW.owner_id&nbsp;IS&nbsp;NOT&nbsp;NULL&nbsp;AND&nbsp;(SELECT&nbsp;user_id&nbsp;FROM&nbsp;t_user&nbsp;WHERE&nbsp;user_id&nbsp;=&nbsp;NEW.owner_id)&nbsp;IS&nbsp;NULL;</span></div></li>
<li><div class="src-line"><a name="a196"></a><span class="src-str">END;&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a197"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a198"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Cascading&nbsp;delete</span></div></li>
<li><div class="src-line"><a name="a199"></a>&nbsp;&nbsp;&nbsp;&nbsp;try&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a200"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$dbh</span><span class="src-sym">-&gt;</span><span class="src-id">exec</span><span class="src-sym">(</span><span class="src-str">'DROP&nbsp;TRIGGER&nbsp;fkdc_t_account_owner_id_t_user_user_id'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a201"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}&nbsp;</span>catch&nbsp;<span class="src-sym">(</span><span class="src-id">PDOException&nbsp;</span><span class="src-var">$ignore</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a202"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;TODO:&nbsp;rethrow&nbsp;if&nbsp;exception&nbsp;is&nbsp;not&nbsp;&quot;Trigger&nbsp;not&nbsp;found&quot;</span></div></li>
<li><div class="src-line"><a name="a203"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a204"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$dbh</span><span class="src-sym">-&gt;</span><span class="src-id">exec</span><span class="src-sym">(</span><span class="src-str">&quot;CREATE&nbsp;TRIGGER&nbsp;fkdc_t_account_owner_id_t_user_user_id</span></div></li>
<li><div class="src-line"><a name="a205"></a><span class="src-str">BEFORE&nbsp;DELETE&nbsp;ON&nbsp;t_user</span></div></li>
<li><div class="src-line"><a name="a206"></a><span class="src-str">FOR&nbsp;EACH&nbsp;ROW&nbsp;BEGIN</span></div></li>
<li><div class="src-line"><a name="a207"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;DELETE&nbsp;FROM&nbsp;t_account&nbsp;WHERE&nbsp;t_account.owner_id&nbsp;=&nbsp;OLD.user_id;</span></div></li>
<li><div class="src-line"><a name="a208"></a><span class="src-str">END;&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a209"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a210"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-id"><a href="../swam/FileLog.html">FileLog</a></span><span class="src-sym">::</span><a href="../swam/FileLog.html#methodinstance">instance</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">info</span><span class="src-sym">(</span><span class="src-str">&quot;Created&nbsp;triggers&nbsp;for&nbsp;t_account&nbsp;table&nbsp;(sqlitedb)&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a211"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a212"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*&nbsp;t_transaction&nbsp;table&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a213"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a214"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Foreign&nbsp;key&nbsp;preventing&nbsp;insert</span></div></li>
<li><div class="src-line"><a name="a215"></a>&nbsp;&nbsp;&nbsp;&nbsp;try&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a216"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$dbh</span><span class="src-sym">-&gt;</span><span class="src-id">exec</span><span class="src-sym">(</span><span class="src-str">'DROP&nbsp;TRIGGER&nbsp;fki_t_transaction_account_id_t_account_account_id;'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a217"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}&nbsp;</span>catch&nbsp;<span class="src-sym">(</span><span class="src-id">PDOException&nbsp;</span><span class="src-var">$ignore</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a218"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;TODO:&nbsp;rethrow&nbsp;if&nbsp;exception&nbsp;is&nbsp;not&nbsp;&quot;Trigger&nbsp;not&nbsp;found&quot;</span></div></li>
<li><div class="src-line"><a name="a219"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a220"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$dbh</span><span class="src-sym">-&gt;</span><span class="src-id">exec</span><span class="src-sym">(</span><span class="src-str">&quot;CREATE&nbsp;TRIGGER&nbsp;fki_t_transaction_account_id_t_account_account_id</span></div></li>
<li><div class="src-line"><a name="a221"></a><span class="src-str">BEFORE&nbsp;INSERT&nbsp;ON&nbsp;[t_transaction]</span></div></li>
<li><div class="src-line"><a name="a222"></a><span class="src-str">FOR&nbsp;EACH&nbsp;ROW&nbsp;BEGIN</span></div></li>
<li><div class="src-line"><a name="a223"></a><span class="src-str">&nbsp;&nbsp;SELECT&nbsp;RAISE(ROLLBACK,&nbsp;'insert&nbsp;on&nbsp;table&nbsp;\&quot;t_transaction\&quot;&nbsp;violates&nbsp;foreign&nbsp;key&nbsp;constraint&nbsp;\&quot;fki_t_transaction_account_id_t_account_account_id\&quot;')</span></div></li>
<li><div class="src-line"><a name="a224"></a><span class="src-str">&nbsp;&nbsp;WHERE&nbsp;(SELECT&nbsp;account_id&nbsp;FROM&nbsp;t_account&nbsp;WHERE&nbsp;account_id&nbsp;=&nbsp;NEW.account_id)&nbsp;IS&nbsp;NULL;</span></div></li>
<li><div class="src-line"><a name="a225"></a><span class="src-str">END;&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a226"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a227"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Foreign&nbsp;key&nbsp;preventing&nbsp;update</span></div></li>
<li><div class="src-line"><a name="a228"></a>&nbsp;&nbsp;&nbsp;&nbsp;try&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a229"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$dbh</span><span class="src-sym">-&gt;</span><span class="src-id">exec</span><span class="src-sym">(</span><span class="src-str">'DROP&nbsp;TRIGGER&nbsp;fku_t_transaction_account_id_t_account_account_id;'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a230"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}&nbsp;</span>catch&nbsp;<span class="src-sym">(</span><span class="src-id">PDOException&nbsp;</span><span class="src-var">$ignore</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a231"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;TODO:&nbsp;rethrow&nbsp;if&nbsp;exception&nbsp;is&nbsp;not&nbsp;&quot;Trigger&nbsp;not&nbsp;found&quot;</span></div></li>
<li><div class="src-line"><a name="a232"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a233"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$dbh</span><span class="src-sym">-&gt;</span><span class="src-id">exec</span><span class="src-sym">(</span><span class="src-str">&quot;CREATE&nbsp;TRIGGER&nbsp;fku_t_transaction_account_id_t_account_account_id</span></div></li>
<li><div class="src-line"><a name="a234"></a><span class="src-str">BEFORE&nbsp;UPDATE&nbsp;ON&nbsp;[t_transaction]</span></div></li>
<li><div class="src-line"><a name="a235"></a><span class="src-str">FOR&nbsp;EACH&nbsp;ROW&nbsp;BEGIN</span></div></li>
<li><div class="src-line"><a name="a236"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;SELECT&nbsp;RAISE(ROLLBACK,&nbsp;'update&nbsp;on&nbsp;table&nbsp;\&quot;t_transaction\&quot;&nbsp;violates&nbsp;foreign&nbsp;key&nbsp;constraint&nbsp;\&quot;fku_t_transaction_account_id_t_account_account_id\&quot;')</span></div></li>
<li><div class="src-line"><a name="a237"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHERE&nbsp;(SELECT&nbsp;account_id&nbsp;FROM&nbsp;t_account&nbsp;WHERE&nbsp;account_id&nbsp;=&nbsp;NEW.account_id)&nbsp;IS&nbsp;NULL;</span></div></li>
<li><div class="src-line"><a name="a238"></a><span class="src-str">END;&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a239"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a240"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Cascading&nbsp;delete</span></div></li>
<li><div class="src-line"><a name="a241"></a>&nbsp;&nbsp;&nbsp;&nbsp;try&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a242"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$dbh</span><span class="src-sym">-&gt;</span><span class="src-id">exec</span><span class="src-sym">(</span><span class="src-str">'DROP&nbsp;TRIGGER&nbsp;fkdc_t_transaction_account_id_t_account_account_id;'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a243"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}&nbsp;</span>catch&nbsp;<span class="src-sym">(</span><span class="src-id">PDOException&nbsp;</span><span class="src-var">$ignore</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a244"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;TODO:&nbsp;rethrow&nbsp;if&nbsp;exception&nbsp;is&nbsp;not&nbsp;&quot;Trigger&nbsp;not&nbsp;found&quot;</span></div></li>
<li><div class="src-line"><a name="a245"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a246"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$dbh</span><span class="src-sym">-&gt;</span><span class="src-id">exec</span><span class="src-sym">(</span><span class="src-str">'CREATE&nbsp;TRIGGER&nbsp;fkdc_t_transaction_account_id_t_account_account_id</span></div></li>
<li><div class="src-line"><a name="a247"></a><span class="src-str">BEFORE&nbsp;DELETE&nbsp;ON&nbsp;t_account</span></div></li>
<li><div class="src-line"><a name="a248"></a><span class="src-str">FOR&nbsp;EACH&nbsp;ROW&nbsp;BEGIN</span></div></li>
<li><div class="src-line"><a name="a249"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;DELETE&nbsp;FROM&nbsp;t_transaction&nbsp;WHERE&nbsp;t_transaction.account_id&nbsp;=&nbsp;OLD.account_id;</span></div></li>
<li><div class="src-line"><a name="a250"></a><span class="src-str">END;'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a251"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a252"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-id"><a href="../swam/FileLog.html">FileLog</a></span><span class="src-sym">::</span><a href="../swam/FileLog.html#methodinstance">instance</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">info</span><span class="src-sym">(</span><span class="src-str">&quot;Created&nbsp;triggers&nbsp;for&nbsp;t_transaction&nbsp;table&nbsp;(sqlitedb)&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a253"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a254"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*&nbsp;t_transaction_template&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a255"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a256"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Foreign&nbsp;key&nbsp;preventing&nbsp;insert</span></div></li>
<li><div class="src-line"><a name="a257"></a>&nbsp;&nbsp;&nbsp;&nbsp;try&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a258"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$dbh</span><span class="src-sym">-&gt;</span><span class="src-id">exec</span><span class="src-sym">(</span><span class="src-str">'DROP&nbsp;TRIGGER&nbsp;fki_t_transaction_template_account_id_t_account_account_id;'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a259"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}&nbsp;</span>catch&nbsp;<span class="src-sym">(</span><span class="src-id">PDOException&nbsp;</span><span class="src-var">$ignore</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a260"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;TODO:&nbsp;rethrow&nbsp;if&nbsp;exception&nbsp;is&nbsp;not&nbsp;&quot;Trigger&nbsp;not&nbsp;found&quot;</span></div></li>
<li><div class="src-line"><a name="a261"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a262"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$dbh</span><span class="src-sym">-&gt;</span><span class="src-id">exec</span><span class="src-sym">(</span><span class="src-str">&quot;CREATE&nbsp;TRIGGER&nbsp;fki_t_transaction_template_account_id_t_account_account_id</span></div></li>
<li><div class="src-line"><a name="a263"></a><span class="src-str">BEFORE&nbsp;INSERT&nbsp;ON&nbsp;[t_transaction_template]</span></div></li>
<li><div class="src-line"><a name="a264"></a><span class="src-str">FOR&nbsp;EACH&nbsp;ROW&nbsp;BEGIN</span></div></li>
<li><div class="src-line"><a name="a265"></a><span class="src-str">&nbsp;&nbsp;SELECT&nbsp;RAISE(ROLLBACK,&nbsp;'insert&nbsp;on&nbsp;table&nbsp;\&quot;t_transaction_template\&quot;&nbsp;violates&nbsp;foreign&nbsp;key&nbsp;constraint&nbsp;\&quot;fki_t_transaction_template_account_id_t_account_account_id\&quot;')</span></div></li>
<li><div class="src-line"><a name="a266"></a><span class="src-str">&nbsp;&nbsp;WHERE&nbsp;(SELECT&nbsp;account_id&nbsp;FROM&nbsp;t_account&nbsp;WHERE&nbsp;account_id&nbsp;=&nbsp;NEW.account_id)&nbsp;IS&nbsp;NULL;</span></div></li>
<li><div class="src-line"><a name="a267"></a><span class="src-str">END;&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a268"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a269"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Foreign&nbsp;key&nbsp;preventing&nbsp;update</span></div></li>
<li><div class="src-line"><a name="a270"></a>&nbsp;&nbsp;&nbsp;&nbsp;try&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a271"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$dbh</span><span class="src-sym">-&gt;</span><span class="src-id">exec</span><span class="src-sym">(</span><span class="src-str">'DROP&nbsp;TRIGGER&nbsp;fku_t_transaction_template_account_id_t_account_account_id;'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a272"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}&nbsp;</span>catch&nbsp;<span class="src-sym">(</span><span class="src-id">PDOException&nbsp;</span><span class="src-var">$ignore</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a273"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;TODO:&nbsp;rethrow&nbsp;if&nbsp;exception&nbsp;is&nbsp;not&nbsp;&quot;Trigger&nbsp;not&nbsp;found&quot;</span></div></li>
<li><div class="src-line"><a name="a274"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a275"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$dbh</span><span class="src-sym">-&gt;</span><span class="src-id">exec</span><span class="src-sym">(</span><span class="src-str">&quot;CREATE&nbsp;TRIGGER&nbsp;fku_t_transaction_template_account_id_t_account_account_id</span></div></li>
<li><div class="src-line"><a name="a276"></a><span class="src-str">BEFORE&nbsp;UPDATE&nbsp;ON&nbsp;[t_transaction_template]</span></div></li>
<li><div class="src-line"><a name="a277"></a><span class="src-str">FOR&nbsp;EACH&nbsp;ROW&nbsp;BEGIN</span></div></li>
<li><div class="src-line"><a name="a278"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;SELECT&nbsp;RAISE(ROLLBACK,&nbsp;'update&nbsp;on&nbsp;table&nbsp;\&quot;t_transaction_template\&quot;&nbsp;violates&nbsp;foreign&nbsp;key&nbsp;constraint&nbsp;\&quot;fku_t_transaction_template_account_id_t_account_account_id\&quot;')</span></div></li>
<li><div class="src-line"><a name="a279"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHERE&nbsp;(SELECT&nbsp;account_id&nbsp;FROM&nbsp;t_account&nbsp;WHERE&nbsp;account_id&nbsp;=&nbsp;NEW.account_id)&nbsp;IS&nbsp;NULL;</span></div></li>
<li><div class="src-line"><a name="a280"></a><span class="src-str">END;&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a281"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a282"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Cascading&nbsp;delete</span></div></li>
<li><div class="src-line"><a name="a283"></a>&nbsp;&nbsp;&nbsp;&nbsp;try&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a284"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$dbh</span><span class="src-sym">-&gt;</span><span class="src-id">exec</span><span class="src-sym">(</span><span class="src-str">'DROP&nbsp;TRIGGER&nbsp;fkdc_t_transaction_template_account_id_t_account_account_id;'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a285"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}&nbsp;</span>catch&nbsp;<span class="src-sym">(</span><span class="src-id">PDOException&nbsp;</span><span class="src-var">$ignore</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a286"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;TODO:&nbsp;rethrow&nbsp;if&nbsp;exception&nbsp;is&nbsp;not&nbsp;&quot;Trigger&nbsp;not&nbsp;found&quot;</span></div></li>
<li><div class="src-line"><a name="a287"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a288"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$dbh</span><span class="src-sym">-&gt;</span><span class="src-id">exec</span><span class="src-sym">(</span><span class="src-str">'CREATE&nbsp;TRIGGER&nbsp;fkdc_t_transaction_template_account_id_t_account_account_id</span></div></li>
<li><div class="src-line"><a name="a289"></a><span class="src-str">BEFORE&nbsp;DELETE&nbsp;ON&nbsp;t_account</span></div></li>
<li><div class="src-line"><a name="a290"></a><span class="src-str">FOR&nbsp;EACH&nbsp;ROW&nbsp;BEGIN</span></div></li>
<li><div class="src-line"><a name="a291"></a><span class="src-str">&nbsp;&nbsp;&nbsp;&nbsp;DELETE&nbsp;FROM&nbsp;t_transaction_template&nbsp;WHERE&nbsp;t_transaction_template.account_id&nbsp;=&nbsp;OLD.account_id;</span></div></li>
<li><div class="src-line"><a name="a292"></a><span class="src-str">END;'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a293"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a294"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id">set_database_file_permissions</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a295"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a296"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-id"><a href="../swam/FileLog.html">FileLog</a></span><span class="src-sym">::</span><a href="../swam/FileLog.html#methodinstance">instance</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">info</span><span class="src-sym">(</span><span class="src-str">&quot;Created&nbsp;triggers&nbsp;for&nbsp;t_transaction_template&nbsp;table&nbsp;(sqlitedb)&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a297"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a298"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a299"></a>&nbsp;&nbsp;<span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a300"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*&nbsp;</span><span class="src-doc-coretag">@see</span><span class="src-doc">&nbsp;IDatabase::vacuum()</span></div></li>
<li><div class="src-line"><a name="a301"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a302"></a>&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../swam/SwamSqliteDatabase.html#methodvacuum">vacuum</a><span class="src-sym">(</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a303"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$dbh&nbsp;</span>=&nbsp;<span class="src-id"><a href="../swam/Database.html">Database</a></span><span class="src-sym">::</span><a href="../swam/Database.html#methodinstance">instance</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">get_connection</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a304"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$dbh</span><span class="src-sym">-&gt;</span><span class="src-id">exec</span><span class="src-sym">(</span><span class="src-str">'VACUUM;'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a305"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a306"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a307"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a308"></a><span class="src-php">?&gt;</span></div></li>
</ol></div>
</div>
	<p class="notes" id="credit">
		Documentation generated on Thu, 20 Aug 2009 01:04:18 +0200 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.1</a>
	</p>
	</body>
</html>
Return current item: Simple Web Account Manager