Code Duplication    Length = 39-51 lines in 2 locations

class/adodb.php 1 location

@@ 929-967 (lines=39) @@
926
	 * @param	mixed	$val
927
	 * @return	string
928
	 */
929
	public function QuoteValue ($table, $column, $val) {
930
		$this->GetMetaColumn($table);
931
		if (!isset($this->aMetaColumn[$table][$column]->type)) {
932
			error_log("Column to quote not exists($table.$column).\n");
933
			// Return quoted value for safety
934
			$val = stripslashes($val);
935
			return $this->qstr($val, false);
936
		}
937
938
		//print_r($this->aMetaColumn[$table][$column]);
939
		$type = $this->aMetaColumn[$table][$column]->type;
940
		//var_dump($type);
941
		if (in_array($type, array(
942
				'bigint',
943
				'bit',
944
				'decimal',
945
				'double',
946
				'float',
947
				'int',
948
				'intn', // Sybase - tinyint
949
				'mediumint',
950
				'numeric',
951
				'numericn',	// Sybase - numeric
952
				'real',
953
				'smallint',
954
				'tinyint',
955
			)))
956
			// Need not quote, output directly
957
			return $val;
958
		// Sybase timestamp
959
		//elseif ($this->IsDbSybase() && 'varbinary' == $type && 'timestamp' == $column)
960
		elseif ($this->IsDbSybase() && 'timestamp' == $type)
961
			return '0x' . $val;
962
		else {
963
			// Need quote, use db's quote method
964
			$val = stripslashes($val);
965
			return $this->qstr($val, false);
966
		}
967
	} // end of func GenSqlQuote
968
969
970
	/**

src/Fwlib/Bridge/Adodb.php 1 location

@@ 1225-1275 (lines=51) @@
1222
     * @param   mixed   $val
1223
     * @return  string
1224
     */
1225
    public function quoteValue($table, $col, $val)
1226
    {
1227
        $this->getMetaColumn($table);
1228
        if (!isset($this->metaColumn[$table][$col]->type)) {
1229
            trigger_error(
1230
                "Column to quote not exists($table.$col).",
1231
                E_USER_WARNING
1232
            );
1233
1234
            // @codeCoverageIgnoreStart
1235
            // Return quoted value for safety
1236
            $val = stripslashes($val);
1237
            return $this->conn->qstr($val, false);
1238
            // @codeCoverageIgnoreEnd
1239
        }
1240
1241
        $type = $this->metaColumn[$table][$col]->type;
1242
        if (in_array(
1243
            $type,
1244
            [
1245
                'bigint',
1246
                'bit',
1247
                'decimal',
1248
                'double',
1249
                'float',
1250
                'int',
1251
                'intn',     // Sybase - tinyint
1252
                'mediumint',
1253
                'numeric',
1254
                'numericn', // Sybase - numeric
1255
                'real',
1256
                'smallint',
1257
                'tinyint',
1258
            ]
1259
        )) {
1260
            // Need not quote, output directly
1261
            return $val;
1262
1263
        } elseif ($this->isDbSybase() && 'timestamp' == $type) {
1264
            // Sybase timestamp
1265
            // @codeCoverageIgnoreStart
1266
            return '0x' . $val;
1267
            //elseif ($this->IsDbSybase() && 'varbinary' == $type && 'timestamp' == $col)
1268
            // @codeCoverageIgnoreEnd
1269
1270
        } else {
1271
            // Need quote, use db's quote method
1272
            $val = stripslashes($val);
1273
            return $this->conn->qstr($val, false);
1274
        }
1275
    }
1276
1277
1278
    /**