Re: [PHP-DB] How to Sync MySQL with iPhone or Google Contacts
Karl / Andrés Thanks for your replies. iMy appears to be only a client and I can already access servers with php on the iPhone web browser. I would like MySQL on my iPhone. There was a way to make a jailbroke iPhone a MySQL server, but I'm not sure it is available any longer. My immediate desire is to sync the iPhone's native contacts and, perhaps, the calendar with our online server over the internet. Preferably syncs would be pushed. With a Google Gmail account, you can already do just exactly that. Once set up, if you update your Gmail contacts, a minute or two later your iPhone contacts will be sync'd. It's supposed to work with the Google calendar, too, but I haven't tried it. It appears that Google is using a MS Exchange Server or similar. The setup in the iPhone uses the Exchange server settings. See http://www.google.com/mobile/sync/ The solution I'm looking for would be server side -- if not completely, in part. Again, it would be best to sync directly to the iPhone, but if the server would sync with the Google calendar and Google sync'd with the iPhone, that would be an acceptable 2nd choice. Thanks again for your reply! - Ron On 10/23/2010 5:47 AM, Andrés G. Montañez wrote Hi Ron, what's what you want to sync? Contacts? Or everything else? You want to sync it over the internet? Or over wire? You should research the iPhone API/SDK for sync; and not focus with MySQL, wich is just an storage. Cheers. On 23 October 2010 03:09, Karl DeSaulniersk...@designdrumm.com wrote: I believe there is a MySQL for the iphone iMy? http://forums.mysql.com/read.php?58,249718,249718 You'd probably want o use JASON or an equiv. to talk back and forth with your database and app. At least thats the consensus I'm finding on posts about it. HTH Karl On Oct 22, 2010, at 11:21 PM, listread wrote: Hey all! Does anyone know how to go about syncing a MySQL db with an iPhone over the internet? An alternative would be syncing with Google Contacts, which then could sync with the iPhone. I think Google Contacts uses Exchange Server to sync with devices. Thanks! - Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Karl DeSaulniers Design Drumm http://designdrumm.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] How to Sync MySQL with iPhone or Google Contacts
Andrés, It would be tempting to build an app for this, but we don't have a single Mac in the place. Maybe syncing with Google is the way to go? That would keep the iPhone out of the equation. (This is not intended for the market.) Thanks, - Ron On 10/23/2010 2:16 PM, Andrés G. Montañez wrote: Hi Ron, watchout with the jailbrake becaous it will void your warranty over the iphone. If you want to sync the phone's contact with something, you really should check the iphone API and build an iphone application which hooks and listens for contact's change and then notify the changes to your server. I know building an iphone app is a pain, but I think its the right way to do it, if not the only. Is this need for a hobbie or you need to implement this for a public application? Cheers. On 23 October 2010 13:57, listreadlistr...@cze.com wrote: Karl / Andrés Thanks for your replies. iMy appears to be only a client and I can already access servers with php on the iPhone web browser. I would like MySQL on my iPhone. There was a way to make a jailbroke iPhone a MySQL server, but I'm not sure it is available any longer. My immediate desire is to sync the iPhone's native contacts and, perhaps, the calendar with our online server over the internet. Preferably syncs would be pushed. With a Google Gmail account, you can already do just exactly that. Once set up, if you update your Gmail contacts, a minute or two later your iPhone contacts will be sync'd. It's supposed to work with the Google calendar, too, but I haven't tried it. It appears that Google is using a MS Exchange Server or similar. The setup in the iPhone uses the Exchange server settings. See http://www.google.com/mobile/sync/ The solution I'm looking for would be server side -- if not completely, in part. Again, it would be best to sync directly to the iPhone, but if the server would sync with the Google calendar and Google sync'd with the iPhone, that would be an acceptable 2nd choice. Thanks again for your reply! - Ron On 10/23/2010 5:47 AM, Andrés G. Montañez wrote Hi Ron, what's what you want to sync? Contacts? Or everything else? You want to sync it over the internet? Or over wire? You should research the iPhone API/SDK for sync; and not focus with MySQL, wich is just an storage. Cheers. On 23 October 2010 03:09, Karl DeSaulniersk...@designdrumm.comwrote: I believe there is a MySQL for the iphone iMy? http://forums.mysql.com/read.php?58,249718,249718 You'd probably want o use JASON or an equiv. to talk back and forth with your database and app. At least thats the consensus I'm finding on posts about it. HTH Karl On Oct 22, 2010, at 11:21 PM, listread wrote: Hey all! Does anyone know how to go about syncing a MySQL db with an iPhone over the internet? An alternative would be syncing with Google Contacts, which then could sync with the iPhone. I think Google Contacts uses Exchange Server to sync with devices. Thanks! - Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Karl DeSaulniers Design Drumm http://designdrumm.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] How to Sync MySQL with iPhone or Google Contacts
Hey all! Does anyone know how to go about syncing a MySQL db with an iPhone over the internet? An alternative would be syncing with Google Contacts, which then could sync with the iPhone. I think Google Contacts uses Exchange Server to sync with devices. Thanks! - Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] calling a page for each row
We need to load a page which performs some tasks specific to each record, including writing some results to another table. I have tried to place a page loading script within the while loop that creates the table, but it seems to only load the page on the last record in the table. Is there a better way to do this? Thanks! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] calling a page for each row
On 7/15/2010 8:03 PM, Chris wrote: On 16/07/10 09:51, listread wrote: On 7/15/2010 6:42 PM, Chris wrote: On 16/07/10 09:38, listread wrote: We need to load a page which performs some tasks specific to each record, including writing some results to another table. I have tried to place a page loading script within the while loop that creates the table, but it seems to only load the page on the last record in the table. Is there a better way to do this? Why does it need to call a page to do all the work? If it was just a function call you'd be off and racing already. The page I want to call is a little involved. It makes a geocode request from Google Maps and then parses the resulting json code and then writes the parsed data to another table. I guess it could be done with functions, but the other page was already written... :-) I guess you could do a file_get_contents on the url of the page. If I call a function, will the while loop wait for the function to complete before going to the next row? Yes. I'll see if I can imbed the page as functions... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] How to use PHP to fill in existing pdf document
Greetings PHP gurus! Does anyone know of a way to use PHP to fill in the form fields in an existing pdf document residing on the server? We want the end result to be the creation of a unique pdf document for each visitor which can either be emailed or stored in a directory on the server. We prefer to do this without any server side dependencies, other than files residing on the website. Thanks in advance for your help. - Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] How to use PHP to fill in existing pdf document
Yes, we can first ask the user to fill in a form, but then comes the part I don't understand - how to covert it to pdf. It would be best if we could just fill in the fields on an existing form, but it would also work to print the printer friendly form to the server's printer queue, which could really be a postscript file we could then convert to pdf. In that case, I need to learn how to get PHP to print to the server's printer... - Ron On 5/1/2010 7:53 AM, nagendra prasad wrote: I am not sure if this works for your project but you can first ask user to fill the form in PHP and then convert it into PDF. What say? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] How to use PHP to fill in existing pdf document
Yes, I've looked hard at fdpf and see how it is used to generate a new pdf, but I need to simply fill in the form fields in an existing pdf. If it can do that, I'm not finding the feature Thanks, - Ron On 5/1/2010 7:43 PM, Gary wrote: listreadlistr...@cze.com wrote in message news:4bdc9ced.3060...@cze.com... Yes, we can first ask the user to fill in a form, but then comes the part I don't understand - how to covert it to pdf. It would be best if we could just fill in the fields on an existing form, but it would also work to print the printer friendly form to the server's printer queue, which could really be a postscript file we could then convert to pdf. In that case, I need to learn how to get PHP to print to the server's printer... - Ron On 5/1/2010 7:53 AM, nagendra prasad wrote: I am not sure if this works for your project but you can first ask user to fill the form in PHP and then convert it into PDF. What say? __ Information from ESET Smart Security, version of virus signature database 5078 (20100501) __ The message was checked by ESET Smart Security. http://www.eset.com Ron Take a peek at this http://fpdf.org/ Writing to a pdf from php is very cumbersome, this seems to take some of the sting out. Gary __ Information from ESET Smart Security, version of virus signature database 5078 (20100501) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Building indexes
This all helps. I think I need to spend some time experimenting. Thanks for your help! - Ron On 3/19/2010 3:56 PM, Bastien Koert wrote: [snip] Here's an example of a tough query (there are lots of Smiths!). SELECT voter1.County, voter1.`First Name`, voter1.`Middle Name`, voter1.`Last Name`, voter1.`Residential ZipCode`,voter1.`House Number`, voter1.`Mailing Address`, voter1.`Street Name`, voter1.`Residential City`, voter1.`Voter ID`, voter1.`Congressional Distri`,voter1.idVoter, voter1.County FROM voter1 WHERE voter1.`County` LIKE '%' AND voter1.`Last Name` LIKE 'Smith%' AND voter1.`First Name` LIKE 'John%' AND voter1.`Residential ZipCode` LIKE '%' LIMIT 0, 10; Do you think the LIKE '%' hurts for the fields we don't have search criteria? We do that to keep the query definition simple and flexible. [/snip] Yes, those hurt and will cause you endless grief. A much better course of action is to build the SQL dynamically to only query on the fields where you have values to start with. If I alter your example SELECT voter1.County, voter1.`First Name`, voter1.`Middle Name`, voter1.`Last Name`, voter1.`Residential ZipCode`,voter1.`House Number`, voter1.`Mailing Address`, voter1.`Street Name`, voter1.`Residential City`, voter1.`Voter ID`, voter1.`Congressional Distri`,voter1.idVoter, voter1.County FROM voter1 WHERE voter1.`Last Name` LIKE 'Smith%' AND voter1.`First Name` LIKE 'John%' LIMIT 0, 10; This produces a much cleaner SQL and simpler query for the DB to use. Also, I tend to prefer not using spaces in the field names. I prefer to have an underscore to avoid any issues if I ever have to move databases -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Building indexes
On 3/18/2010 4:59 PM, Chris wrote: What do your queries end up looking like? Here's an example of a tough query (there are lots of Smiths!). SELECT voter1.County, voter1.`First Name`, voter1.`Middle Name`, voter1.`Last Name`, voter1.`Residential ZipCode`,voter1.`House Number`, voter1.`Mailing Address`, voter1.`Street Name`, voter1.`Residential City`, voter1.`Voter ID`, voter1.`Congressional Distri`,voter1.idVoter, voter1.County FROM voter1 WHERE voter1.`County` LIKE '%' AND voter1.`Last Name` LIKE 'Smith%' AND voter1.`First Name` LIKE 'John%' AND voter1.`Residential ZipCode` LIKE '%' LIMIT 0, 10; Do you think the LIKE '%' hurts for the fields we don't have search criteria? We do that to keep the query definition simple and flexible. More upfront db prep can be justified since we have to do two or three hundred thousand queries in the course of validating all the signatures on a petition. Thanks! - Ron listread wrote: Chris, I just assumed that everyone on this list was using MySQL... That's what we're using (v. 5.1.45 GA) with InnoDB as the engine. Most people are but there are lots of types of databases out there :) (I just read your tutorial at http://www.designmagick.com/article/16/ It was very helpful - I look forward to checking out more of your articles.) If it is just as efficient to use multiple separate indexes, that would make index building less complicated on our large db. It is, though wildcard searches can't always use indexes. If you do field like 'abcdef%'; then an index can potentially be used because the db (mysql or otherwise) can look at the start of the string to see if it matches. The longer the string the more likely an index can be used (eg doing field like 'a%' probably won't use an index, it'll end up being quicker to scan the actual data). If you do field like '%abcdef%'; then an index can't be used since abcdef could appear anywhere in the string. Without a large dataset, it hard to truly test a system and if you have a large dataset, like we do, it takes quite a while to build indexes. Definitely, it's the best way to test and also the hardest since rebuilding the db takes so long. Our project is a petition signature validation suite. Since many of the handwritten names and addresses on petition sheets are difficult to read, the user needs to be able to do some fuzzy searching. Sometimes it's easier to read the address than it is the name. The zip code is usually easy to read. We almost always need to use LIKE queries, since some part of the name or address is typically hard to read. (We try to use as many of the leading characters as we can and wildcard the remaining.) I'd suggest fulltext but that won't work with innodb, only myisam. You could do something like keep the addresses and names in a separate myisam table just for searching, though that means a whole new import process and also means you'd end up having to do two queries (maybe a subquery or join, you'd have to test) - one do to full text search and one to get the rest of the data based on the result of the first. What do your queries end up looking like? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Building indexes
Chris, I just assumed that everyone on this list was using MySQL... That's what we're using (v. 5.1.45 GA) with InnoDB as the engine. (I just read your tutorial at http://www.designmagick.com/article/16/ It was very helpful - I look forward to checking out more of your articles.) If it is just as efficient to use multiple separate indexes, that would make index building less complicated on our large db. Without a large dataset, it hard to truly test a system and if you have a large dataset, like we do, it takes quite a while to build indexes. Our project is a petition signature validation suite. Since many of the handwritten names and addresses on petition sheets are difficult to read, the user needs to be able to do some fuzzy searching. Sometimes it's easier to read the address than it is the name. The zip code is usually easy to read. We almost always need to use LIKE queries, since some part of the name or address is typically hard to read. (We try to use as many of the leading characters as we can and wildcard the remaining.) For this part of the project joins are not needed. We could eliminate most of the 55 columns, which would reduce the size of the db, but I don't know what that would do to speed... Does any of this affect the approach you would suggest? Thanks!! - Ron On 3/17/2010 11:56 PM, Chris wrote: listread wrote: Greetings! We are working on a 4 million record db with about 55 fields. We need to build indexes to speed queries, but it seems to take way too long. I'm assuming your using mysql but that's just a guess. What database? (mysql, oracle, postgres, firebird, sqlite, other) If it's mysql, what db engine? Here are some questions: 1) If a query uses two or three fields is it best to prepare an index with those two or three fields, or will the query be just as efficient if we build three separate index, one for each field? Relates to above, but assuming mysql then it depends on what version. multicolumn indexes work well in all mysql versions. separate indexes can be used and combined in newer versions (v5 I think it came in). 2) Is the index building process any slower, per index, if you are building more than one index at a time? Most indexing I think takes an exclusive lock on the table, so index 1 gets created, index 2 has to wait it's turn until index 1 finishes. I wrote an article on this a while ago, might give you some more insights: http://www.designmagick.com/article/16/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Building indexes
Greetings! We are working on a 4 million record db with about 55 fields. We need to build indexes to speed queries, but it seems to take way too long. Here are some questions: 1) If a query uses two or three fields is it best to prepare an index with those two or three fields, or will the query be just as efficient if we build three separate index, one for each field? 2) Is the index building process any slower, per index, if you are building more than one index at a time? Does anyone have any suggestions about building indexes? Thanks! - Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] FW: semaphores WAS: [PHP-DB] Automatic logoff
On 1/28/2010 3:57 PM, Richard Quadling wrote: On 28 January 2010 21:38, Daevid Vincentdae...@daevid.com wrote: An intersting synopsis of Semaphores. I've done similar things in the past, but never knew this is what I was doing. LOL. Just like I've built an uber XML parser/editor and didn't know that I actually built a Factory. Ahhh... good old data structures -- they didn't teach these things when I was in college (20+ years ago). I particularly found this part interesting as I hadn't considered this, What you _DON'T_ do, is see if the lock is already there before trying to write one. No need and provides the possibility for another user, using the same code, to be interleaved. I am assuming (and correct me if I'm wrong) as you will get a race condition (on a sufficiently large system) wherein, two users check is there a directory lock, and the system responds No to each, and then the code attempts to create a directory. Then one of them gets a lock granted (i.e a directory) and since 'there can be only one' [highlander reference] the other one THINKS they got the lock (too). Doh! What happens in code depends upon the code. If the code doesn't test the result of assigning the lock, then there is no lock. Every write will overwrite whatever was previously written if all users use the same code. And there is the major flaw of distributed or client initiated semaphoring. It is entirely possible for you to open up your DB gui tool and amend the data. Completely bypassing the semaphoring. Would this support the idea of putting a lock column in the table to be locked? If an admin had cause to go into a table with a DB gui tool, at least he would see the semaphore as a warning. The same table would also simplify code and make the sb more portable. As for speed, you have to query that (those) records to be updated anyway at some point - a special lock table would require another query and if it that lock table was for ALL the other tables in the system, it would be getting more hits than any one table. This has been very educational for me - thanks for the discussion. - Ron So, whilst semaphoring is really useful for long edits, it isn't perfect. But as long as all code use the same semaphoring logic, then it is fine. The wiki page is also interesting and I'd always heard these terms, but never really knew what they were in a practical sense: A mutex is a binary semaphore that usually incorporates extra features, such as ownership, priority inversion protection or recursivity. The differences between mutexes and semaphores are operating system dependent, though mutexes are implemented by specialized and faster routines. Mutexes are meant to be used for mutual exclusion (post/release operation is restricted to thread which called pend/acquire) only and binary semaphores are meant to be used for event notification (post-ability from any thread) and mutual exclusion. Events are also sometimes called event semaphores and are used for event notification. And this also helped to clarify: http://stackoverflow.com/questions/62814/difference-between-binary-semaphor e-and-mutex Ha! Toilets. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] FW: Oracle Finalizes Acquisition of Sun
As an open source product, is the code in the public domain? If so, what's to prevent someone(s) from using it as a starting point and creating YourSQL? On 1/28/2010 7:16 PM, Eric Lee wrote: hmm, that' true now !! Shall the mysql db become paid software !! Regards, Eric, On Thu, Jan 28, 2010 at 11:44 PM, Bastien Koertphps...@gmail.com wrote: [snip] [/snip] PS We will now proceed to fire some 20,000 employees as they will no longer be needed. -- Bastien Cat, the other other white meat -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Automatic logoff
Great explanation, Richard! I think I understand the concept now. I'll study it a little and try to implement it. Thanks! - Ron On 1/28/2010 5:47 AM, Richard Quadling wrote: On 27 January 2010 17:20, listreadlistr...@cze.com wrote: Richard, I think I need to learn about semaphores! Any suggestions for a good tutorial? One of the things we want to do is exclude locked records from a query. Will semaphores provide for that? Thanks! - Ron On 1/27/2010 8:14 AM, Richard Quadling wrote: The technique I've used in the past is semaphore locking, where the semaphore contains the session and the expected expiry time. Follow this. User a starts the process of editing a record. Set the semaphore where there is : a - no existing semaphore - no ongoing edits. b - the semaphore's session is the same - repeat edits by this user in the same session (expired or otherwise). c - the semaphore has expired - the other user simply took too long. If the semaphore cannot be set it will be because of : d - Different non expired session - someone else is editing the record. When a user saves the row, you just remove the semaphore. The semaphores could be in a separate table (rather than on the record itself). Different tables have different number of columns so take different amounts of time to edit, so each table would have a different amount of time from edit to expiry. An entry on a lookup table (just a description) should, in the main, be completed within 30 seconds. But a detail line for a purchase order may take several minutes. You'll have to tune this to your own needs. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php A semaphore is just a flag. Nothing else. You can implement it in any way you like as long as _ALL_ code related to locking uses the semaphores. A common technique for locking files is to create a folder called filename.lck A directory can only exist or not. You try to create the directory. If you did, you got the lock. If not, someone else has. The same approach should be used for DB locking in this manner. You try to place the lock (with the conditions defined in the WHERE clause under which it should succeed). If the lock doesn't get written, then you don't have it. What you _DON'T_ do, is see if the lock is already there before trying to write one. No need and provides the possibility for another user, using the same code, to be interleaved. Also, no need for transactions at this stage too. You put the lock on (if you are allowed to). Now you can edit and re-edit the row until you've finished. This technique is described quite well in http://en.wikipedia.org/wiki/Semaphore_(programming) One of the important aspects to using semaphores is that the process to set (and either succeed or fail) must not be interrupted, hence why you don't try to read the presence of the lock before setting it. I hope that helps some. I used to develop using an old DOS based 4GL called Sage Retrieve 4GL (prior to that it was called Sage Skybase). This uses a modified D-ISAM db structure and semaphores for locking. You'd try to lock a record and process the failure. Quite easy really. By extending this concept to include an expiry time within the lock, you've got your auto-unlock feature written. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Automatic logoff
Richard, One more question (for now): Are there advantages to using a separate table for locking, rather than specifying a lock column in the table you want to lock the row in? - Ron On 1/28/2010 5:47 AM, Richard Quadling wrote: On 27 January 2010 17:20, listreadlistr...@cze.com wrote: Richard, I think I need to learn about semaphores! Any suggestions for a good tutorial? One of the things we want to do is exclude locked records from a query. Will semaphores provide for that? Thanks! - Ron On 1/27/2010 8:14 AM, Richard Quadling wrote: The technique I've used in the past is semaphore locking, where the semaphore contains the session and the expected expiry time. Follow this. User a starts the process of editing a record. Set the semaphore where there is : a - no existing semaphore - no ongoing edits. b - the semaphore's session is the same - repeat edits by this user in the same session (expired or otherwise). c - the semaphore has expired - the other user simply took too long. If the semaphore cannot be set it will be because of : d - Different non expired session - someone else is editing the record. When a user saves the row, you just remove the semaphore. The semaphores could be in a separate table (rather than on the record itself). Different tables have different number of columns so take different amounts of time to edit, so each table would have a different amount of time from edit to expiry. An entry on a lookup table (just a description) should, in the main, be completed within 30 seconds. But a detail line for a purchase order may take several minutes. You'll have to tune this to your own needs. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php A semaphore is just a flag. Nothing else. You can implement it in any way you like as long as _ALL_ code related to locking uses the semaphores. A common technique for locking files is to create a folder called filename.lck A directory can only exist or not. You try to create the directory. If you did, you got the lock. If not, someone else has. The same approach should be used for DB locking in this manner. You try to place the lock (with the conditions defined in the WHERE clause under which it should succeed). If the lock doesn't get written, then you don't have it. What you _DON'T_ do, is see if the lock is already there before trying to write one. No need and provides the possibility for another user, using the same code, to be interleaved. Also, no need for transactions at this stage too. You put the lock on (if you are allowed to). Now you can edit and re-edit the row until you've finished. This technique is described quite well in http://en.wikipedia.org/wiki/Semaphore_(programming) One of the important aspects to using semaphores is that the process to set (and either succeed or fail) must not be interrupted, hence why you don't try to read the presence of the lock before setting it. I hope that helps some. I used to develop using an old DOS based 4GL called Sage Retrieve 4GL (prior to that it was called Sage Skybase). This uses a modified D-ISAM db structure and semaphores for locking. You'd try to lock a record and process the failure. Quite easy really. By extending this concept to include an expiry time within the lock, you've got your auto-unlock feature written. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Automatic logoff
Chris, Yes, I can see how your suggestion would be good for approximating the length of a visit, but my issue is more specific and technical... We will have users updating database records. We want to lock a record while it is being worked on and release it once the user is finished or otherwise leaves the site. That's why we want a graceful exit. Maybe I should start a new thread about locking db records? - Ron On 1/26/2010 4:03 PM, Chris wrote: listread wrote: Bruno, Thanks for the heads up on the php configuration. I'll check that out. We also need to write some data to a database, things like logout time. That means running a script for some other php code. There are probably a number of situations where the onUnload thing won't work including browser crashes, some browsers may not support it, will it work if you have multiple browser tabs open and close one (something you'll have to research) etc, so be aware that you're not going to get this 100% right. If you just want the timing, I'd do it the other way. Each time their session is checked (on page load), update the end time. In db terms: update session set logout_time=NOW() where session_id='X'; That way you're always going to get at least an idea of how long their session lasts but you won't get reading time on the page (ie it takes me 2 mins to read something on the page, the logout_time will be 2 minutes before I actually close it). -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Automatic logoff
Richard, I think I need to learn about semaphores! Any suggestions for a good tutorial? One of the things we want to do is exclude locked records from a query. Will semaphores provide for that? Thanks! - Ron On 1/27/2010 8:14 AM, Richard Quadling wrote: The technique I've used in the past is semaphore locking, where the semaphore contains the session and the expected expiry time. Follow this. User a starts the process of editing a record. Set the semaphore where there is : a - no existing semaphore - no ongoing edits. b - the semaphore's session is the same - repeat edits by this user in the same session (expired or otherwise). c - the semaphore has expired - the other user simply took too long. If the semaphore cannot be set it will be because of : d - Different non expired session - someone else is editing the record. When a user saves the row, you just remove the semaphore. The semaphores could be in a separate table (rather than on the record itself). Different tables have different number of columns so take different amounts of time to edit, so each table would have a different amount of time from edit to expiry. An entry on a lookup table (just a description) should, in the main, be completed within 30 seconds. But a detail line for a purchase order may take several minutes. You'll have to tune this to your own needs. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Automatic logoff
Has anyone considered a way to run a script or automatically access a php page when a user leaves a site without logging off? The idea is to gracefully end that user's session. Thanks! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Automatic logoff
js onunload sounds like a viable option. Will it work if the use just closes his browser? Thanks for the tip! - Ron On 1/25/2010 12:51 PM, Bastien Koert wrote: On Mon, Jan 25, 2010 at 1:48 PM, listreadlistr...@cze.com wrote: Has anyone considered a way to run a script or automatically access a php page when a user leaves a site without logging off? The idea is to gracefully end that user's session. Thanks! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You can try using an ajax call paired with the js onunload function to call the server. The other option is to time the user out via cron on the server after x number of minutes -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Automatic logoff
Bruno, Thanks for the heads up on the php configuration. I'll check that out. We also need to write some data to a database, things like logout time. That means running a script for some other php code. Thanks! - Ron On 1/25/2010 1:24 PM, Bruno Fajardo wrote: 2010/1/25 listreadlistr...@cze.com: Has anyone considered a way to run a script or automatically access a php page when a user leaves a site without logging off? The idea is to gracefully end that user's session. The built-in garbage collector is not sufficient for your app? Additionally, you can configure PHP to destroy the session as soon as the client closes your page. Thanks! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] How to: Include identifier with a query
Greetings! We are searching for names that might or might not exist in a 4 million row db and have to do a lot of fuzzy searches that often don't return results. I would like the use to have the option of killing a query process. Since we are apt to have several queries running KILL QUERY doesn't seem to work. I would like to use KILL (process id) instead. We can use SHOW FULL PROCESSLIST to get a complete list of the processes, but we need for the code to identify which one to kill. Here's the question: How can I flag a particular query so it can be identified from the array SHOW FULL PROCESSLIST generates? Thanks! - Ron