Re: [PHP-DB] gdbm locking problem
I don't use GDBM, but it looks like you have the wrong idea completely. dba_open will return a database connection handle, if its successful, there is no sense opening up multiple database handles in a loop like that. dba_open will do locking itself, the d in wd tells it to use a file lock, the w tells it to allow read/write access. $id = dba_open (/tmp/test.db, n, db2); if (!$id) { echo dba_open failed\n; exit; } Read this: http://us2.php.net/manual/en/function.dba-open.php *Note: * Locking and the mode modifiers l, d, - and t were added in PHP 4.3.0. In PHP versions before PHP 4.3.0 you must use semaphores to guard against simultaneous database access for any database handler with the exception of GDBM. See System V semaphore support http://us2.php.net/manual/en/ref.sem.php. -Jeff Moss Michael Jeung wrote: Hello everyone, I am having trouble with gdbm locking. I've written two very simple test scripts that I am running simultaneously and locking does not seem to be working properly. 1st Test Script - Opens a writer lock, then spins infinitely. dba_open(research.db, wd, gdbm); while(1) { echo I have a writer lock on the file! \n; } 2nd Test Script: - Spins infinitely, trying to get a write lock on the file. while(1) { if(dba_open(research.db, wd, gdbm)) echo I also have a write lock on the file! (using dba_open) \n; } Here is the problem: When I run Script 1 and then Script 2 (while Script 1 is running), both scripts claim to have a writer lock on research.db. This doesn't seem right. What am I missing? I'm running both of the scripts in the same directory on the same machine under FreeBSD 4.10. Thanks for your help! Michael Jeung
Re: [PHP-DB] mysqli prepared statement query result sets
Hi Gerard, Thanks for the reply. I'm writing a db abstraction layer driver for MySQLi. I'm glad to finally get a chance to play around with these new functions, but am completely stumped by this question: Is there no way to get back a standard resultset when using prepared statement queries? snip I don't see the solution, but I hope I'm just missing something because I've been staring at it too long. No you're not missing anything... I ran into the same thing... http://marc.theaimsgroup.com/?l=php-dbm=109625996830773w=2 So I ended up simulating prepared statements via php itself. The way the mysqli extension is currently setup, is that you can either use the normal functions by themselves, or you use the statement functions by themselves. They cannot be used together, which I think Never mind, I'll keep my thoughts to myself... Ooops, I guess I should have searched the list itself; I did some google searches to no avail. This is really unfortunate. This API sucks! I was looking forward to being able to use native prepared statements rather than emulating, but I guess that's really not feasible for this project. Argh. Thanks again for response. Hans -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysqli prepared statement query result sets
Am Di, den 26.10.2004 schrieb Hans Lellelid um 12:57: Ooops, I guess I should have searched the list itself; I did some google searches to no avail. This is really unfortunate. This API sucks! Prepared api calls use a binary protocol, which is totally different from the old protocol. If you don't need binary protocol for prepared statements, why don't you use native SQL Implementation for prepared statements instead ?? It's always easy to claim that stuff other people created (and spent a lot of time on it) sucks. But it sucks definitely more, if people are not able to read the PHP and MySQL Documentation carefully. Just my 2 cents Georg -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] gdbm locking problem
The point is it was a simple test case created to test if locking was working, the results of which show that for whatever reason - it is not. The point wasn't to make a meaningful script. He's obviously trying to call a single script simultaneously, or work on a single database from multiple scripts, but wants to make sure they don't hose his db file. You do bring up a good point though - script 2 has the while loop outside the connection, so it should only print its message once if locking was working properly. - Martin Norland, Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -Original Message- From: Jeff Moss [mailto:[EMAIL PROTECTED] Sent: Monday, October 25, 2004 11:14 PM To: Michael Jeung Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] gdbm locking problem I don't use GDBM, but it looks like you have the wrong idea completely. dba_open will return a database connection handle, if its successful, there is no sense opening up multiple database handles in a loop like that. dba_open will do locking itself, the d in wd tells it to use a file lock, the w tells it to allow read/write access. $id = dba_open (/tmp/test.db, n, db2); if (!$id) { echo dba_open failed\n; exit; } Read this: http://us2.php.net/manual/en/function.dba-open.php *Note: * Locking and the mode modifiers l, d, - and t were added in PHP 4.3.0. In PHP versions before PHP 4.3.0 you must use semaphores to guard against simultaneous database access for any database handler with the exception of GDBM. See System V semaphore support http://us2.php.net/manual/en/ref.sem.php. -Jeff Moss Michael Jeung wrote: Hello everyone, I am having trouble with gdbm locking. I've written two very simple test scripts that I am running simultaneously and locking does not seem to be working properly. 1st Test Script - Opens a writer lock, then spins infinitely. dba_open(research.db, wd, gdbm); while(1) { echo I have a writer lock on the file! \n; } 2nd Test Script: - Spins infinitely, trying to get a write lock on the file. while(1) { if(dba_open(research.db, wd, gdbm)) echo I also have a write lock on the file! (using dba_open) \n; } Here is the problem: When I run Script 1 and then Script 2 (while Script 1 is running), both scripts claim to have a writer lock on research.db. This doesn't seem right. What am I missing? I'm running both of the scripts in the same directory on the same machine under FreeBSD 4.10. Thanks for your help! Michael Jeung -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysqli prepared statement query result sets
Norland, Martin wrote: The functions you want exist in php5, if that's an option: http://us2.php.net/manual/en/ref.mysqli.php - http://us2.php.net/manual/en/function.mysqli-fetch-assoc.php No this is not an option. mysqli_fetch_* needs a result resource id to work. mysqli statement functions needs object references (plus there are other quirks). You cannot use mysqli_fetch_* functions with the mysqli prepared statement functions... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysqli prepared statement query result sets
Hi Gerard, I believe he is talking about - http://dev.mysql.com/doc/mysql/en/SQLPS.html But IMHO, I think emulating via php would be faster, as that is alot of talking to a database to get the job done, especially if the database is on a remote host. Ahh, ok. Yes, this is interesting, but certainly not ideal from a uniform API perspective. I will stick w/ emulation in PHP. Granted, he is correct. We have no right to say that is sucks. Me personally, I do not know at whom to point a finger to blame (maybe the mysql C API), but it is what it is unfortunately. We just have to make the best of it... Yes, you're right. Saying the API sucks was certainly an exaggeration. It is a disappointment, but no one sucks. Georg did an awesome job bringing this to PHP5. I'll stop complaining just stick w/ classic mysql API ;) -Hans -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysqli prepared statement query result sets
Wishful thinking on my part, since it specified no version info because it was likely only in CVS - I thought maybe it was *really new* :). That is unfortunate then, definitely. Perhaps a mysqli_stmt_fetch_assoc() is forthcoming :( - Martin Norland, Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -Original Message- From: Gerard Samuel [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 26, 2004 8:49 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysqli prepared statement query result sets Norland, Martin wrote: The functions you want exist in php5, if that's an option: http://us2.php.net/manual/en/ref.mysqli.php - http://us2.php.net/manual/en/function.mysqli-fetch-assoc.php No this is not an option. mysqli_fetch_* needs a result resource id to work. mysqli statement functions needs object references (plus there are other quirks). You cannot use mysqli_fetch_* functions with the mysqli prepared statement functions... -- 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] Implementing search in a database driven website
Hi I have a PHP-mysql website in which I want to implement search functionality. Through the content management section, the user can enter data into the database. Here he can enter HTML tags and embedded CSS stylesheets also. Now the problem is while searching the table, I want to show couple of lines of the relevant text. This gets displayed along with the HTML tags and CSS entries. Is there anyway I can display only the text ? I have tried strip_tags but it does not strip the CSS entries. -- Warm Regards Vinayak -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] delete time related data inside a table within 1 hour
Hi Martin, http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html says that's the right format. Are you sure you're storing the time and not just the date? I'd wager that it will delete immediately if you are only storing the date. I agree as it is the right format but when I use INTERVAL 1 HOUR it deletes it immediately. The used column is date and time related 2004-10-24 07:42:34 and work's fine while using INTERVAL -1 DAY. -- Best Regards, Mark -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Implementing search in a database driven website
On Wed, 2004-10-27 at 00:33 +0530, Vinayakam Murugan wrote: Hi I have a PHP-mysql website in which I want to implement search functionality. Through the content management section, the user can enter data into the database. Here he can enter HTML tags and embedded CSS stylesheets also. Now the problem is while searching the table, I want to show couple of lines of the relevant text. This gets displayed along with the HTML tags and CSS entries. Is there anyway I can display only the text ? I have tried strip_tags but it does not strip the CSS entries. -- Warm Regards Vinayak You're going to have replace all the css tags when you pull the data out...or rethink how you handle this sort of stuff in your CMS. (html/css inside the content isn't fun to deal with) -Robby -- /*** * Robby Russell | Owner.Developer.Geek * PLANET ARGON | www.planetargon.com * Portland, OR | [EMAIL PROTECTED] * 503.351.4730 | blog.planetargon.com * PHP/PostgreSQL Hosting Development / signature.asc Description: This is a digitally signed message part
Re: [PHP-DB] Implementing search in a database driven website
On Tue, 2004-10-26 at 16:57 -0700, Robby Russell wrote: On Wed, 2004-10-27 at 00:33 +0530, Vinayakam Murugan wrote: Hi I have a PHP-mysql website in which I want to implement search functionality. Through the content management section, the user can enter data into the database. Here he can enter HTML tags and embedded CSS stylesheets also. Now the problem is while searching the table, I want to show couple of lines of the relevant text. This gets displayed along with the HTML tags and CSS entries. Is there anyway I can display only the text ? I have tried strip_tags but it does not strip the CSS entries. -- Warm Regards Vinayak You're going to have replace all the css tags when you pull the data out...or rethink how you handle this sort of stuff in your CMS. (html/css inside the content isn't fun to deal with) -Robby found on php.net,http://us2.php.net/strip_tags (bottom) $string= preg_replace('style[^]*.*/style'siU,'',$string); -- /*** * Robby Russell | Owner.Developer.Geek * PLANET ARGON | www.planetargon.com * Portland, OR | [EMAIL PROTECTED] * 503.351.4730 | blog.planetargon.com * PHP/PostgreSQL Hosting Development / signature.asc Description: This is a digitally signed message part
Re: [PHP-DB] Implementing search in a database driven website
regex replace them all bastien From: Robby Russell [EMAIL PROTECTED] To: Vinayakam Murugan [EMAIL PROTECTED] CC: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Implementing search in a database driven website Date: Tue, 26 Oct 2004 16:57:36 -0700 On Wed, 2004-10-27 at 00:33 +0530, Vinayakam Murugan wrote: Hi I have a PHP-mysql website in which I want to implement search functionality. Through the content management section, the user can enter data into the database. Here he can enter HTML tags and embedded CSS stylesheets also. Now the problem is while searching the table, I want to show couple of lines of the relevant text. This gets displayed along with the HTML tags and CSS entries. Is there anyway I can display only the text ? I have tried strip_tags but it does not strip the CSS entries. -- Warm Regards Vinayak You're going to have replace all the css tags when you pull the data out...or rethink how you handle this sort of stuff in your CMS. (html/css inside the content isn't fun to deal with) -Robby -- /*** * Robby Russell | Owner.Developer.Geek * PLANET ARGON | www.planetargon.com * Portland, OR | [EMAIL PROTECTED] * 503.351.4730 | blog.planetargon.com * PHP/PostgreSQL Hosting Development / signature.asc -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Implementing search in a database driven website
Thanks, Robby. This worked. However I wasn't able to get any documentation on the siU parameters used in the command as in $string= preg_replace('style[^]*.*/style'siU,'',$string); Any pointers. -- Warm Regards Vinayak -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Implementing search in a database driven website
On Wednesday 27 October 2004 03:11, Vinayakam Murugan wrote: Thanks, Robby. This worked. However I wasn't able to get any documentation on the siU parameters used in the command as in $string= preg_replace('style[^]*.*/style'siU,'',$string); Any pointers. manual Regular Expression Functions (Perl-Compatible) Pattern Modifiers -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* General Protection Fault! [ Ignore ] [ Reboot ] [ Install Linux ] -- From a Slashdot.org post */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php