This is a discussion on Serching of products correspondence within the PHP Language forums, part of the PHP Programming Forums category; Hello. I have gotten the problem. I have two tables with products in mysql database. I need to code php ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello.
I have gotten the problem. I have two tables with products in mysql database. I need to code php script that will connect products by name. But names can be some different (like another words order, or additional spaces, commas, dephises ect.) Can someone recommend me php class of show some example how to do this? Thanks. |
|
|||
|
tower.grv@gmail.com wrote:
> Hello. > > I have gotten the problem. > I have two tables with products in mysql database. I need to code php > script that will connect products by name. > But names can be some different (like another words order, or > additional spaces, commas, dephises ect.) > > Can someone recommend me php class of show some example how to do > this? > > Thanks. > Could be tricky depending on how different the names are, but you can use MySQL's LIKE function and perhaps it's REPLACE and REGEX options, you might be best asking in a SQL newsgroup. Try selecting into another table, then export the two tables into a spreadsheet and manually compare afterwards for things that might be missed or wrong. |
|
|||
|
On 28 Sep, 11:17, Tyno Gendo <nob...@example.com> wrote:
> tower....@gmail.com wrote: > > Hello. > > > I have gotten the problem. > > I have two tables with products in mysql database. I need to code php > > script that will connect products by name. > > But names can be some different (like another words order, or > > additional spaces, commas, dephises ect.) > > > Can someone recommend me php class of show some example how to do > > this? > > > Thanks. > > Could be tricky depending on how different the names are, but you can > use MySQL's LIKE function and perhaps it's REPLACE and REGEX options, > you might be best asking in a SQL newsgroup. > > Try selecting into another table, then export the two tables into a > spreadsheet and manually compare afterwards for things that might be > missed or wrong. Certainly it depends what the OP means by 'connect', if it's 'join' then it should be at the database level - but that's a workaround of the real problem where the same physical entity is described by different labels in different contexts. C. |
|
|||
|
tower.grv@gmail.com wrote:
> Hello. > > I have gotten the problem. > I have two tables with products in mysql database. I need to code php > script that will connect products by name. > But names can be some different (like another words order, or > additional spaces, commas, dephises ect.) > > Can someone recommend me php class of show some example how to do > this? > > Thanks. > You should be doing it in SQL, not PHP. Try comp.databases.mysql. And it sounds like you need to normalize your database. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|||
|
Based on your description, I would assign a canonical name to each
product in the database and then match against that. For items not matched in this step, you can try using the metaphone algorithm on the canonical name. This can help detect some types of spelling errors. Any remaining items with no unique match could be handled manually. <? function canonicalName($name) { $name = preg_replace('/[^0-9a-z\s]/i', '', $name); $words = preg_split('/\s/s', $name, -1, PREG_SPLIT_NO_EMPTY); sort($words); return join(' ', $words); } $cName = canonicalName("Barbie Funhouse"); $metaphone = metaphone($cName); echo "cName = $cName, metaphon = $metaphone\n"; $cName = canonicalName("Funhouse Barbie!"); $metaphone = metaphone($cName); echo "cName = $cName, metaphon = $metaphone\n"; ?> The above outputs: cName = Barbie Funhouse, metaphone = BRBFNHS cName = Barbie Funhouse, metaphone = BRBFNHS You can update each product with a cName and metaphone field. On Sep 28, 5:07 am, "tower....@gmail.com" <tower....@gmail.com> wrote: > Hello. > > I have gotten the problem. > I have two tables with products in mysql database. I need to code php > script that will connect products by name. > But names can be some different (like another words order, or > additional spaces, commas, dephises ect.) > > Can someone recommend me php class of show some example how to do > this? > > Thanks. |