[phplib-dev] cvs commit From: ssilk (phplib-dev <email protected>)
Date: 01/28/01

From: ssilk
Date: Mon Jan 29 00:10:34 2001
Modified files:
      php-lib/php/query_sql.inc

Log message:
Bugfixes of query_sql. Works now very fine - think we can say it's now
stable.

Index: php-lib/php/query_sql.inc
diff -u php-lib/php/query_sql.inc:1.21 php-lib/php/query_sql.inc:1.22
--- php-lib/php/query_sql.inc:1.21 Thu Sep 21 23:26:59 2000
+++ php-lib/php/query_sql.inc Mon Jan 29 00:10:02 2001
@@ -18,7 +18,7 @@
  * is based in November 1997,
  * it was a collection of functions for PHP/FI and mSQL.
  *
- * $Id: query_sql.inc,v 1.21 2000/09/21 21:26:59 ssilk Exp $
+ * $Id: query_sql.inc,v 1.22 2001/01/28 23:10:02 ssilk Exp $
  *
  */
 
@@ -203,7 +203,6 @@
                 }
         }
 
- ##
         ## table_quote - converts a value of given table into a
         ## corresponding correctly escaped value. Indeed it is only
         ## some better type of interface for convert()
@@ -470,8 +469,10 @@
                 }
                 list($vals,$names)=$this->uniform_vars($meta,$fields,$special);
 
+ $unique_key=array_flip(explode(' ',$meta['unique']));
                 for ($i=0 ; $i < Count ($names); $i++ ) {
- $s[]=$names[$i].'='.$vals[$i];
+ if (!isset($unique_key[$names[$i]]))
+ $s[]=$names[$i].'='.$vals[$i];
                 }
                 if (Count($s)) {
                         $q=sprintf("UPDATE %s SET %s%s",$table,join($s,", "),
@@ -672,12 +673,14 @@
                 }
                 $uniq=split(" ",$meta['unique']);
                 $wfields=ARRAY();
+ # loops through found uniques and remember them in $wfields
                 for ( reset($uniq) ; list(,$name)=each($uniq) ; ) {
- if (isset($meta['meta'][$name])) {
- $tmp= $this->convert($fields[$name],
+ if (!isset($fields[$name])) continue;
+ if (isset($meta['meta'][$name]) ) {
+ $tmp= $this->convert(@$fields[$name],
                                                      $meta[$meta['meta'][$name]],
                                                      @$special[$name]);
- if ( (string)$tmp[0] !='NULL' &&
+ if ( (string)$tmp[0] !='NULL' and
                                      empty($special['removenull']) ) {
                                         $wfields[$name]=$fields[$name];
                                 }
@@ -691,7 +694,9 @@
                 if (!$whereclause) {
                         echo "ERROR: unique_where_Clause(): The result of generating a where-clause to this uniqe identifers is empty:<br>";
                         for ( reset($uniq); list(,$name)=each($uniq) ; ) {
- echo "[$name]=>'$fields[$name]'<br>";
+ if (!isset($fields[$name]) )
+ echo "\$fields[$name] is empty";
+ else echo "\$fields[$name]=>'$fields[$name]'<br>";
                         }
                         echo "<br>";
                         return(false);
@@ -885,7 +890,7 @@
         ##
         ## $table The name of the table
         ##
- function capture_vars ($table) {
+ function capture_vars ($table,$special='') {
                 list($table,$prefix)=$this->istableprefix($table,$special);
                 $meta=$this->metadata_buffered($table,$prefix);
                 $r=Array();

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-dev-unsubscribe <email protected>
For additional commands, e-mail: phplib-dev-help <email protected>