Query/apiDocumentation/source/Drivers/Sqlite/Util.php.html
2020-04-17 15:05:37 -04:00

4 lines
35 KiB
HTML

<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><title>phpDox - Source of Util.php</title><link rel="stylesheet" type="text/css" href="../../../css/style.css" media="screen"/><link rel="stylesheet" href="../../../css/source.css"/><meta http-equiv="content-type" content="text/html; charset=utf-8"/></head><body><nav class="topnav"><ul><li><div class="logo"><span>/**</span>phpDox</div></li><li class="separator"><a href="../../../index.html">Overview</a></li><li class="separator"><a href="../../../namespaces.html">Namespaces</a></li><li><a href="../../../interfaces.html">Interfaces</a></li><li><a href="../../../classes.html">Classes</a></li><li class="separator"><a href="../../../source/index.html">Source</a></li></ul></nav><div id="mainstage"><div class="box"><ul class="breadcrumb"><li><a href="../../../index.html">Overview</a></li><li class="separator"><a href="../../../source/index.html">Source</a></li></ul></div><h1>Source of file Util.php</h1><p>
Size: 2,569 Bytes - Last Modified: 2020-04-17T14:56:27-04:00</p><section><h2><small>src/Drivers/Sqlite/</small>Util.php</h2><table class="source"><tr><td class="no"><a class="anker" href="#line1">1</a><a class="anker" href="#line2">2</a><a class="anker" href="#line3">3</a><a class="anker" href="#line4">4</a><a class="anker" href="#line5">5</a><a class="anker" href="#line6">6</a><a class="anker" href="#line7">7</a><a class="anker" href="#line8">8</a><a class="anker" href="#line9">9</a><a class="anker" href="#line10">10</a><a class="anker" href="#line11">11</a><a class="anker" href="#line12">12</a><a class="anker" href="#line13">13</a><a class="anker" href="#line14">14</a><a class="anker" href="#line15">15</a><a class="anker" href="#line16">16</a><a class="anker" href="#line17">17</a><a class="anker" href="#line18">18</a><a class="anker" href="#line19">19</a><a class="anker" href="#line20">20</a><a class="anker" href="#line21">21</a><a class="anker" href="#line22">22</a><a class="anker" href="#line23">23</a><a class="anker" href="#line24">24</a><a class="anker" href="#line25">25</a><a class="anker" href="#line26">26</a><a class="anker" href="#line27">27</a><a class="anker" href="#line28">28</a><a class="anker" href="#line29">29</a><a class="anker" href="#line30">30</a><a class="anker" href="#line31">31</a><a class="anker" href="#line32">32</a><a class="anker" href="#line33">33</a><a class="anker" href="#line34">34</a><a class="anker" href="#line35">35</a><a class="anker" href="#line36">36</a><a class="anker" href="#line37">37</a><a class="anker" href="#line38">38</a><a class="anker" href="#line39">39</a><a class="anker" href="#line40">40</a><a class="anker" href="#line41">41</a><a class="anker" href="#line42">42</a><a class="anker" href="#line43">43</a><a class="anker" href="#line44">44</a><a class="anker" href="#line45">45</a><a class="anker" href="#line46">46</a><a class="anker" href="#line47">47</a><a class="anker" href="#line48">48</a><a class="anker" href="#line49">49</a><a class="anker" href="#line50">50</a><a class="anker" href="#line51">51</a><a class="anker" href="#line52">52</a><a class="anker" href="#line53">53</a><a class="anker" href="#line54">54</a><a class="anker" href="#line55">55</a><a class="anker" href="#line56">56</a><a class="anker" href="#line57">57</a><a class="anker" href="#line58">58</a><a class="anker" href="#line59">59</a><a class="anker" href="#line60">60</a><a class="anker" href="#line61">61</a><a class="anker" href="#line62">62</a><a class="anker" href="#line63">63</a><a class="anker" href="#line64">64</a><a class="anker" href="#line65">65</a><a class="anker" href="#line66">66</a><a class="anker" href="#line67">67</a><a class="anker" href="#line68">68</a><a class="anker" href="#line69">69</a><a class="anker" href="#line70">70</a><a class="anker" href="#line71">71</a><a class="anker" href="#line72">72</a><a class="anker" href="#line73">73</a><a class="anker" href="#line74">74</a><a class="anker" href="#line75">75</a><a class="anker" href="#line76">76</a><a class="anker" href="#line77">77</a><a class="anker" href="#line78">78</a><a class="anker" href="#line79">79</a><a class="anker" href="#line80">80</a><a class="anker" href="#line81">81</a><a class="anker" href="#line82">82</a><a class="anker" href="#line83">83</a><a class="anker" href="#line84">84</a><a class="anker" href="#line85">85</a><a class="anker" href="#line86">86</a><a class="anker" href="#line87">87</a><a class="anker" href="#line88">88</a><a class="anker" href="#line89">89</a><a class="anker" href="#line90">90</a><a class="anker" href="#line91">91</a><a class="anker" href="#line92">92</a><a class="anker" href="#line93">93</a><a class="anker" href="#line94">94</a><a class="anker" href="#line95">95</a><a class="anker" href="#line96">96</a><a class="anker" href="#line97">97</a><a class="anker" href="#line98">98</a><a class="anker" href="#line99">99</a><a class="anker" href="#line100">100</a><a class="anker" href="#line101">101</a><a class="anker" href="#line102">102</a><a class="anker" href="#line103">103</a><a class="anker" href="#line104">104</a><a class="anker" href="#line105">105</a><a class="anker" href="#line106">106</a><a class="anker" href="#line107">107</a><a class="anker" href="#line108">108</a><a class="anker" href="#line109">109</a><a class="anker" href="#line110">110</a><a class="anker" href="#line111">111</a><a class="anker" href="#line112">112</a><a class="anker" href="#line113">113</a><a class="anker" href="#line114">114</a><a class="anker" href="#line115">115</a><a class="anker" href="#line116">116</a><a class="anker" href="#line117">117</a><a class="anker" href="#line118">118</a><a class="anker" href="#line119">119</a><a class="anker" href="#line120">120</a></td><td class="line"><div id="line1"><pre><span class="token T_OPEN_TAG">&lt;?php </span><span class="token T_DECLARE">declare</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_STRING">strict_types</span><span class="token T_PHPDOX_EQUAL">=</span><span class="token T_LNUMBER">1</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line2"><pre><span class="token T_DOC_COMMENT">/**</span></pre></div><div id="line3"><pre><span class="token T_DOC_COMMENT"> * Query</span></pre></div><div id="line4"><pre><span class="token T_DOC_COMMENT"> *</span></pre></div><div id="line5"><pre><span class="token T_DOC_COMMENT"> * SQL Query Builder / Database Abstraction Layer</span></pre></div><div id="line6"><pre><span class="token T_DOC_COMMENT"> *</span></pre></div><div id="line7"><pre><span class="token T_DOC_COMMENT"> * PHP version 7.4</span></pre></div><div id="line8"><pre><span class="token T_DOC_COMMENT"> *</span></pre></div><div id="line9"><pre><span class="token T_DOC_COMMENT"> * @package Query</span></pre></div><div id="line10"><pre><span class="token T_DOC_COMMENT"> * @author Timothy J. Warren &lt;tim@timshomepage.net&gt;</span></pre></div><div id="line11"><pre><span class="token T_DOC_COMMENT"> * @copyright 2012 - 2020 Timothy J. Warren</span></pre></div><div id="line12"><pre><span class="token T_DOC_COMMENT"> * @license http://www.opensource.org/licenses/mit-license.html MIT License</span></pre></div><div id="line13"><pre><span class="token T_DOC_COMMENT"> * @link https://git.timshomepage.net/aviat/Query</span></pre></div><div id="line14"><pre><span class="token T_DOC_COMMENT"> * @version 3.0.0</span></pre></div><div id="line15"><pre><span class="token T_DOC_COMMENT"> */</span></pre></div><div id="line16"><pre><span class="token T_NAMESPACE">namespace</span><span class="token T_WHITESPACE"> </span><span class="token T_STRING">Query</span><span class="token T_NS_SEPARATOR">\</span><span class="token T_STRING">Drivers</span><span class="token T_NS_SEPARATOR">\</span><span class="token T_STRING">Sqlite</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line17"><br/></div><div id="line18"><pre><span class="token T_USE">use</span><span class="token T_WHITESPACE"> </span><span class="token T_STRING">PDO</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line19"><pre><span class="token T_USE">use</span><span class="token T_WHITESPACE"> </span><span class="token T_STRING">Query</span><span class="token T_NS_SEPARATOR">\</span><span class="token T_STRING">Drivers</span><span class="token T_NS_SEPARATOR">\</span><span class="token T_STRING">AbstractUtil</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line20"><br/></div><div id="line21"><pre><span class="token T_DOC_COMMENT">/**</span></pre></div><div id="line22"><pre><span class="token T_DOC_COMMENT"> * SQLite-specific backup, import and creation methods</span></pre></div><div id="line23"><pre><span class="token T_DOC_COMMENT"> */</span></pre></div><div id="line24"><pre><span class="token T_CLASS">class</span><span class="token T_WHITESPACE"> </span><span class="token T_STRING">Util</span><span class="token T_WHITESPACE"> </span><span class="token T_EXTENDS">extends</span><span class="token T_WHITESPACE"> </span><span class="token T_STRING">AbstractUtil</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_OPEN_CURLY">{</span></pre></div><div id="line25"><br/></div><div id="line26"><pre><span class="token T_WHITESPACE"> </span><span class="token T_DOC_COMMENT">/**</span></pre></div><div id="line27"><pre><span class="token T_DOC_COMMENT"> * Create an SQL backup file for the current database's data</span></pre></div><div id="line28"><pre><span class="token T_DOC_COMMENT"> *</span></pre></div><div id="line29"><pre><span class="token T_DOC_COMMENT"> * @param array $excluded</span></pre></div><div id="line30"><pre><span class="token T_DOC_COMMENT"> * @return string</span></pre></div><div id="line31"><pre><span class="token T_DOC_COMMENT"> */</span></pre></div><div id="line32"><pre><span class="token T_WHITESPACE"> </span><span class="token T_PUBLIC">public</span><span class="token T_WHITESPACE"> </span><span class="token T_FUNCTION">function</span><span class="token T_WHITESPACE"> </span><span class="token T_STRING">backupData</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_ARRAY">array</span><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$excluded</span><span class="token T_PHPDOX_EQUAL">=</span><span class="token T_PHPDOX_OPEN_SQUARE">[</span><span class="token T_PHPDOX_CLOSE_SQUARE">]</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_COLON">:</span><span class="token T_WHITESPACE"> </span><span class="token T_STRING">string</span></pre></div><div id="line33"><pre><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_OPEN_CURLY">{</span></pre></div><div id="line34"><pre><span class="token T_WHITESPACE"> </span><span class="token T_COMMENT">// Get a list of all the objects</span></pre></div><div id="line35"><pre><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$sql</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_EQUAL">=</span><span class="token T_WHITESPACE"> </span><span class="token T_CONSTANT_ENCAPSED_STRING">'SELECT DISTINCT "name"</span></pre></div><div id="line36"><pre><span class="token T_CONSTANT_ENCAPSED_STRING"> FROM "sqlite_master"</span></pre></div><div id="line37"><pre><span class="token T_CONSTANT_ENCAPSED_STRING"> WHERE "type"=\'table\''</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line38"><br/></div><div id="line39"><pre><span class="token T_WHITESPACE"> </span><span class="token T_IF">if</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_EXCLAMATION_MARK">!</span><span class="token T_WHITESPACE"> </span><span class="token T_EMPTY">empty</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_VARIABLE">$excluded</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span></pre></div><div id="line40"><pre><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_OPEN_CURLY">{</span></pre></div><div id="line41"><pre><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$sql</span><span class="token T_WHITESPACE"> </span><span class="token T_CONCAT_EQUAL">.=</span><span class="token T_WHITESPACE"> </span><span class="token T_CONSTANT_ENCAPSED_STRING">" AND \"name\" NOT IN('"</span><span class="token T_PHPDOX_DOT">.</span><span class="token T_STRING">implode</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_CONSTANT_ENCAPSED_STRING">"','"</span><span class="token T_PHPDOX_COMMA">,</span><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$excluded</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_DOT">.</span><span class="token T_CONSTANT_ENCAPSED_STRING">"')"</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line42"><pre><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_CLOSE_CURLY">}</span></pre></div><div id="line43"><br/></div><div id="line44"><pre><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$res</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_EQUAL">=</span><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$this</span><span class="token T_OBJECT_OPERATOR">-&gt;</span><span class="token T_STRING">getDriver</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_OBJECT_OPERATOR">-&gt;</span><span class="token T_STRING">query</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_VARIABLE">$sql</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line45"><pre><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$result</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_EQUAL">=</span><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$res</span><span class="token T_OBJECT_OPERATOR">-&gt;</span><span class="token T_STRING">fetchAll</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_STRING">PDO</span><span class="token T_DOUBLE_COLON">::</span><span class="token T_STRING">FETCH_ASSOC</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line46"><br/></div><div id="line47"><pre><span class="token T_WHITESPACE"> </span><span class="token T_UNSET">unset</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_VARIABLE">$res</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line48"><br/></div><div id="line49"><pre><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$outputSql</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_EQUAL">=</span><span class="token T_WHITESPACE"> </span><span class="token T_CONSTANT_ENCAPSED_STRING">''</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line50"><br/></div><div id="line51"><pre><span class="token T_WHITESPACE"> </span><span class="token T_COMMENT">// Get the data for each object</span></pre></div><div id="line52"><pre><span class="token T_WHITESPACE"> </span><span class="token T_FOREACH">foreach</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_VARIABLE">$result</span><span class="token T_WHITESPACE"> </span><span class="token T_AS">as</span><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$r</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span></pre></div><div id="line53"><pre><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_OPEN_CURLY">{</span></pre></div><div id="line54"><pre><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$sql</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_EQUAL">=</span><span class="token T_WHITESPACE"> </span><span class="token T_CONSTANT_ENCAPSED_STRING">'SELECT * FROM "'</span><span class="token T_PHPDOX_DOT">.</span><span class="token T_VARIABLE">$r</span><span class="token T_PHPDOX_OPEN_SQUARE">[</span><span class="token T_CONSTANT_ENCAPSED_STRING">'name'</span><span class="token T_PHPDOX_CLOSE_SQUARE">]</span><span class="token T_PHPDOX_DOT">.</span><span class="token T_CONSTANT_ENCAPSED_STRING">'"'</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line55"><pre><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$res</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_EQUAL">=</span><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$this</span><span class="token T_OBJECT_OPERATOR">-&gt;</span><span class="token T_STRING">getDriver</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_OBJECT_OPERATOR">-&gt;</span><span class="token T_STRING">query</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_VARIABLE">$sql</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line56"><pre><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$objRes</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_EQUAL">=</span><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$res</span><span class="token T_OBJECT_OPERATOR">-&gt;</span><span class="token T_STRING">fetchAll</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_STRING">PDO</span><span class="token T_DOUBLE_COLON">::</span><span class="token T_STRING">FETCH_ASSOC</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line57"><br/></div><div id="line58"><pre><span class="token T_WHITESPACE"> </span><span class="token T_UNSET">unset</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_VARIABLE">$res</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line59"><br/></div><div id="line60"><pre><span class="token T_WHITESPACE"> </span><span class="token T_COMMENT">// If the row is empty, continue</span></pre></div><div id="line61"><pre><span class="token T_WHITESPACE"> </span><span class="token T_IF">if</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_EMPTY">empty</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_VARIABLE">$objRes</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span></pre></div><div id="line62"><pre><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_OPEN_CURLY">{</span></pre></div><div id="line63"><pre><span class="token T_WHITESPACE"> </span><span class="token T_CONTINUE">continue</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line64"><pre><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_CLOSE_CURLY">}</span></pre></div><div id="line65"><br/></div><div id="line66"><pre><span class="token T_WHITESPACE"> </span><span class="token T_COMMENT">// Nab the column names by getting the keys of the first row</span></pre></div><div id="line67"><pre><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$columns</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_EQUAL">=</span><span class="token T_WHITESPACE"> </span><span class="token T_STRING">array_keys</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_STRING">current</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_VARIABLE">$objRes</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line68"><br/></div><div id="line69"><pre><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$insertRows</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_EQUAL">=</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_OPEN_SQUARE">[</span><span class="token T_PHPDOX_CLOSE_SQUARE">]</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line70"><br/></div><div id="line71"><pre><span class="token T_WHITESPACE"> </span><span class="token T_COMMENT">// Create the insert statements</span></pre></div><div id="line72"><pre><span class="token T_WHITESPACE"> </span><span class="token T_FOREACH">foreach</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_VARIABLE">$objRes</span><span class="token T_WHITESPACE"> </span><span class="token T_AS">as</span><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$row</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span></pre></div><div id="line73"><pre><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_OPEN_CURLY">{</span></pre></div><div id="line74"><pre><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$row</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_EQUAL">=</span><span class="token T_WHITESPACE"> </span><span class="token T_STRING">array_values</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_VARIABLE">$row</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line75"><br/></div><div id="line76"><pre><span class="token T_WHITESPACE"> </span><span class="token T_COMMENT">// Quote values as needed by type</span></pre></div><div id="line77"><pre><span class="token T_WHITESPACE"> </span><span class="token T_FOREACH">foreach</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_VARIABLE">$row</span><span class="token T_WHITESPACE"> </span><span class="token T_AS">as</span><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$i</span><span class="token T_WHITESPACE"> </span><span class="token T_DOUBLE_ARROW">=&gt;</span><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$_</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span></pre></div><div id="line78"><pre><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_OPEN_CURLY">{</span></pre></div><div id="line79"><pre><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$row</span><span class="token T_PHPDOX_OPEN_SQUARE">[</span><span class="token T_VARIABLE">$i</span><span class="token T_PHPDOX_CLOSE_SQUARE">]</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_EQUAL">=</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_STRING">is_numeric</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_VARIABLE">$row</span><span class="token T_PHPDOX_OPEN_SQUARE">[</span><span class="token T_VARIABLE">$i</span><span class="token T_PHPDOX_CLOSE_SQUARE">]</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span></pre></div><div id="line80"><pre><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_QUESTION_MARK">?</span><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$row</span><span class="token T_PHPDOX_OPEN_SQUARE">[</span><span class="token T_VARIABLE">$i</span><span class="token T_PHPDOX_CLOSE_SQUARE">]</span></pre></div><div id="line81"><pre><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_COLON">:</span><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$this</span><span class="token T_OBJECT_OPERATOR">-&gt;</span><span class="token T_STRING">getDriver</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_OBJECT_OPERATOR">-&gt;</span><span class="token T_STRING">quote</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_VARIABLE">$row</span><span class="token T_PHPDOX_OPEN_SQUARE">[</span><span class="token T_VARIABLE">$i</span><span class="token T_PHPDOX_CLOSE_SQUARE">]</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line82"><pre><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_CLOSE_CURLY">}</span></pre></div><div id="line83"><br/></div><div id="line84"><pre><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$rowString</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_EQUAL">=</span><span class="token T_WHITESPACE"> </span><span class="token T_CONSTANT_ENCAPSED_STRING">'INSERT INTO "'</span><span class="token T_PHPDOX_DOT">.</span><span class="token T_VARIABLE">$r</span><span class="token T_PHPDOX_OPEN_SQUARE">[</span><span class="token T_CONSTANT_ENCAPSED_STRING">'name'</span><span class="token T_PHPDOX_CLOSE_SQUARE">]</span><span class="token T_PHPDOX_DOT">.</span><span class="token T_CONSTANT_ENCAPSED_STRING">'" ("'</span><span class="token T_PHPDOX_DOT">.</span><span class="token T_STRING">implode</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_CONSTANT_ENCAPSED_STRING">'","'</span><span class="token T_PHPDOX_COMMA">,</span><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$columns</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_DOT">.</span><span class="token T_CONSTANT_ENCAPSED_STRING">'") VALUES ('</span><span class="token T_PHPDOX_DOT">.</span><span class="token T_STRING">implode</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_CONSTANT_ENCAPSED_STRING">','</span><span class="token T_PHPDOX_COMMA">,</span><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$row</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_DOT">.</span><span class="token T_CONSTANT_ENCAPSED_STRING">');'</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line85"><br/></div><div id="line86"><pre><span class="token T_WHITESPACE"> </span><span class="token T_UNSET">unset</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_VARIABLE">$row</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line87"><br/></div><div id="line88"><pre><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$insertRows</span><span class="token T_PHPDOX_OPEN_SQUARE">[</span><span class="token T_PHPDOX_CLOSE_SQUARE">]</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_EQUAL">=</span><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$rowString</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line89"><pre><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_CLOSE_CURLY">}</span></pre></div><div id="line90"><br/></div><div id="line91"><pre><span class="token T_WHITESPACE"> </span><span class="token T_UNSET">unset</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_VARIABLE">$objRes</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line92"><br/></div><div id="line93"><pre><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$outputSql</span><span class="token T_WHITESPACE"> </span><span class="token T_CONCAT_EQUAL">.=</span><span class="token T_WHITESPACE"> </span><span class="token T_CONSTANT_ENCAPSED_STRING">"\n\n"</span><span class="token T_PHPDOX_DOT">.</span><span class="token T_STRING">implode</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_CONSTANT_ENCAPSED_STRING">"\n"</span><span class="token T_PHPDOX_COMMA">,</span><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$insertRows</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line94"><pre><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_CLOSE_CURLY">}</span></pre></div><div id="line95"><br/></div><div id="line96"><pre><span class="token T_WHITESPACE"> </span><span class="token T_RETURN">return</span><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$outputSql</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line97"><pre><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_CLOSE_CURLY">}</span></pre></div><div id="line98"><br/></div><div id="line99"><pre><span class="token T_WHITESPACE"> </span><span class="token T_DOC_COMMENT">/**</span></pre></div><div id="line100"><pre><span class="token T_DOC_COMMENT"> * Create an SQL backup file for the current database's structure</span></pre></div><div id="line101"><pre><span class="token T_DOC_COMMENT"> *</span></pre></div><div id="line102"><pre><span class="token T_DOC_COMMENT"> * @return string</span></pre></div><div id="line103"><pre><span class="token T_DOC_COMMENT"> */</span></pre></div><div id="line104"><pre><span class="token T_WHITESPACE"> </span><span class="token T_PUBLIC">public</span><span class="token T_WHITESPACE"> </span><span class="token T_FUNCTION">function</span><span class="token T_WHITESPACE"> </span><span class="token T_STRING">backupStructure</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_COLON">:</span><span class="token T_WHITESPACE"> </span><span class="token T_STRING">string</span></pre></div><div id="line105"><pre><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_OPEN_CURLY">{</span></pre></div><div id="line106"><pre><span class="token T_WHITESPACE"> </span><span class="token T_COMMENT">// Fairly easy for SQLite...just query the master table</span></pre></div><div id="line107"><pre><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$sql</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_EQUAL">=</span><span class="token T_WHITESPACE"> </span><span class="token T_CONSTANT_ENCAPSED_STRING">'SELECT "sql" FROM "sqlite_master"'</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line108"><pre><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$res</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_EQUAL">=</span><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$this</span><span class="token T_OBJECT_OPERATOR">-&gt;</span><span class="token T_STRING">getDriver</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_OBJECT_OPERATOR">-&gt;</span><span class="token T_STRING">query</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_VARIABLE">$sql</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line109"><pre><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$result</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_EQUAL">=</span><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$res</span><span class="token T_OBJECT_OPERATOR">-&gt;</span><span class="token T_STRING">fetchAll</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_STRING">PDO</span><span class="token T_DOUBLE_COLON">::</span><span class="token T_STRING">FETCH_ASSOC</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line110"><br/></div><div id="line111"><pre><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$sqlArray</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_EQUAL">=</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_OPEN_SQUARE">[</span><span class="token T_PHPDOX_CLOSE_SQUARE">]</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line112"><br/></div><div id="line113"><pre><span class="token T_WHITESPACE"> </span><span class="token T_FOREACH">foreach</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_VARIABLE">$result</span><span class="token T_WHITESPACE"> </span><span class="token T_AS">as</span><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$r</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span></pre></div><div id="line114"><pre><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_OPEN_CURLY">{</span></pre></div><div id="line115"><pre><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$sqlArray</span><span class="token T_PHPDOX_OPEN_SQUARE">[</span><span class="token T_PHPDOX_CLOSE_SQUARE">]</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_EQUAL">=</span><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$r</span><span class="token T_PHPDOX_OPEN_SQUARE">[</span><span class="token T_CONSTANT_ENCAPSED_STRING">'sql'</span><span class="token T_PHPDOX_CLOSE_SQUARE">]</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line116"><pre><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_CLOSE_CURLY">}</span></pre></div><div id="line117"><br/></div><div id="line118"><pre><span class="token T_WHITESPACE"> </span><span class="token T_RETURN">return</span><span class="token T_WHITESPACE"> </span><span class="token T_STRING">implode</span><span class="token T_PHPDOX_OPEN_BRACKET">(</span><span class="token T_CONSTANT_ENCAPSED_STRING">";\n"</span><span class="token T_PHPDOX_COMMA">,</span><span class="token T_WHITESPACE"> </span><span class="token T_VARIABLE">$sqlArray</span><span class="token T_PHPDOX_CLOSE_BRACKET">)</span><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_DOT">.</span><span class="token T_WHITESPACE"> </span><span class="token T_CONSTANT_ENCAPSED_STRING">';'</span><span class="token T_PHPDOX_SEMICOLON">;</span></pre></div><div id="line119"><pre><span class="token T_WHITESPACE"> </span><span class="token T_PHPDOX_CLOSE_CURLY">}</span></pre></div><div id="line120"><pre><span class="token T_PHPDOX_CLOSE_CURLY">}</span></pre></div></td></tr></table></section></div><footer><span>Generated using phpDox 0.12.0-dev - Copyright (C) 2010 - 2020 by Arne Blankerts and Contributors</span></footer></body></html>