FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Query *.mdb file with ODBC functions
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Query *.mdb file with ODBC functions [message #170281] Tue, 26 October 2010 15:20 Go to previous message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma:
Senior Member
Sometimes I'm handled data in a Microsoft Access database and I need to
manipulate it. I only have an old copy of Access 2000, I'm not
proficient with it, I don't know the query syntax and I hate its GUI to
the bone. In the past, I used to migrate data to another DBMS, do stuff
there and then port back to the original file, but it's an error-prone
and time-consuming method.

I've found that writing a simple PHP script with the ODBC functions (I
have a Windows box) can ease the task a lot. However, I have two
important questions so far:

1.- What exact SQL dialect does the JET engine expect? I'd appreciate a
link to MSDN or something with an explanation of basic syntax and
available functions.

2. How am I supposed to escape input data? PHP ODBC functions provide
parametrized queries but I can't make them work:

$data = array(
100 => 'Foo St.',
101 => 'Bar Ave.',
);
$sql = 'UPDATE street
SET name=?
WHERE code=?';
$stmt = odbc_prepare($conexion, $sql);
if( $stmt===FALSE ){
die(odbc_errormsg());
}
foreach($data as $code => $name){
if( !odbc_execute($stmt, array($name, $code)) ){
die(odbc_errormsg()); // SQL state 07001 Wrong number of parameters
}
}

Some user comments in the PHP manual suggest that parametrized queries
are not supported by the Access driver :-?



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Timezone is changing to default
Next Topic: Syntax for adding text prefix to a post variable?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 20 20:30:03 GMT 2024

Total time taken to generate the page: 0.03002 seconds