[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pecl-cvs
Subject:    [PECL-CVS] cvs: pecl /dbdo dbdo.c dbdo_object.c  /dbdo/examples valueSet.php
From:       "Alan Knowles" <alan_k () php ! net>
Date:       2004-11-27 12:00:30
Message-ID: cvsalan_k1101556830 () cvsserver
[Download RAW message or body]

alan_k		Sat Nov 27 07:00:30 2004 EDT

  Modified files:              
    /pecl/dbdo	dbdo.c dbdo_object.c 
    /pecl/dbdo/examples	valueSet.php 
  Log:
  auto field length checking :)
  
http://cvs.php.net/diff.php/pecl/dbdo/dbdo.c?r1=1.37&r2=1.38&ty=u
Index: pecl/dbdo/dbdo.c
diff -u pecl/dbdo/dbdo.c:1.37 pecl/dbdo/dbdo.c:1.38
--- pecl/dbdo/dbdo.c:1.37	Sat Nov 27 06:45:41 2004
+++ pecl/dbdo/dbdo.c	Sat Nov 27 07:00:30 2004
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: dbdo.c,v 1.37 2004/11/27 11:45:41 alan_k Exp $ */
+/* $Id: dbdo.c,v 1.38 2004/11/27 12:00:30 alan_k Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -853,6 +853,7 @@
 		
 		h = zend_hash_func(title, strlen(title)+1);
 		zend_hash_quick_update(HASH_OF(return_value), ntitle, strlen(title)+1, h, &zvalue, \
sizeof(zval *), NULL); +		efree(ntitle);
 		
 		
 	}
http://cvs.php.net/diff.php/pecl/dbdo/dbdo_object.c?r1=1.8&r2=1.9&ty=u
Index: pecl/dbdo/dbdo_object.c
diff -u pecl/dbdo/dbdo_object.c:1.8 pecl/dbdo/dbdo_object.c:1.9
--- pecl/dbdo/dbdo_object.c:1.8	Sat Nov 27 06:45:41 2004
+++ pecl/dbdo/dbdo_object.c	Sat Nov 27 07:00:30 2004
@@ -360,7 +360,6 @@
 				case GDA_VALUE_TYPE_BIGUINT:
 				{
 					ret =  g_new0 (GdaValue, 1);
-					
 					convert_to_long(from); 
 					gda_value_set_bigint(ret, (int)Z_LVAL_P(from));
 					break; 
@@ -382,10 +381,31 @@
 					}
 					convert_to_string(from);
 					gda_value_set_from_string(ret, Z_STRVAL_P(from),type); 
+					
+					/* find a string */
+					{
+						int row_id,col,fieldsize;
+						GdaRow *row;
+						row_id = dbdo_schema_get_col_row(obj,name);
+						row = (GdaRow *) gda_data_model_get_row (obj->table->schema, row_id);
+						col = gda_data_model_get_column_position(obj->table->schema, "Size");
+						fieldsize  = gda_value_get_integer((GdaValue *) gda_row_get_value (row, col));
+						if (Z_STRLEN_P(from) > fieldsize) {
+							if (from == &value_copy) {
+								zval_dtor(from);
+							}
+							zend_throw_exception_ex(
+								dbdo_class_entry_exception_ce , 0 TSRMLS_CC, 
+								"Column %s is not large enough for The value you assigned",
+								name);
+							return NULL;
+						}	
+						
+						
+					}
 					if (from == &value_copy) {
 						zval_dtor(from);
 					}
-
 					break;
 				case GDA_VALUE_TYPE_SINGLE:
 				ret =  g_new0 (GdaValue, 1);
http://cvs.php.net/diff.php/pecl/dbdo/examples/valueSet.php?r1=1.1&r2=1.2&ty=u
Index: pecl/dbdo/examples/valueSet.php
diff -u pecl/dbdo/examples/valueSet.php:1.1 pecl/dbdo/examples/valueSet.php:1.2
--- pecl/dbdo/examples/valueSet.php:1.1	Sat Nov 27 06:45:41 2004
+++ pecl/dbdo/examples/valueSet.php	Sat Nov 27 07:00:30 2004
@@ -12,7 +12,7 @@
 
 class x { 
     function toString() {
-        return 'hello world';
+        return str_repeat('hello world',255);
     }
     function toSQL() {
         return 'NOW()';
@@ -22,7 +22,8 @@
 
 // connect to source test, table test..
 $x = new dbdo("test","typetest");
-$x->schema();
+print_r($x->schema());
+print_r($x->schema('v_varchar'));
 
 $x->valueSet('b_bool', 0);
 $x->valueSet('v_varchar', 6);

-- 
PECL CVS Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic