fr34k Posted August 4, 2008 Share Posted August 4, 2008 I'm connecting to a database using the following method: $connection = new COM("ADODB.Connection"); $connection->open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\path\to\my\database.mdb;"); I'm pretty much stuck with using Access and linking straight to the file in the connection string. Using this connection, I want to be able to utilize parameterized queries/prepared statements. I can't figure out how, exactly, to do this. I haven't even really found anything coherent on doing this in PHP with an Access MDB. I have found articles on doing this in ASP, but my efforts to port the code have been fruitless. Any help would be immensely appreciated! Link to comment https://forums.phpfreaks.com/topic/118030-solved-using-parameterized-queries-on-an-mdb/ Share on other sites More sharing options...
cooldude832 Posted August 4, 2008 Share Posted August 4, 2008 majority of PHP users run MySQL or Oracle or PROTEGSQL there is ODBC interactions with php and those might be of aid. Access is not a database language rather a piece of software to view a database. I do believe it uses ODBC or MSDBC or something like that. Link to comment https://forums.phpfreaks.com/topic/118030-solved-using-parameterized-queries-on-an-mdb/#findComment-607197 Share on other sites More sharing options...
fr34k Posted August 4, 2008 Author Share Posted August 4, 2008 Access is not a database language rather a piece of software to view a database. I didn't mean to imply that Access was a DB language. I was just saying that I'm stuck with using an MDB created from Access, instead of using anything else, like MySQL. there is ODBC interactions with php and those might be of aid. I've tried toying with the ODBC functionality in PHP and haven't met with much success. One thing I attempted to use was odbc_prepare, but couldn't quite get things ironed out. I wish I could give more detail, but the script is currently at the office and I won't be until tomorrow morning. Link to comment https://forums.phpfreaks.com/topic/118030-solved-using-parameterized-queries-on-an-mdb/#findComment-607203 Share on other sites More sharing options...
fr34k Posted August 4, 2008 Author Share Posted August 4, 2008 I've finally figured it out. I still didn't have any luck with odbc_prepare, but I did finally piece ASP ideas into PHP. An example with a long string parameter... <? $dbConn = new COM("ADODB.Connection") or die("Cannot start ADO connection"); $dbCmd = new COM("ADODB.Command") or die("Cannot create ADO command object"); $dbConn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\\path\\to\\my\\database.mdb"); $dbCmd->ActiveConnection = $dbConn; $param1 = $dbCmd->CreateParameter("@param1", 201, 1, strlen($param1Value), $param1Value); $dbCmd->CommandText = "UPDATE table SET field = @param1 WHERE ID = " . $recordId; $dbCmd->Parameters->Append($param1); $dbCmd->Execute(); ?> Link to comment https://forums.phpfreaks.com/topic/118030-solved-using-parameterized-queries-on-an-mdb/#findComment-607601 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.