2

Closed

ADODB AutoExecute() problem with mssqlnative driver

description

Hi,

I'm trying to use this new driver with adodb5.11(latest version) and everything works fine except when using AutoExecute().
This happens because &FetchField() (file -> adodb-mssqlnative.inc.php) doesn't return the right values to construct the query.
It should return the name, type and max_lenght of a field but instead it's returning the value posted to that same field.....
Using the old mssql driver, this works just fine

mssqlnative uses this:
$arrKeys = array_keys($this->fields);
$f = $this->fields[$arrKeys[$this->fieldOffset]]; //this only returns the current field value

mssql uses:
$f = @mssql_fetch_field($this->_queryID, $fieldOffset); //this works fine

So, what am i doing wrong????????????
I'm a newbie so please go easy on me....

P.S.1: The attached file has a little modification i made to the &FetchField() function. It works but i don't know if it's the best option...
P.S.2: I'm Portuguese, sorry for my english....

file attachments

Closed Dec 30, 2011 at 8:50 PM by
Looks like the issue was resolved by a workaround in the application.

comments

dolphy17 wrote Dec 27, 2011 at 7:04 PM

Hi dev,

Is there any update available on this issue?
It's quite a breaking one and should be prioritised I think.

Thanks,
Dolphy

dolphy17 wrote Dec 27, 2011 at 7:26 PM

Situation is a bit better in ADOdb 5.14, but FetchField() still not populates type field in the return object correctly. Quick fix should be something like: (in FetchField() at adodb-mssqlnative.inc.php:705)
...
} else {
$f = new ADOFetchObj();
$f->name = $arrKeys[$this->fieldOffset];
$f->type = gettype($this->fields[$f->name]);
if($fieldOffset == -1) $this->fieldOffset++;
}
...

deoid wrote Dec 27, 2011 at 7:37 PM

Hi.

I don't think theres a fix for this, it happens using ADODB class, so the problem is in this class. The driver itself works fine.

Recently i tried the new versions of this driver (2.0 and 3.0), with ADODB 5.14 and the problem still exists, so i'm still using my modified adodb-mssqlnative.inc.php file, available here as attachment.
It's being used in many professional projects and so far theres no problem with it.

dolphy17 wrote Dec 27, 2011 at 8:03 PM

Thanks deoid.
Your driver works fine to me.

jguerin wrote Dec 30, 2011 at 8:49 PM

Hi Dolphy,

In order for us to be able to reproduce this problem, we would require the functions which are being called on the driver itself (sqlsrv_), the expected result, and the result you are receiving.

Would you be able to provide and example of this behavior so that we can investigate this?

Thanks,

Jonathan

dolphy17 wrote Dec 30, 2011 at 9:14 PM

Why did you close the issue?
This is not a bug in the application, this is a blocking issue in the framework's driver.

Basically, nobody can use the AutoExecute() functionality with this driver currenty.

Usage example:
...
$row['user_email'] = $this->email;
$row['user_testemail'] = $this->testemail;
$row['user_default_subject'] = $this->default_subject;
$this->db->AutoExecute($table, $row, 'UPDATE', "user_id=".$this->id);

Crashes and throws exception.

jguerin wrote Dec 30, 2011 at 9:47 PM

Hi Dolphy,

If this is an issue with AODB, you will have to file the issue with them in order to get it resolved (I don't think they check here :-)). If you believe that the issue exists in the SQLSRV driver, we would require more information.

In order for us to be able to reproduce this problem, we would require the functions which are being called on the driver itself (sqlsrv_), the expected result, and the result you are observing.

Thanks,

Jonathan

dolphy17 wrote Dec 30, 2011 at 10:15 PM

Apols, I got your point now. It's definitely a problem in ADOdb, not in MS' driver.
I'll file an issue there.
Thanks

deoid wrote Dec 31, 2011 at 12:23 AM

Actually, the sqlsrv driver might have a problem...
The ADODB driver for mssql-native has several flaws, i already posted then in their forum, but theres something about 'sqlsrv_field_metadata' that i don't understand.

The AutoExecute needs to know the field name, type and size in order to construct a query.
In mssql 'mssql_fetch_field' is used to get this data, and works just fine.
Mssql-native however uses 'sqlsrv_field_metadata' and it doesn't return the field type correctly.

Here http://msdn.microsoft.com/en-us/library/cc296197.aspx, we can see that Type is an numeric ID, and this ID's don't match with SQLSERVER sys.types.
My workaround on ADODB driver uses an array to link this ID's with the proper sqlserver type and it works fine, but i don't think that's the best option...

And please, correct me if i'm wrong on this matter, a better solution is always welcome :-)

PS: again, sorry for my english...

jguerin wrote Jan 12, 2012 at 8:28 PM

Deoid,

Thanks for the feedback! The Enumeration of the types is documented here:
http://msdn.microsoft.com/en-us/library/cc296183.aspx

You are correct that they do not necessarily match the sys.types, and we have filed your suggestion for evaluation in future driver releases.

Thanks,

Jonathan