Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As mentioned in some of the comments, flatfiles are not the best solution for this type of problem, but as you mentioned sometimes it's just easier (and cheaper) to use what's already there and move onto other features.</p> <p>If you were using a database, you could add a unique constraint on columns where you don't want duplicate data to appear, and this de-dupping capability is handled for you at the database layer. Although you would have to handle the error returned when it attempted to do an insert, its a more elegant solution.</p> <p>However, if you want to move forward with your CSV solution you will have to parse the existing CSV and extrapolate out the existing addresses, then you can check if the form submitted address already exists.</p> <pre><code>// Pseduo code User submits form Open up existing CSV file Step through each entry in csv file Store Address in $addresses[] array Check if user submitted address exists in $addresses[] array </code></pre> <p>As you can see this solution is non-performant, in that you will have to open, parse, and check every time the form is submitted, however it should accomplish your goal.</p> <p>Let me know if the psuedo code isn't enough, I can code it out.</p> <p>--Edit--</p> <p>Below are a few links to get you started on how to integrate a database solution to solve your problem. These are just to get you started, as there is a wealth of information on the subject:</p> <p>Database design: <a href="http://en.wikipedia.org/wiki/Database_design" rel="nofollow">http://en.wikipedia.org/wiki/Database_design</a></p> <p>Vanilla interaction with database (using PHP): <a href="http://php.net/manual/en/book.pdo.php" rel="nofollow">http://php.net/manual/en/book.pdo.php</a></p> <p>ORM interaction with database (using PHP): <a href="http://www.doctrine-project.org/" rel="nofollow">http://www.doctrine-project.org/</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload