Hi Armin and other pmapper users,
join with mdb file now works correctly, great. (but i've got a question, see
more over)
I text some little rules if anybody needs to join a SHAPE dbf file to an mdb
file
(tested on win xp, ms4w, and pmapper 1.2.0):
- DSN to mdb file must be a SYSTEM DSN, just enter control panel > admin
tools > ODBC to create it
- syntax for map file in the example of pmapper documentation is correct, if
it doesn't work must be something else (check DB connection, see the last
point)
- join doesn't work with one2many relation, ONLY with one2one relation
- join doesn't work with TEXT fields, i tried NUMERIC and it goes
- add the joined field headers in the "RESULT HEADERS" tag
- control error log file if connection is refused
- to check if PEAR connection works create this .phtml file and run it:
<?php require_once('DB.php');
$dsn = "odbc://'':''/localhost a name_of_system_dsn";
$dbh = DB::connect($dsn);
if (DB::isError($dbh)) {
die ($dbh->getMessage());
}
?>
result page must be white (otherwise some connection error message appears)
------------------------------------------
Question:
why join doesn't work with text fields?
Thanks and goodbye,
antonio
----- Original Message -----
From: Armin Burger
To: toni
Cc: pmapper-users a faunalia.it
Sent: Friday, April 28, 2006 8:31 AM
Subject: Re: [Pmapper-users] R: join a mdb file with odbc
I guess it is related to an empty query result. This might be a bug in
pmapper, in principal it should check if the returned array is really an
array and if it is not empty.
Try to modify line 220 to
if ($dbresCount > 0 && is_array($data)) {
and see if the problem remains. And try what you get if you write out the
$data with print_r() (the line should already be there, but commented out).
A 1-n join became a bit more complicated to implement when I changed the
whole query part. It would break some of the current logics and needs a
slightly deeper code modification. Since I do not use joins any more I will
not tackle this problem very soon, I guess.
Armin
> --- Urspr?ngliche Nachricht ---
> Von: "toni" <fiorenontaglio a libero.it>
> An: <pmapper-users a faunalia.it>
> Betreff: [Pmapper-users] R: join a mdb file with odbc
> Datum: Fri, 28 Apr 2006 00:00:16 +0200
>
> Dear Armin,
> I made a SYSTEM DSN and some new error message appeared in the query
> result
> window:
>
> Warning: Cannot use a scalar value as an array in
> C:\ms4w\Apache\htdocs\pmapper\incphp\query\squery.php on line 222
>
> Warning: Invalid argument supplied for foreach() in
> C:\ms4w\Apache\htdocs\pmapper\incphp\query\squery.php on line 222
>
> In the previous mailing list is told this error is connected with one2many
> joins. I tried with a one2one join but I have the same error result.
> I tried with lower-case names of tables and fields but it's the same.
>
> However I really need one2many join. Anybody made a patch for the
> squery.php
> file? (I don't know PHP code)
>
> ----------------------------
>
> Here is the new command lines in MAP file:
>
> "RESULT_JOIN" "odbc://'':''/localhost a turbo||situazip a [EMAIL PROTECTED] a
> qua||IDP||0"
>
> "RESULT_JOIN" "odbc://'':''/localhost a turbo||situazif a [EMAIL PROTECTED] a
> cons||IDF||1"
>
> where 'turbo' is a SYSTEM DNS connected to a mdb file
>
>
> Thanks again,
> antonio
>
>
>
> >----- Original Message -----
> >From: Armin Burger
> >To: toni
> >Cc: pmapper-users a faunalia.it
> >Sent: Thursday, April 27, 2006 9:41 PM
> >Subject: Re: [Pmapper-users] join a mdb file with odbc
> >
> >
> >did you try if the connection via pure PHP/PEAR to your ODBC connection
> >is working correctly? And try best via a Web page, not just a command
> >line run of the PHP script. Like
> >
> >$dsn = "odbc://'':''/localhost a daticatastali";
> >$dbh = DB::connect($dsn);
> >if (DB::isError($dbh)) {
> > die ($dbh->getMessage());
> >}
> >
> >That is the first step to check, since pmapper does not have lots of
> >debugging to work with databases and joins. In your case it looks like a
> >not correctly set definition of the connection parameters. It stems from
> >the call
> >
> >$dbh = $this->dbConnect($dsn);
> >if (!$dbh) error_log ...
> >
> >A DSN file is not required and I don't know what it should contain. As
> >long as you have not set a password, user and password string remain
> >empty ('').
> >
> >I have not used joins since some time, but 1-to-1 should work (1-to-many
> >will not work corrcetly).
> >
> >I have an old definition that is
> >
> >"odbc://'':''/myserver a peartest||corine a [EMAIL PROTECTED] a
> >landcover||CODE||0"
> >
> >where 'peartest' is the ODBC definition ('Data Source Name') defined in
> >Windows ODBC Admin (I think it has to be a *SYSTEM* DSN). 'corine' is a
> >table in the mdb file. 'code' is the join field in the ODBC table,
> >'CODE' the join field in the shapefile dbf.
> >
> >armin
> >
> >toni wrote:
> > Hello everybody,
> > i'm in troubles and i hope you can help me.
> >
> > I'm a beginner in pmapper and i have to solve a problem with a join to
> an
> > external ms-access database: join doesn't work, more over are the
> > explanations.
> > I've read the whole newsletter but usually talks about problems with
> > postgres and there are no useful examples for me. Even PEAR manual is
> too
> > short.
> >
> > My machine (os: win xp) runs Mapserver for Windows (MS4W) v. 1.5.0 (the
> > package as is) and I've installed pmapper v.1.2.0 following the
> instructions
> > in the documentation
> >
> > ------------------------------
> > This is the layer interested in the join (map file extract):
> >
> > # Start of Layer fabbricati
> > #
> > LAYER
> > NAME "fabbricatiGBO"
> > TYPE polygon
> > DATA "fabbricatiGBO"
> > METADATA
> > "DESCRIPTION" "fabbricati"
> > "RESULT_FIELDS" "IDF,FABBRI_N,FABBRI_T,FOGLIO_N,FOGLIO_T,ID1"
> > "RESULT_HEADERS" "Idf,Fabbri_n,Fabbri_t,Foglio_n,Foglio_t,Id1"
> > "RESULT_JOIN"
> > "odbc://'':''/localhost a daticatastali||SITUAZIF a [EMAIL PROTECTED] a
> > Cons||IDF||1"
> > END # Metadata
> > CLASS
> > Name 'fabbricati'
> > COLOR 252 205 104
> > OUTLINECOLOR 0 0 0
> > TEMPLATE void
> > END # Class
> > END # Layer
> >
> > ------------------------------
> > Here is the error in the error log file:
> >
> > [27-Apr-2006 18:05:15] Could not connect to DB defined for Layer
> > 'fabbricatiGBO'. Check map file entry for JOIN definition.
> >
> > ------------------------------
> > What i did:
> >
> > I created a DSN file named 'daticatastali.dsn' pointing to the ms-access
> > database, but i don't know where to put it and if it has the right
> content.
> > Then I even created a user DSN.
> > I checked if PEAR's DB module was installed and i found it in
> > c:\ms4w\Apache\php\PEAR\DB
> > I tried to change the syntax in many ways but unsuccessfully.
> > I controlled that filed names were right.
> >
> > ------------------------------
> > My questions:
> >
> > What's the right syntax for the "RESULT_JOIN" instruction?
> > Am I in the correct way?
> > Where i put the dsn file?
> > Do I have to use username 'admin' or change slashes or paths?
> >
> >
> > Thanks in advance
> > Greetings, antonio
> >
> >
> > _______________________________________________
> > Pmapper-users mailing list
> > Pmapper-users a faunalia.it
> > http://faunalia.it/cgi-bin/mailman/listinfo/pmapper-users
> >
> >
>
>
> _______________________________________________
> Pmapper-users mailing list
> Pmapper-users a faunalia.it
> http://faunalia.it/cgi-bin/mailman/listinfo/pmapper-users
>
--
Analog-/ISDN-Nutzer sparen mit GMX SmartSurfer bis zu 70%!
Kostenlos downloaden: http://www.gmx.net/de/go/smartsurfer