Use the Erase Option to Erase a Record Outside of CMS

5 posts by 3 authors in: Forums > CMS Builder
Last Post: July 13, 2015   (RSS)

By andybarn - July 11, 2015

Hi

I have a client that imports XML feeds into their listings database from 20 + other Agents.

The problem they are having is that there are a number of duplications on properties and it is possible to have listings showing several properties all the same but with different agent reference numbers.

We have written a dedupe type program that looks at 9 fields in the listings table (Town, Property Type, Price, Description, Bedrooms, Bathrooms, Sq Meters Build, Plot size, Pool) and produces a spreadsheet with a worksheet for each number of matches (9 matches, 8 matches etc.). This works well and we have a link in the spreadsheet so the client can view each property to see if it is definite duplication. (It is possible to have 9 matches and still be different as well as have 7 matches and be a duplication so there has to be a manual element involved for final checking)

We run this automatically after the weekly XML import, and  the system sends the client an email with the spreadsheet duplications ready for checking.

We want to increase the number of options on the spreadsheet so the client can not only use a link to view the property but also provide a link to delete the property. We have also added  functions so that we do not re import deleted properties the next time we import the XML feed (stored in a new Exclude database) and we also have a function to clean up the exclude database so that once a property no longer appears on the XML import we can remove from the exclude database.

All of this is working great except for the delete option. I have 2 questions:-

1) Is there a way we can use the functionality of the erase function in the CMS Admin/listings screen to erase/delete the record from outside the admin using a link on the spreadsheet?

2) Please confirm that the erase function in CMS Admin/listings screen, not only erases the record, but also erases any uploads associated with that record and erases any Permalinks associated with that record.

Thank you for your help.

Kind regards

Andy

By gregThomas - July 13, 2015

Hey Andy,

You can recreate the delete function with two function calls:

  //Remove the uploads first
  removeUploads("`recordNum` = '5' AND `tableName` = 'blog'");
 
  //Next remove the record itself
  mysql_delete('blog', 5);

So the code above would remove record num 5 from the section blog after it's deleted any uploads associated with the record. The function removeUpload's variable is a where string for the uploads table for the uploads you want to delete. The mysql_delete function takes the tablename as its first variable, and the record number as the second. 

I'd recommend making a full backup of the database before testing out these functions. 

Thanks,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By gkornbluth - July 13, 2015

Hi Andy,

Well, that sounds easier, and certainly cleaner, but still a dangerous approach IMHO

I think security and vulnerability will be the larger concern.

Still, I was glad to learn about the removeUploads function.

Best,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By andybarn - July 13, 2015

Thanks Greg (and Jerry for your input)

That looks pretty straight forward and could be exactly what I was looking for. I will give it a go.

As always great support!

Thanks again

Andy