[prev in list] [next in list] [prev in thread] [next in thread]
List: pear-cvs
Subject: [PEAR-CVS] cvs: pear /MDB/MDB Common.php fbsql.php mysql.php oci8.php pgsql.php
From: "Lukas Smith" <smith () dybnet ! de>
Date: 2003-03-06 22:19:24
[Download RAW message or body]
lsmith Thu Mar 6 17:19:24 2003 EDT
Modified files:
/pear/MDB/MDB pgsql.php oci8.php mysql.php fbsql.php Common.php
Log:
all get*Value() methods (aside from getBlobValue and getClobValue which are not \
called directly anyways) will now turn a php NULL into an SQL NULL therefore passing \
of a php 'NULL' string to all of the above methods (except for getTextValue() for \
which this feature was missing anyways) was removed this is a BC break!
["lsmith-20030306171924.txt" (text/plain)]
Index: pear/MDB/MDB/pgsql.php
diff -u pear/MDB/MDB/pgsql.php:1.52 pear/MDB/MDB/pgsql.php:1.53
--- pear/MDB/MDB/pgsql.php:1.52 Sun Feb 23 10:50:00 2003
+++ pear/MDB/MDB/pgsql.php Thu Mar 6 17:19:23 2003
@@ -42,7 +42,7 @@
// | Author: Paul Cooper <pgc@ucecom.com> |
// +----------------------------------------------------------------------+
//
-// $Id: pgsql.php,v 1.52 2003/02/23 15:50:00 lsmith Exp $
+// $Id: pgsql.php,v 1.53 2003/03/06 22:19:23 lsmith Exp $
require_once('MDB/Common.php');
@@ -1167,7 +1167,7 @@
*/
function getFloatValue($value)
{
- return(!strcmp($value, 'NULL') ? 'NULL' : $value);
+ return(($value === NULL) ? 'NULL' : $value);
}
// }}}
@@ -1184,7 +1184,7 @@
*/
function getDecimalValue($value)
{
- return(!strcmp($value, 'NULL') ? 'NULL' : \
strval(round($value*$this->decimal_factor))); + return(($value === NULL) ? \
'NULL' : strval(round($value*$this->decimal_factor))); }
// }}}
Index: pear/MDB/MDB/oci8.php
diff -u pear/MDB/MDB/oci8.php:1.10 pear/MDB/MDB/oci8.php:1.11
--- pear/MDB/MDB/oci8.php:1.10 Sun Feb 23 10:50:01 2003
+++ pear/MDB/MDB/oci8.php Thu Mar 6 17:19:23 2003
@@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@backendmedia.com> |
// +----------------------------------------------------------------------+
-// $Id: oci8.php,v 1.10 2003/02/23 15:50:01 lsmith Exp $
+// $Id: oci8.php,v 1.11 2003/03/06 22:19:23 lsmith Exp $
if (!defined('MDB_OCI8_INCLUDED')) {
define('MDB_OCI8_INCLUDED', 1);
@@ -970,20 +970,9 @@
* Obtain DBMS specific native datatype as a string
*
* @param string $field associative array with the name of the properties
- * of the field being declared as array indexes. Id
- * ently, the types
+ * of the field being declared as array indexes. Currently, the types
* of supported field properties are as follows:
*
- * unsigned
- * Boolean flag that indicates whether the field should be
- * declared as unsigned integer if possible.
- *
- * default
- * Integer value to be used as default for this field.
- *
- * notnull
- * Boolean flag that indicates whether this field is constrained
- * to not be set to NULL.
* @return string with the correct RDBMS native type
* @access public
*/
@@ -1378,7 +1367,7 @@
*/
function getDateValue($value)
{
- return(!strcmp($value, 'NULL') ? 'NULL' : "TO_DATE('$value','YYYY-MM-DD')");
+ return($value === NULL) ? 'NULL' : "TO_DATE('$value','YYYY-MM-DD')");
}
// }}}
@@ -1395,7 +1384,7 @@
*/
function getTimestampValue($value)
{
- return(!strcmp($value, 'NULL') ? 'NULL' : "TO_DATE('$value','YYYY-MM-DD \
HH24:MI:SS')"); + return($value === NULL) ? 'NULL' : \
"TO_DATE('$value','YYYY-MM-DD HH24:MI:SS')"); }
// }}}
@@ -1412,7 +1401,7 @@
*/
function getTimeValue($value)
{
- return(!strcmp($value, 'NULL') ? 'NULL' : "TO_DATE('0001-01-01 \
$value','YYYY-MM-DD HH24:MI:SS')"); + return($value === NULL) ? 'NULL' : \
"TO_DATE('0001-01-01 $value','YYYY-MM-DD HH24:MI:SS')"); }
// }}}
@@ -1429,7 +1418,7 @@
*/
function getFloatValue($value)
{
- return(!strcmp($value, 'NULL') ? 'NULL' : "$value");
+ return(($value === NULL) ? 'NULL' : (float)$value);
}
// }}}
@@ -1446,7 +1435,7 @@
*/
function getDecimalValue($value)
{
- return(!strcmp($value, 'NULL') ? 'NULL' : "$value");
+ return($value === NULL) ? 'NULL' : $value);
}
// }}}
Index: pear/MDB/MDB/mysql.php
diff -u pear/MDB/MDB/mysql.php:1.68 pear/MDB/MDB/mysql.php:1.69
--- pear/MDB/MDB/mysql.php:1.68 Sun Feb 23 10:50:01 2003
+++ pear/MDB/MDB/mysql.php Thu Mar 6 17:19:23 2003
@@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@backendmedia.com> |
// +----------------------------------------------------------------------+
//
-// $Id: mysql.php,v 1.68 2003/02/23 15:50:01 lsmith Exp $
+// $Id: mysql.php,v 1.69 2003/03/06 22:19:23 lsmith Exp $
//
require_once('MDB/Common.php');
@@ -580,10 +580,6 @@
if (isset($fields[$name]['Null']) && $fields[$name]['Null']) {
$value = 'NULL';
} else {
- if (!isset($fields[$name]['Value'])) {
- return($this->raiseError(MDB_ERROR_CANNOT_REPLACE, NULL, NULL,
- 'no value for field "'.$name.'" specified'));
- }
if(isset($fields[$name]['Type'])) {
switch ($fields[$name]['Type']) {
case 'text':
@@ -593,7 +589,7 @@
$value = \
$this->getBooleanValue($fields[$name]['Value']); break;
case 'integer':
- $value = strval($fields[$name]['Value']);
+ $value = \
$this->getIntegerValue($fields[$name]['Value']); break;
case 'decimal':
$value = \
$this->getDecimalValue($fields[$name]['Value']); @@ -620,9 +616,9 @@
}
$values .= $value;
if (isset($fields[$name]['Key']) && $fields[$name]['Key']) {
- if ($value == 'NULL') {
+ if ($value === 'NULL') {
return($this->raiseError(MDB_ERROR_CANNOT_REPLACE, NULL, NULL,
- 'key values may not be NULL'));
+ $name.': key values may not be NULL'));
}
$keys++;
}
@@ -1247,7 +1243,7 @@
*/
function getFloatValue($value)
{
- return(!strcmp($value, 'NULL') ? 'NULL' : "$value");
+ return(($value === NULL) ? 'NULL' : (float)$value);
}
// }}}
@@ -1264,7 +1260,7 @@
*/
function getDecimalValue($value)
{
- return(!strcmp($value, 'NULL') ? 'NULL' : \
strval(round(doubleval($value)*$this->decimal_factor))); + return(($value === \
NULL) ? 'NULL' : strval(round(doubleval($value)*$this->decimal_factor))); }
// }}}
Index: pear/MDB/MDB/fbsql.php
diff -u pear/MDB/MDB/fbsql.php:1.7 pear/MDB/MDB/fbsql.php:1.8
--- pear/MDB/MDB/fbsql.php:1.7 Sun Feb 23 10:50:01 2003
+++ pear/MDB/MDB/fbsql.php Thu Mar 6 17:19:23 2003
@@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@dybnet.de> |
// +----------------------------------------------------------------------+
//
-// $Id: fbsql.php,v 1.7 2003/02/23 15:50:01 lsmith Exp $
+// $Id: fbsql.php,v 1.8 2003/03/06 22:19:23 lsmith Exp $
//
require_once('MDB/Common.php');
@@ -1221,7 +1221,7 @@
*/
function getFloatValue($value)
{
- return(!strcmp($value, 'NULL') ? 'NULL' : "$value");
+ return(($value === NULL) ? 'NULL' : (float)$value);
}
// }}}
@@ -1238,7 +1238,7 @@
*/
function getDecimalValue($value)
{
- return(!strcmp($value, 'NULL') ? 'NULL' : \
strval(round(doubleval($value)*$this->decimal_factor))); + return(($value === \
NULL) ? 'NULL' : strval(round(doubleval($value)*$this->decimal_factor))); }
// }}}
Index: pear/MDB/MDB/Common.php
diff -u pear/MDB/MDB/Common.php:1.91 pear/MDB/MDB/Common.php:1.92
--- pear/MDB/MDB/Common.php:1.91 Sun Feb 23 10:50:00 2003
+++ pear/MDB/MDB/Common.php Thu Mar 6 17:19:23 2003
@@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@backendmedia.com> |
// +----------------------------------------------------------------------+
//
-// $Id: Common.php,v 1.91 2003/02/23 15:50:00 lsmith Exp $
+// $Id: Common.php,v 1.92 2003/03/06 22:19:23 lsmith Exp $
/**
* @package MDB
@@ -1533,10 +1533,6 @@
if (isset($fields[$name]['Null']) && $fields[$name]['Null']) {
$value = 'NULL';
} else {
- if (!isset($fields[$name]['Value'])) {
- return($this->raiseError(MDB_ERROR_CANNOT_REPLACE, NULL, NULL,
- 'no value for field "' . $name . '" specified'));
- }
if(isset($fields[$name]['Type'])) {
switch ($fields[$name]['Type']) {
case 'text':
@@ -1546,7 +1542,7 @@
$value = \
$this->getBooleanValue($fields[$name]['Value']); break;
case 'integer':
- $value = strval($fields[$name]['Value']);
+ $value = \
$this->getIntegerValue($fields[$name]['Value']); break;
case 'decimal':
$value = \
$this->getDecimalValue($fields[$name]['Value']); @@ -1573,7 +1569,7 @@
}
$values .= $value;
if (isset($fields[$name]['Key']) && $fields[$name]['Key']) {
- if ($value == 'NULL') {
+ if ($value === 'NULL') {
return($this->raiseError(MDB_ERROR_CANNOT_REPLACE, NULL, NULL,
'key values may not be NULL'));
}
@@ -1936,6 +1932,11 @@
function setParamArray($prepared_query, $params, $types = NULL)
{
if (is_array($types)) {
+ if (count($params) != count($types)) {
+ return $this->raiseError(MDB_ERROR_SYNTAX, NULL, NULL,
+ 'setParamArray: the number of given types ('.count($types).')'
+ .'is not corresponding to the number of given parameters \
('.count($params).')'); + }
for($i = 0, $j = count($params); $i < $j; ++$i) {
switch ($types[$i]) {
case 'NULL':
@@ -2836,8 +2837,7 @@
*
* @param string $name name the field to be declared.
* @param string $field associative array with the name of the properties
- * of the field being declared as array indexes. Id
- ently, the types
+ * of the field being declared as array indexes. Currently, the types
* of supported field properties are as follows:
*
* unsigned
@@ -3129,7 +3129,7 @@
*/
function getIntegerValue($value)
{
- return(!strcmp($value, 'NULL') ? 'NULL' : "$value");
+ return(($value === NULL) ? 'NULL' : (int)$value);
}
// }}}
@@ -3146,8 +3146,7 @@
*/
function getTextValue($value)
{
- $value = $this->_quote($value);
- return("'$value'");
+ return(($value === NULL) ? 'NULL' : "'".$this->_quote($value)."'");
}
// }}}
@@ -3234,7 +3233,7 @@
*/
function getBooleanValue($value)
{
- return(!strcmp($value, 'NULL') ? 'NULL' : ($value ? "'Y'" : "'N'"));
+ return(($value === NULL) ? 'NULL' : ($value ? "'Y'" : "'N'"));
}
// }}}
@@ -3251,7 +3250,7 @@
*/
function getDateValue($value)
{
- return(!strcmp($value, 'NULL') ? 'NULL' : "'$value'");
+ return(($value === NULL) ? 'NULL' : "'$value'");
}
// }}}
@@ -3268,7 +3267,7 @@
*/
function getTimestampValue($value)
{
- return(!strcmp($value, 'NULL') ? 'NULL' : "'$value'");
+ return(($value === NULL) ? 'NULL' : "'$value'");
}
// }}}
@@ -3285,7 +3284,7 @@
*/
function getTimeValue($value)
{
- return(!strcmp($value, 'NULL') ? 'NULL' : "'$value'");
+ return(($value === NULL) ? 'NULL' : "'$value'");
}
// }}}
@@ -3302,7 +3301,7 @@
*/
function getFloatValue($value)
{
- return(!strcmp($value, 'NULL') ? 'NULL' : "'$value'");
+ return(($value === NULL) ? 'NULL' : "'$value'");
}
// }}}
@@ -3319,7 +3318,7 @@
*/
function getDecimalValue($value)
{
- return(!strcmp($value, 'NULL') ? 'NULL' : "'$value'");
+ return(($value === NULL) ? 'NULL' : "'$value'");
}
// }}}
--
PEAR CVS Mailing List (http://pear.php.net/)
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