}
plc->freeq = 1;
} else {
+ enum pdo_param_type param_type = param->param_type;
zend_string *buf = NULL;
- switch (param->param_type) {
+ /* assume all types are nullable */
+ if (Z_TYPE_P(parameter) == IS_NULL) {
+ param_type = PDO_PARAM_NULL;
+ }
+
+ switch (param_type) {
case PDO_PARAM_BOOL:
plc->quoted = zend_is_true(parameter) ? "1" : "0";
plc->qlen = sizeof("1")-1;
buf = zval_get_string(parameter);
if (!stmt->dbh->methods->quoter(stmt->dbh, ZSTR_VAL(buf),
ZSTR_LEN(buf), &plc->quoted, &plc->qlen,
- param->param_type)) {
+ param_type)) {
/* bork */
ret = -1;
strncpy(stmt->error_code, stmt->dbh->error_code, 6);
}
plc->freeq = 1;
} else {
+ enum pdo_param_type param_type = param->param_type;
zend_string *buf = NULL;
- switch (param->param_type) {
+ /* assume all types are nullable */
+ if (Z_TYPE_P(parameter) == IS_NULL) {
+ param_type = PDO_PARAM_NULL;
+ }
+
+ switch (param_type) {
case PDO_PARAM_BOOL:
plc->quoted = zend_is_true(parameter) ? "1" : "0";
plc->qlen = sizeof("1")-1;
buf = zval_get_string(parameter);
if (!stmt->dbh->methods->quoter(stmt->dbh, ZSTR_VAL(buf),
ZSTR_LEN(buf), &plc->quoted, &plc->qlen,
- param->param_type)) {
+ param_type)) {
/* bork */
ret = -1;
strncpy(stmt->error_code, stmt->dbh->error_code, 6);
echo "===INSERT===\n";
$stmt = $db->prepare('INSERT INTO test VALUES(:id, :classtype, :val)');
+$stmt->bindParam(':id', $idx);
+$stmt->bindParam(':classtype', $ctype);
+$stmt->bindParam(':val', $val);
foreach($objs as $idx => $obj)
{
$ctype = $ctypes[get_class($obj)];
-
- $stmt->bindValue(':id', $idx);
- $stmt->bindValue(':classtype', $ctype, $ctype === null ? PDO::PARAM_NULL : PDO::PARAM_INT);
- $stmt->bindValue(':val', method_exists($obj, 'serialize') ? $obj->serialize() : '');
-
- $stmt->execute();
+ if (method_exists($obj, 'serialize'))
+ {
+ $val = $obj->serialize();
+ }
+ else
+ {
+ $val = '';
+ }
+ $stmt->execute();
}
unset($stmt);
printf("NULL...\n");
$stmt = $db->prepare('INSERT INTO test(id, label) VALUES (100, ?)');
$label = null;
- if (!$stmt->bindParam(1, $label, PDO::PARAM_NULL))
+ if (!$stmt->bindParam(1, $label))
printf("[%03d + 4] Cannot bind parameter, %s %s\n", $offset,
$stmt->errorCode(), var_export($stmt->errorInfo(), true));
$stmt->execute() or var_dump($stmt->errorInfo());
$bar = null;
-$stmt->bindParam(':bar', $bar, PDO::PARAM_NULL);
+$stmt->bindParam(':bar', $bar);
$stmt->execute() or var_dump($stmt->errorInfo());
$bar = 'qaz';