[TEP-COMMIT] [CVS catalog] allow the select count field to be defined for batched queries

hpdl-OfajU3CKLf1/[email protected] 26 Oct 2004 20:04:11 -0000
Newsgroups gmane.comp.web.oscommerce.cvs
Message-ID <[email protected]>
<html>
<head>
<style><!--
  body {background-color:#ffffff;}
  .file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
  .pathname {font-family:monospace; float:right;}
  .fileheader {margin-bottom:.5em;}
  .diff {margin:0;}
  .tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
  .tasklist ul {margin-top:0;margin-bottom:0;}
  tr.alt {background-color:#eeeeee}
  #added {background-color:#ddffdd;}
  #addedchars {background-color:#99ff99;font-weight:bolder;}
  tr.alt #added {background-color:#ccf7cc;}
  #removed {background-color:#ffdddd;}
  #removedchars {background-color:#ff9999;font-weight:bolder;}
  tr.alt #removed {background-color:#f7cccc;}
  #info {color:#888888;}
  #context {background-color:#eeeeee;}
  td {padding-left:.3em;padding-right:.3em;}
  tr.head {border-bottom-width:1px;border-bottom-style:solid;}
  tr.head td {padding:0;padding-top:.2em;}
  .task {background-color:#ffff00;}
  .comment {padding:4px;border:1px dashed #000000;background-color:#ffffdd}
  .error {color:red;}
  hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="4">Commit in <b><tt>catalog/catalog/includes/classes</tt></b><span id="info"> on MAIN</span></td></tr>
<tr><td><tt><a href="#file1">database.php</a></tt></td><td align="right" id="added">+5</td><td align="right" id="removed">-3</td><td nowrap="nowrap" align="center"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/database.php?rev=1.5&amp;content-type=text/vnd.viewcvs-markup">1.5</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/database.php.diff?r1=1.5&amp;r2=1.6">-&gt;</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/database.php?rev=1.6&amp;content-type=text/vnd.viewcvs-markup">1.6</a></td></tr>
<tr class="alt"><td><tt>database/<a href="#file2">mysql.php</a></tt></td><td align="right" id="added">+2</td><td align="right" id="removed">-2</td><td nowrap="nowrap" align="center"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/database/mysql.php?rev=1.4&amp;content-type=text/vnd.viewcvs-markup">1.4</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/database/mysql.php.diff?r1=1.4&amp;r2=1.5">-&gt;</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/database/mysql.php?rev=1.5&amp;content-type=text/vnd.viewcvs-markup">1.5</a></td></tr>
<tr><td></td><td align="right" id="added">+7</td><td align="right" id="removed">-5</td><td></td></tr>
</table>
<small id="info">2 modified files</small><br />
<pre class="comment">
allow the select count field to be defined for batched queries
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes">includes</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes">classes</a><br /></span>
<div class="fileheader"><big><b>database.php</b></big> <small id="info"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/database.php?rev=1.5&amp;content-type=text/vnd.viewcvs-markup">1.5</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/database.php.diff?r1=1.5&amp;r2=1.6">-&gt;</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/database.php?rev=1.6&amp;content-type=text/vnd.viewcvs-markup">1.6</a></small></div>
<pre class="diff"><small id="info">diff -u -r1.5 -r1.6
--- database.php	2004/08/27 22:02:26	1.5
+++ database.php	2004/10/26 20:04:04	1.6
@@ -282,7 +282,8 @@
</small></pre><pre class="diff" id="context">         $batch_rows,
         $batch_size,
         $batch_to,
</pre><pre class="diff" id="removed">-        $batch_from<span id="removedchars">;</span>
</pre><pre class="diff" id="added">+        $batch_from<span id="addedchars">,</span>
+        $batch_select_field;
</pre><pre class="diff" id="context"> 
     function osC_Database_Result(&amp;$db_class) {
       $this-&gt;db_class =&amp; $db_class;
</pre><pre class="diff"><small id="info">@@ -516,10 +517,11 @@
</small></pre><pre class="diff" id="context">       return $this-&gt;result;
     }
 
</pre><pre class="diff" id="removed">-    function setBatchLimit($batch_number, $maximum_rows) {
</pre><pre class="diff" id="added">+    function setBatchLimit($batch_number, $maximum_rows<span id="addedchars">,&nbsp;$select_field&nbsp;=&nbsp;''</span>) {
</pre><pre class="diff" id="context">       $this-&gt;batch_query = true;
       $this-&gt;batch_number = $batch_number;
       $this-&gt;batch_rows = $maximum_rows;
</pre><pre class="diff" id="added">+      $this-&gt;batch_select_field = (empty($select_field) ? '*' : $select_field);
</pre><pre class="diff" id="context"> 
       $from = ($batch_number * $maximum_rows) - $maximum_rows;
 
</pre><pre class="diff"><small id="info">@@ -533,7 +535,7 @@
</small></pre><pre class="diff" id="context">       if (!isset($this-&gt;batch_size)) {
 
 
</pre><pre class="diff" id="removed">-        $this-&gt;batch_size = $this-&gt;db_class-&gt;batchSize($this-&gt;sql_query);
</pre><pre class="diff" id="added">+        $this-&gt;batch_size = $this-&gt;db_class-&gt;batchSize($this-&gt;sql_query<span id="addedchars">,&nbsp;$this-&gt;batch_select_field</span>);
</pre><pre class="diff" id="context">       }
 
       return $this-&gt;batch_size;
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes">includes</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes">classes</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/database">database</a><br /></span>
<div class="fileheader"><big><b>mysql.php</b></big> <small id="info"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/database/mysql.php?rev=1.4&amp;content-type=text/vnd.viewcvs-markup">1.4</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/database/mysql.php.diff?r1=1.4&amp;r2=1.5">-&gt;</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/database/mysql.php?rev=1.5&amp;content-type=text/vnd.viewcvs-markup">1.5</a></small></div>
<pre class="diff"><small id="info">diff -u -r1.4 -r1.5
--- mysql.php	2004/07/22 16:22:13	1.4
+++ mysql.php	2004/10/26 20:04:07	1.5
@@ -220,12 +220,12 @@
</small></pre><pre class="diff" id="context">       return $sql_query . ' limit ' . $from . ', ' . $maximum_rows;
     }
 
</pre><pre class="diff" id="removed">-    function batchSize($sql_query) {
</pre><pre class="diff" id="added">+    function batchSize($sql_query, $select_field = '*') {
</pre><pre class="diff" id="context">       if (strpos($sql_query, 'SQL_CALC_FOUND_ROWS') !== false) {
         $bb = $this-&gt;query('select found_rows() as total');
       } else {
         $total_query = substr($sql_query, 0, strpos($sql_query, ' limit'));
</pre><pre class="diff" id="removed">-        $bb = $this-&gt;query('select count(<span id="removedchars">*</span>) as total ' . substr($total_query, strpos($sql_query, 'from ')));
</pre><pre class="diff" id="added">+        $bb = $this-&gt;query('select count(<span id="addedchars">'&nbsp;.&nbsp;$select_field&nbsp;.&nbsp;'</span>) as total ' . substr($total_query, strpos($sql_query, 'from ')));
</pre><pre class="diff" id="context">       }
 
       return $bb-&gt;value('total');
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -&gt; email">CVSspam</a> 0.2.9</small></center>
</body></html>


-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click