php-general Digest 13 Sep 2011 07:35:55 -0000 Issue 7475

2011-09-13 Thread php-general-digest-help

php-general Digest 13 Sep 2011 07:35:55 - Issue 7475

Topics (messages 314774 through 314779):

Re: PHP cron job optimization
314774 by: Igor Escobar
314775 by: Eric Butera
314777 by: Igor Escobar

Stop PHP execution on client connection closed
314776 by: Marco Lanzotti
314778 by: Al
314779 by: Marco Lanzotti

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
Other good point is: always set a timeout connection when you're getting the
RSS data to avoid your thread get stuck unnecessary. Use cURL (is much more
faster then file_get_contents).

Multithreading in PHP with cURL http://devzone.zend.com/article/3341


Regards,
Igor Escobar
*Software Engineer
*
+ http://blog.igorescobar.com
+ http://www.igorescobar.com
+ @igorescobar http://www.twitter.com/igorescobar





On Mon, Sep 12, 2011 at 10:05 AM, Igor Escobar titiolin...@gmail.comwrote:

 Use PHP threads. Do the job separately.. in parts... in other words... you
 can't read all them at once.

 You can read a little more about php multithreading here:
 http://blog.motane.lu/2009/01/02/multithreading-in-php/

 You can use a non-relational database like mongo or couchdb to manage where
 you stop and where you have to look back to the RSS feed as well.

 []'s

 Regards,
 Igor Escobar
 *Software Engineer
 *
 + http://blog.igorescobar.com
 + http://www.igorescobar.com
 + @igorescobar http://www.twitter.com/igorescobar






 On Sat, Sep 10, 2011 at 10:37 PM, Stuart Dallas stu...@3ft9.com wrote:

 On 10 Sep 2011, at 09:35, muad shibani wrote:

  I want to design an application that reads news from RSS sources.
  I have about 1000 RSS feed to collect from.
 
  I also will use Cron jobs every 15 minutes to collect the data.
  the question is: Is there a clever way to collect all those feed items
  without exhausting the server
  any Ideas

 I designed a job queuing system a while back when I had a similar problem.
 You can read about it here: http://stut.net/2009/05/29/php-job-queue/.
 Set that type of system up and add a job for each feed, set to run every 15
 minutes. You can then watch the server and tune the number of concurrent job
 processors so you get the optimum balance between load and speed.

 -Stuart

 --
 Stuart Dallas
 3ft9 Ltd
 http://3ft9.com/
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



---End Message---
---BeginMessage---
On Mon, Sep 12, 2011 at 9:37 AM, Igor Escobar titiolin...@gmail.com wrote:
 Other good point is: always set a timeout connection when you're getting the
 RSS data to avoid your thread get stuck unnecessary. Use cURL (is much more
 faster then file_get_contents).

 Multithreading in PHP with cURL http://devzone.zend.com/article/3341


 Regards,
 Igor Escobar
 *Software Engineer
 *
 + http://blog.igorescobar.com
 + http://www.igorescobar.com
 + @igorescobar http://www.twitter.com/igorescobar





 On Mon, Sep 12, 2011 at 10:05 AM, Igor Escobar titiolin...@gmail.comwrote:

 Use PHP threads. Do the job separately.. in parts... in other words... you
 can't read all them at once.

 You can read a little more about php multithreading here:
 http://blog.motane.lu/2009/01/02/multithreading-in-php/

 You can use a non-relational database like mongo or couchdb to manage where
 you stop and where you have to look back to the RSS feed as well.

 []'s

 Regards,
 Igor Escobar
 *Software Engineer
 *
 + http://blog.igorescobar.com
 + http://www.igorescobar.com
 + @igorescobar http://www.twitter.com/igorescobar






 On Sat, Sep 10, 2011 at 10:37 PM, Stuart Dallas stu...@3ft9.com wrote:

 On 10 Sep 2011, at 09:35, muad shibani wrote:

  I want to design an application that reads news from RSS sources.
  I have about 1000 RSS feed to collect from.
 
  I also will use Cron jobs every 15 minutes to collect the data.
  the question is: Is there a clever way to collect all those feed items
  without exhausting the server
  any Ideas

 I designed a job queuing system a while back when I had a similar problem.
 You can read about it here: http://stut.net/2009/05/29/php-job-queue/.
 Set that type of system up and add a job for each feed, set to run every 15
 minutes. You can then watch the server and tune the number of concurrent job
 processors so you get the optimum balance between load and speed.

 -Stuart

 --
 Stuart Dallas
 3ft9 Ltd
 http://3ft9.com/
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





Thread != Multi Process.
---End Message---
---BeginMessage---
@Eric ok ;)


Regards,
Igor Escobar
*Software Engineer
*
+ http://blog.igorescobar.com
+ http://www.igorescobar.com

php-general Digest 13 Sep 2011 19:36:47 -0000 Issue 7476

2011-09-13 Thread php-general-digest-help

php-general Digest 13 Sep 2011 19:36:47 - Issue 7476

Topics (messages 314780 through 314811):

Re: Stop PHP execution on client connection closed
314780 by: vikash.iitb.gmail.com
314781 by: Marco Lanzotti
314788 by: Eric Butera
314789 by: yeer tai
314798 by: Ian
314799 by: Marco Lanzotti
314800 by: Jim Lucas
314807 by: Alex Nikitin
314809 by: Jim Lucas
314810 by: Alex Nikitin

PHP FPM and OCI8 crashes
314782 by: linuxsupport

PHP FPM and OCI crashes
314783 by: linuxsupport
314784 by: Negin Nickparsa
314785 by: linuxsupport
314786 by: Negin Nickparsa
314787 by: linuxsupport
314795 by: linuxsupport
314808 by: Alex Nikitin

Querying a database for 50 users' information: 50 queries or a WHERE array?
314790 by: Dotan Cohen
314791 by: Ashley Sheridan
314792 by: muad shibani
314793 by: Steve Staples
314794 by: yeer tai
314796 by: Ashley Sheridan
314797 by: Eric Butera
314801 by: David Harkness
314802 by: Steve Staples
314803 by: Marc Guay
314804 by: Alex Nikitin
314811 by: Dotan Cohen

htmlentities
314805 by: Ron Piggott
314806 by: Marc Guay

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
On 13 September 2011 13:05, Marco Lanzotti ma...@lanzotti.com wrote:

 Il 12/09/2011 21:32, Al ha scritto:
  See http://us2.php.net/manual/en/function.connection-aborted.php

 As I wrote, PHP doesn't detect that client aborted connection until it
 send some data.
 During query the script doesn't send any data to client, so it doesn't
 detect client aborted connenction.
 I know this function, but it's useless to solve my problem...


You can use ob_start() to start output buffering and ob_end_flush() to send
some data in the middle of script  - that way  your php script will send
some data to the client earlier than finishing execution and hence detect
the aborted connection.



 Bye,
 Marco

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


---End Message---
---BeginMessage---
Il 13/09/2011 09:39, vikash.i...@gmail.com ha scritto:

 You can use ob_start() to start output buffering and ob_end_flush() to send
 some data in the middle of script  - that way  your php script will send
 some data to the client earlier than finishing execution and hence detect
 the aborted connection.

The question is: how can I send data to client until I'm waiting for
query execution? PHP thread support is not available in Apache enviroment.

Bye,
Marco
---End Message---
---BeginMessage---
On Tue, Sep 13, 2011 at 4:01 AM, Marco Lanzotti ma...@lanzotti.com wrote:
 Il 13/09/2011 09:39, vikash.i...@gmail.com ha scritto:

 You can use ob_start() to start output buffering and ob_end_flush() to send
 some data in the middle of script  - that way  your php script will send
 some data to the client earlier than finishing execution and hence detect
 the aborted connection.

 The question is: how can I send data to client until I'm waiting for
 query execution? PHP thread support is not available in Apache enviroment.

 Bye,
 Marco

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



Flush all buffers you have.  Sometimes you have to do nasty hacks like
send a certain number of characters.  Execution will still continue
along after your buffers are send if it is still blocking for a query.

You might have better luck if you search for 'comet' or 'long polling.'
---End Message---
---BeginMessage---


You can use ajax.



 Date: Tue, 13 Sep 2011 09:22:54 -0400
 From: eric.but...@gmail.com
 To: ma...@lanzotti.com
 CC: php-gene...@lists.php.net
 Subject: Re: [PHP] Re: Stop PHP execution on client connection closed
 
 On Tue, Sep 13, 2011 at 4:01 AM, Marco Lanzotti ma...@lanzotti.com wrote:
  Il 13/09/2011 09:39, vikash.i...@gmail.com ha scritto:
 
  You can use ob_start() to start output buffering and ob_end_flush() to send
  some data in the middle of script  - that way  your php script will send
  some data to the client earlier than finishing execution and hence detect
  the aborted connection.
 
  The question is: how can I send data to client until I'm waiting for
  query execution? PHP thread support is not available in Apache enviroment.
 
  Bye,
  Marco
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 Flush all buffers you have.  Sometimes you have to do nasty hacks like
 send a certain number of characters.  Execution 

Re: [PHP] Re: Stop PHP execution on client connection closed

2011-09-13 Thread Marco Lanzotti
Il 12/09/2011 21:32, Al ha scritto:
 See http://us2.php.net/manual/en/function.connection-aborted.php

As I wrote, PHP doesn't detect that client aborted connection until it
send some data.
During query the script doesn't send any data to client, so it doesn't
detect client aborted connenction.
I know this function, but it's useless to solve my problem...

Bye,
Marco

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Stop PHP execution on client connection closed

2011-09-13 Thread vikash . iitb
On 13 September 2011 13:05, Marco Lanzotti ma...@lanzotti.com wrote:

 Il 12/09/2011 21:32, Al ha scritto:
  See http://us2.php.net/manual/en/function.connection-aborted.php

 As I wrote, PHP doesn't detect that client aborted connection until it
 send some data.
 During query the script doesn't send any data to client, so it doesn't
 detect client aborted connenction.
 I know this function, but it's useless to solve my problem...


You can use ob_start() to start output buffering and ob_end_flush() to send
some data in the middle of script  - that way  your php script will send
some data to the client earlier than finishing execution and hence detect
the aborted connection.



 Bye,
 Marco

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Re: Stop PHP execution on client connection closed

2011-09-13 Thread Marco Lanzotti
Il 13/09/2011 09:39, vikash.i...@gmail.com ha scritto:

 You can use ob_start() to start output buffering and ob_end_flush() to send
 some data in the middle of script  - that way  your php script will send
 some data to the client earlier than finishing execution and hence detect
 the aborted connection.

The question is: how can I send data to client until I'm waiting for
query execution? PHP thread support is not available in Apache enviroment.

Bye,
Marco

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PHP FPM and OCI8 crashes

2011-09-13 Thread linuxsupport
Hi,

Recently, I decided to use PHP FPM, installation went well, I configured it
with Nginx.

I can run php script without any issue.

But when I used a script to connect to Oracle database using oci module, I
got a blank page.

Below is the code I am using in script.

?php

$c = oci_connect(mydb, password, 'DEV');

if(!c)
{
  $e = oci_error();
  print htmlentities($e['message']);
  exit;
}
else
{
 echo 'br /Connection is OK';
}
?

If I run this script from command line it works well.

---
/usr/local/php/bin/php db_test.php

Connection is ok
--

But when I run it from Web it does not return any thing, I got following
error in FPM log, nothing else.

WARNING: [pool www] child 15712 exited on signal 11 (SIGSEGV) after
3986.160925 seconds from start

It is getting segfault.

Anyone can suggest what could be possible reason.

PHP veriosn 5.3.8


[PHP] PHP FPM and OCI crashes

2011-09-13 Thread linuxsupport
Hi,

Recently, I decided to use PHP FPM, installation went well, I configured it
with Nginx.

I can run php script without any issue.

But when I used a script to connect to Oracle database using oci module, I
got a blank page.

Below is the code I am using in script.

?php

$c = oci_connect(mydb, password, 'DEV');

if(!c)
{
  $e = oci_error();
  print htmlentities($e['message']);
  exit;
}
else
{
 echo 'br /Connection is OK';
}
?

If I run this script from command line it works well.

---
/usr/local/php/bin/php db_test.php

Connection is ok
--

But when I run it from Web it does not return any thing, I got following
error in FPM log, nothing else.

WARNING: [pool www] child 15712 exited on signal 11 (SIGSEGV) after
3986.160925 seconds from start

It is getting segfault.

Anyone can suggest what could be possible reason.

PHP veriosn 5.3.8


Re: [PHP] PHP FPM and OCI crashes

2011-09-13 Thread Negin Nickparsa
is your oci module enabled in php.ini?
I mean something like this?
extension=oci8.so


Re: [PHP] PHP FPM and OCI crashes

2011-09-13 Thread linuxsupport
Yes, it is enabled, I checked through phpinfo()

On Tue, Sep 13, 2011 at 2:54 PM, Negin Nickparsa nickpa...@gmail.comwrote:

 is your oci module enabled in php.ini?
 I mean something like this?
 extension=oci8.so



Re: [PHP] PHP FPM and OCI crashes

2011-09-13 Thread Negin Nickparsa
use gdb


Re: [PHP] PHP FPM and OCI crashes

2011-09-13 Thread linuxsupport
Could you please tell me how to use GDB here?

On Tue, Sep 13, 2011 at 4:07 PM, Negin Nickparsa nickpa...@gmail.comwrote:

 use gdb



Re: [PHP] Re: Stop PHP execution on client connection closed

2011-09-13 Thread Eric Butera
On Tue, Sep 13, 2011 at 4:01 AM, Marco Lanzotti ma...@lanzotti.com wrote:
 Il 13/09/2011 09:39, vikash.i...@gmail.com ha scritto:

 You can use ob_start() to start output buffering and ob_end_flush() to send
 some data in the middle of script  - that way  your php script will send
 some data to the client earlier than finishing execution and hence detect
 the aborted connection.

 The question is: how can I send data to client until I'm waiting for
 query execution? PHP thread support is not available in Apache enviroment.

 Bye,
 Marco

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



Flush all buffers you have.  Sometimes you have to do nasty hacks like
send a certain number of characters.  Execution will still continue
along after your buffers are send if it is still blocking for a query.

You might have better luck if you search for 'comet' or 'long polling.'

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: Stop PHP execution on client connection closed

2011-09-13 Thread yeer tai


You can use ajax.



 Date: Tue, 13 Sep 2011 09:22:54 -0400
 From: eric.but...@gmail.com
 To: ma...@lanzotti.com
 CC: php-general@lists.php.net
 Subject: Re: [PHP] Re: Stop PHP execution on client connection closed
 
 On Tue, Sep 13, 2011 at 4:01 AM, Marco Lanzotti ma...@lanzotti.com wrote:
  Il 13/09/2011 09:39, vikash.i...@gmail.com ha scritto:
 
  You can use ob_start() to start output buffering and ob_end_flush() to send
  some data in the middle of script  - that way  your php script will send
  some data to the client earlier than finishing execution and hence detect
  the aborted connection.
 
  The question is: how can I send data to client until I'm waiting for
  query execution? PHP thread support is not available in Apache enviroment.
 
  Bye,
  Marco
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 Flush all buffers you have.  Sometimes you have to do nasty hacks like
 send a certain number of characters.  Execution will still continue
 along after your buffers are send if it is still blocking for a query.
 
 You might have better luck if you search for 'comet' or 'long polling.'
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
  

[PHP] Querying a database for 50 users' information: 50 queries or a WHERE array?

2011-09-13 Thread Dotan Cohen
I have a MySQL database table with about 10,000 rows. If I want to
query for 50 specific users (so no LIMIT ORDER BY) then I seem to have
these choices:

1) SELECT * FROM table
This will pull in all 10,000 rows, not nice!

2) foreach ($user as $u) { mysql_query(SELECT * FROM table WHERE
userID=.$u);  }
This will lead to 50 queries, again not nice! (maybe worse)

3) foreach ($user as $u) { $whereClause+= OR userID=.$u; }
This makes a huge SQL query. However, this is the method that I'm using now.

Is there some sort of array that can be passed in the WHERE clause,
containing all the userID's that I am interested in?

Thanks!

-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Querying a database for 50 users' information: 50 queries or a WHERE array?

2011-09-13 Thread Ashley Sheridan


Dotan Cohen dotanco...@gmail.com wrote:

I have a MySQL database table with about 10,000 rows. If I want to
query for 50 specific users (so no LIMIT ORDER BY) then I seem to have
these choices:

1) SELECT * FROM table
This will pull in all 10,000 rows, not nice!

2) foreach ($user as $u) { mysql_query(SELECT * FROM table WHERE
userID=.$u);  }
This will lead to 50 queries, again not nice! (maybe worse)

3) foreach ($user as $u) { $whereClause+= OR userID=.$u; }
This makes a huge SQL query. However, this is the method that I'm using
now.

Is there some sort of array that can be passed in the WHERE clause,
containing all the userID's that I am interested in?

Thanks!

--
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

SELECT * FROM table WHERE userID IN (1,2,3,4,5,etc)

Much smaller than what you proposed in #3, and easier to make if your user is 
list is already an array.

Thanks,
Ash
http://www.ashleysheridan.co.uk
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Querying a database for 50 users' information: 50 queries or a WHERE array?

2011-09-13 Thread muad shibani
Yes there is but all the IDs in one string like this
$ids =  $id1.', '.$id2.', ' ;
note : remove the last comma from the string
the make the query like this:
mysql_query(SELECT * FROM table WHERE
userID= in($ids ) }

On Tue, Sep 13, 2011 at 7:24 AM, Dotan Cohen dotanco...@gmail.com wrote:

 I have a MySQL database table with about 10,000 rows. If I want to
 query for 50 specific users (so no LIMIT ORDER BY) then I seem to have
 these choices:

 1) SELECT * FROM table
 This will pull in all 10,000 rows, not nice!

 2) foreach ($user as $u) { mysql_query(SELECT * FROM table WHERE
 userID=.$u);  }
 This will lead to 50 queries, again not nice! (maybe worse)

 3) foreach ($user as $u) { $whereClause+= OR userID=.$u; }
 This makes a huge SQL query. However, this is the method that I'm using
 now.

 Is there some sort of array that can be passed in the WHERE clause,
 containing all the userID's that I am interested in?

 Thanks!

 --
 Dotan Cohen

 http://gibberish.co.il
 http://what-is-what.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Querying a database for 50 users' information: 50 queries or a WHERE array?

2011-09-13 Thread Steve Staples
On Tue, 2011-09-13 at 17:24 +0300, Dotan Cohen wrote:
 I have a MySQL database table with about 10,000 rows. If I want to
 query for 50 specific users (so no LIMIT ORDER BY) then I seem to have
 these choices:
 
 1) SELECT * FROM table
 This will pull in all 10,000 rows, not nice!
 
 2) foreach ($user as $u) { mysql_query(SELECT * FROM table WHERE
 userID=.$u);  }
 This will lead to 50 queries, again not nice! (maybe worse)
 
 3) foreach ($user as $u) { $whereClause+= OR userID=.$u; }
 This makes a huge SQL query. However, this is the method that I'm using now.
 
 Is there some sort of array that can be passed in the WHERE clause,
 containing all the userID's that I am interested in?
 
 Thanks!
 
 -- 
 Dotan Cohen
 
 http://gibberish.co.il
 http://what-is-what.com
 

what criteria are you using to get the stats for these 50 users?

also, wouldn't this be much better suited for the mysql mailing list?


if you know all the userids, then you could just do it as:

$sql = SELECT * FROM table WHERE userid IN (. implode(', ',
$usersids) .);

not very elegant, and I am not sure that the IN is any better than doing
50 mysql calls, but this is only 1 call, and gets you the data.

Are you querying the database to get the id's in the frist place?  if
so, you could look at doing an inner join on the 2 tables.

-- 

Steve Staples
Web Application Developer


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Querying a database for 50 users' information: 50 queries or a WHERE array?

2011-09-13 Thread yeer tai


select * from table where userID in(1,2,3,etc)



 From: a...@ashleysheridan.co.uk
 Date: Tue, 13 Sep 2011 15:29:26 +0100
 To: dotanco...@gmail.com; php-general@lists.php.net
 Subject: Re: [PHP] Querying a database for 50 users' information: 50 queries 
 or a WHERE array?
 
 
 
 Dotan Cohen dotanco...@gmail.com wrote:
 
 I have a MySQL database table with about 10,000 rows. If I want to
 query for 50 specific users (so no LIMIT ORDER BY) then I seem to have
 these choices:
 
 1) SELECT * FROM table
 This will pull in all 10,000 rows, not nice!
 
 2) foreach ($user as $u) { mysql_query(SELECT * FROM table WHERE
 userID=.$u);  }
 This will lead to 50 queries, again not nice! (maybe worse)
 
 3) foreach ($user as $u) { $whereClause+= OR userID=.$u; }
 This makes a huge SQL query. However, this is the method that I'm using
 now.
 
 Is there some sort of array that can be passed in the WHERE clause,
 containing all the userID's that I am interested in?
 
 Thanks!
 
 -- 
 Dotan Cohen
 
 http://gibberish.co.il
 http://what-is-what.com
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 SELECT * FROM table WHERE userID IN (1,2,3,4,5,etc)
 
 Much smaller than what you proposed in #3, and easier to make if your user is 
 list is already an array.
 
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 -- 
 Sent from my Android phone with K-9 Mail. Please excuse my brevity.
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
  

Re: [PHP] PHP FPM and OCI crashes

2011-09-13 Thread linuxsupport
I enabled debug in log and found this in the log file

[13-Sep-2011 17:03:19.966801] DEBUG: pid 16974, fpm_got_signal(), line 76:
received SIGCHLD
[13-Sep-2011 17:03:19.966832] WARNING: pid 16974, fpm_children_bury(), line
252: [pool www] child 16992 exited on signal 11 (SIGSEGV) after 58.213448
seconds from start
[13-Sep-2011 17:03:19.967678] NOTICE: pid 16974, fpm_children_make(), line
404: [pool www] child 16996 started


Anyone can suggest me to fix this.

On Tue, Sep 13, 2011 at 5:41 PM, linuxsupport lin.supp...@gmail.com wrote:

 Could you please tell me how to use GDB here?

 On Tue, Sep 13, 2011 at 4:07 PM, Negin Nickparsa nickpa...@gmail.comwrote:

 use gdb





RE: [PHP] Querying a database for 50 users' information: 50 queries or a WHERE array?

2011-09-13 Thread Ashley Sheridan


yeer tai yeer...@hotmail.com wrote:



select * from table where userID in(1,2,3,etc)



 From: a...@ashleysheridan.co.uk
 Date: Tue, 13 Sep 2011 15:29:26 +0100
 To: dotanco...@gmail.com; php-general@lists.php.net
 Subject: Re: [PHP] Querying a database for 50 users' information: 50
queries or a WHERE array?



 Dotan Cohen dotanco...@gmail.com wrote:

 I have a MySQL database table with about 10,000 rows. If I want to
 query for 50 specific users (so no LIMIT ORDER BY) then I seem to
have
 these choices:
 
 1) SELECT * FROM table
 This will pull in all 10,000 rows, not nice!
 
 2) foreach ($user as $u) { mysql_query(SELECT * FROM table WHERE
 userID=.$u);  }
 This will lead to 50 queries, again not nice! (maybe worse)
 
 3) foreach ($user as $u) { $whereClause+= OR userID=.$u; }
 This makes a huge SQL query. However, this is the method that I'm
using
 now.
 
 Is there some sort of array that can be passed in the WHERE clause,
 containing all the userID's that I am interested in?
 
 Thanks!
 
 --
 Dotan Cohen
 
 http://gibberish.co.il
 http://what-is-what.com
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

 SELECT * FROM table WHERE userID IN (1,2,3,4,5,etc)

 Much smaller than what you proposed in #3, and easier to make if your
user is list is already an array.

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 --
 Sent from my Android phone with K-9 Mail. Please excuse my brevity.

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



Erm, that's funny that you replied with the exact same answer as I gave, just 
top-posted on my reply...

Thanks,
Ash
http://www.ashleysheridan.co.uk
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Querying a database for 50 users' information: 50 queries or a WHERE array?

2011-09-13 Thread Eric Butera
Oh no, he stole your internet points!


On Tue, Sep 13, 2011 at 10:44 AM, Ashley Sheridan
a...@ashleysheridan.co.uk wrote:


 yeer tai yeer...@hotmail.com wrote:



select * from table where userID in(1,2,3,etc)



 From: a...@ashleysheridan.co.uk
 Date: Tue, 13 Sep 2011 15:29:26 +0100
 To: dotanco...@gmail.com; php-general@lists.php.net
 Subject: Re: [PHP] Querying a database for 50 users' information: 50
queries or a WHERE array?



 Dotan Cohen dotanco...@gmail.com wrote:

 I have a MySQL database table with about 10,000 rows. If I want to
 query for 50 specific users (so no LIMIT ORDER BY) then I seem to
have
 these choices:
 
 1) SELECT * FROM table
 This will pull in all 10,000 rows, not nice!
 
 2) foreach ($user as $u) { mysql_query(SELECT * FROM table WHERE
 userID=.$u);  }
 This will lead to 50 queries, again not nice! (maybe worse)
 
 3) foreach ($user as $u) { $whereClause+= OR userID=.$u; }
 This makes a huge SQL query. However, this is the method that I'm
using
 now.
 
 Is there some sort of array that can be passed in the WHERE clause,
 containing all the userID's that I am interested in?
 
 Thanks!
 
 --
 Dotan Cohen
 
 http://gibberish.co.il
 http://what-is-what.com
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

 SELECT * FROM table WHERE userID IN (1,2,3,4,5,etc)

 Much smaller than what you proposed in #3, and easier to make if your
user is list is already an array.

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 --
 Sent from my Android phone with K-9 Mail. Please excuse my brevity.

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



 Erm, that's funny that you replied with the exact same answer as I gave, just 
 top-posted on my reply...

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 --
 Sent from my Android phone with K-9 Mail. Please excuse my brevity.

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Stop PHP execution on client connection closed

2011-09-13 Thread Ian
On 13/09/2011 09:01, Marco Lanzotti wrote:
 Il 13/09/2011 09:39, vikash.i...@gmail.com ha scritto:

 You can use ob_start() to start output buffering and ob_end_flush() to send
 some data in the middle of script  - that way  your php script will send
 some data to the client earlier than finishing execution and hence detect
 the aborted connection.
 
 The question is: how can I send data to client until I'm waiting for
 query execution? PHP thread support is not available in Apache enviroment.
 
 Bye,
 Marco
 

Hi Marco,

You may have to think of this problem a different way.


How about about creating a job queuing system to handle the long running
database queries.  You will have to break it down into steps:



User initiatives Query via AJAX call.

System receives query and adds it to queue, return status of 'Added to
queue'

System daemon monitors job queue and runs / records status / stores
results of jobs.

Background process on web page monitors job status via AJAX calls and
alerts user when complete.



On linux systems, The pear module 'System Daemon' is very good for job
queues and easy to install:

[http://pear.php.net/package/System_Daemon]



Hope this helps.

Ian
-- 




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Stop PHP execution on client connection closed

2011-09-13 Thread Marco Lanzotti
Il 13/09/2011 15:22, Eric Butera ha scritto:
 Flush all buffers you have. Sometimes you have to do nasty hacks like
 send a certain number of characters.
I'm looking for a way to send some characters during query execution.

  You might have better luck if you search for 'comet' or 'long polling.' 
Long polling requires script interaction. How can I interact while I'm
waiting for query to be executed?

Bye,
Marco

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Stop PHP execution on client connection closed

2011-09-13 Thread Jim Lucas
On 9/12/2011 7:40 AM, Marco Lanzotti wrote:
 Hi all, I'm new in the list and I already have a question for you.
 I'm running an heavy query on my DB in a PHP script called by AJAX.
 Because client often abort AJAX connection to ask a new query, I need to
 stop query because DB will be too loaded.
 When AJAX connection is aborted, PHP script doesn't stop until it send
 some output to client, so I need to wait query execution to know client
 aborted connection.
 How can I abort query (or script) when AJAX connection is aborted?
 
 Thank you,
 Marco
 
 

You cannot stop a DB query.

What this means is PHP will not be able to do anything else until the db has
finished its step and handed data back to the processing script.  At that point,
you can check to see if the connection is still active and take appropriate 
action.

Jim Lucas

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Querying a database for 50 users' information: 50 queries or a WHERE array?

2011-09-13 Thread David Harkness
On Tue, Sep 13, 2011 at 7:29 AM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:

 SELECT * FROM table WHERE userID IN (1,2,3,4,5,etc)


+1. And this is a great place to use implode():

$sql = 'select ... where userID in (' . implode(',', $ids) . ')';

David


Re: [PHP] Querying a database for 50 users' information: 50 queries or a WHERE array?

2011-09-13 Thread Steve Staples
On Tue, 2011-09-13 at 09:48 -0700, David Harkness wrote:
 On Tue, Sep 13, 2011 at 7:29 AM, Ashley Sheridan
 a...@ashleysheridan.co.ukwrote:
 
  SELECT * FROM table WHERE userID IN (1,2,3,4,5,etc)
 
 
 +1. And this is a great place to use implode():
 
 $sql = 'select ... where userID in (' . implode(',', $ids) . ')';
 
 David

I mentioned that implode earlier, but there is also the underlying
question (which I also asked earlier)... how is he getting the 50 id's
to populate?

here are 2 other ways of skinning the cat:

using an inner join:
select table.* from table inner join othertable on (table.userid =
othertable.userid) where (use the way your getting the 50 id's here);

OR by using a subselect,
select * from table where userid IN (select group_concat(userid,
separator ', ') FROM othertable where (using logic here));

guess it all depends on how you want to do it...  but that would make it
1 db query

good luck!


-- 

Steve Staples
Web Application Developer


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Querying a database for 50 users' information: 50 queries or a WHERE array?

2011-09-13 Thread Marc Guay
Another theoretical approach, given the grey areas, would be to add a
field to your table to indicate these special users.  I would call
the field is_awesome and have it default to zero, because that's
just the way it is.  Then you can make your query SELECT * FROM users
WHERE is_awesome=1.  This method might make the code a bit more
manageable as you could modify the users through a CMS rather than
updating a hardcoded array.

Marc

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Querying a database for 50 users' information: 50 queries or a WHERE array?

2011-09-13 Thread Alex Nikitin
On Tue, Sep 13, 2011 at 2:06 PM, Steve Staples sstap...@mnsi.net wrote:

 On Tue, 2011-09-13 at 09:48 -0700, David Harkness wrote:
  On Tue, Sep 13, 2011 at 7:29 AM, Ashley Sheridan
  a...@ashleysheridan.co.ukwrote:
 
   SELECT * FROM table WHERE userID IN (1,2,3,4,5,etc)
  
 
  +1. And this is a great place to use implode():
 
  $sql = 'select ... where userID in (' . implode(',', $ids) . ')';
 
  David

 I mentioned that implode earlier, but there is also the underlying
 question (which I also asked earlier)... how is he getting the 50 id's
 to populate?

 here are 2 other ways of skinning the cat:

 using an inner join:
 select table.* from table inner join othertable on (table.userid =
 othertable.userid) where (use the way your getting the 50 id's here);

 OR by using a subselect,
 select * from table where userid IN (select group_concat(userid,
 separator ', ') FROM othertable where (using logic here));

 guess it all depends on how you want to do it...  but that would make it
 1 db query

 good luck!


 --

 Steve Staples
 Web Application Developer


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



And this will be faster or at least more efficient with a limit (e.g. limit
50) this way when you have found the 50 users in the in statement, you
don't continue iterating through the rest of your data set...

--
The trouble with programmers is that you can never tell what a programmer is
doing until it’s too late.  ~Seymour Cray


[PHP] htmlentities

2011-09-13 Thread Ron Piggott

Is there a way to only change accented characters and not HTML (Example: p 
/p a href =”” /a )

The syntax

echo htmlentities( stripslashes(mysql_result($whats_new_result,0,message)) ) 
. \r\n;

is doing everything (as I expect).  I store breaking news within the database 
as HTML formatted text.  I am trying to see if a work around is available?  Do 
I need to do a variety of search / replace to convert the noted characters 
above back after htmlentities ?

(I am just starting to get use to accented letters.)

Thanks a lot for your help.

Ron

The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info  


Re: [PHP] htmlentities

2011-09-13 Thread Marc Guay
You could store the accented characters in your DB if you set
everything to UTF-8, including calling the SET NAMES utf8 MySQL
command after connecting.  I find this much easier than
encoding/decoding.

Marc

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Stop PHP execution on client connection closed

2011-09-13 Thread Alex Nikitin
On Tue, Sep 13, 2011 at 11:44 AM, Jim Lucas li...@cmsws.com wrote:

 On 9/12/2011 7:40 AM, Marco Lanzotti wrote:
  Hi all, I'm new in the list and I already have a question for you.
  I'm running an heavy query on my DB in a PHP script called by AJAX.
  Because client often abort AJAX connection to ask a new query, I need to
  stop query because DB will be too loaded.
  When AJAX connection is aborted, PHP script doesn't stop until it send
  some output to client, so I need to wait query execution to know client
  aborted connection.
  How can I abort query (or script) when AJAX connection is aborted?
 
  Thank you,
  Marco
 
 

 You cannot stop a DB query.

 What this means is PHP will not be able to do anything else until the db
 has
 finished its step and handed data back to the processing script.  At that
 point,
 you can check to see if the connection is still active and take appropriate
 action.

 Jim Lucas

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


Correction on Marco's post. You can absolutely stop a mysql query, it is
done with a large amount of success at Facebook for example, where they have
very strict query execution rules, e.g. if your query takes too long to run,
it is killed. However unless you are dealing with enormous data sets, or
very very slow mysql server, this is not worth the tremendous amount of
trouble you would have to go through. And if you are dealing with enormous
data sets or slow servers, it would be far more beneficial to address those
issue then to implement the query killing thing.

MySQL commands in question are:
SHOW PROCESSLIST;
KILL [thread];

You can also hook into if you really wanted to with some C through the API,
but again, it is far more trouble than most people need, and problems often
lay else-where (for example inefficient query or bad database design or
matching on non-indexed cols etc...) A query that ties together 3 tables and
pulls 80-90k rows @10 columns shouldn't take more than 0.25 sec to execute,
maybe a second for the whole operation from connect to result, if your mysql
server is one hop away (i.e. they are on the same switch), the tcp hand
shake can take up to 100ms, plus you need to get the process list, traverse
it for your query, and send a kill command. I'm going to guess that the kill
process will take longer to connect, list, parse and kill, then it will take
the query to finish and return data...

What is your data set like, what are you trying to accomplish by this other
than complicating your code?

Also yes, AJAX is your friend (avoid pulling large or any data sets if you
can), as well as some query and database optimization, and caching ;)



--
The trouble with programmers is that you can never tell what a programmer is
doing until it’s too late.  ~Seymour Cray


Re: [PHP] PHP FPM and OCI crashes

2011-09-13 Thread Alex Nikitin
On Tue, Sep 13, 2011 at 10:40 AM, linuxsupport lin.supp...@gmail.comwrote:

 I enabled debug in log and found this in the log file

 [13-Sep-2011 17:03:19.966801] DEBUG: pid 16974, fpm_got_signal(), line 76:
 received SIGCHLD
 [13-Sep-2011 17:03:19.966832] WARNING: pid 16974, fpm_children_bury(), line
 252: [pool www] child 16992 exited on signal 11 (SIGSEGV) after 58.213448
 seconds from start
 [13-Sep-2011 17:03:19.967678] NOTICE: pid 16974, fpm_children_make(), line
 404: [pool www] child 16996 started


 Anyone can suggest me to fix this.

 On Tue, Sep 13, 2011 at 5:41 PM, linuxsupport lin.supp...@gmail.com
 wrote:

  Could you please tell me how to use GDB here?
 
  On Tue, Sep 13, 2011 at 4:07 PM, Negin Nickparsa nickpa...@gmail.com
 wrote:
 
  use gdb
 
 
 


Regarding gdb backtrace:

https://bugs.php.net/bugs-generating-backtrace.php


--
The trouble with programmers is that you can never tell what a programmer is
doing until it’s too late.  ~Seymour Cray


Re: [PHP] Stop PHP execution on client connection closed

2011-09-13 Thread Jim Lucas
On 9/13/2011 11:58 AM, Alex Nikitin wrote:
 On Tue, Sep 13, 2011 at 11:44 AM, Jim Lucas li...@cmsws.com wrote:
 
 On 9/12/2011 7:40 AM, Marco Lanzotti wrote:
 Hi all, I'm new in the list and I already have a question for you.
 I'm running an heavy query on my DB in a PHP script called by AJAX.
 Because client often abort AJAX connection to ask a new query, I need to
 stop query because DB will be too loaded.
 When AJAX connection is aborted, PHP script doesn't stop until it send
 some output to client, so I need to wait query execution to know client
 aborted connection.
 How can I abort query (or script) when AJAX connection is aborted?

 Thank you,
 Marco



 You cannot stop a DB query.

 What this means is PHP will not be able to do anything else until the db
 has
 finished its step and handed data back to the processing script.  At that
 point,
 you can check to see if the connection is still active and take appropriate
 action.

 Jim Lucas

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


 Correction on Marco's post. You can absolutely stop a mysql query, it is
 done with a large amount of success at Facebook for example, where they have
 very strict query execution rules, e.g. if your query takes too long to run,
 it is killed. However unless you are dealing with enormous data sets, or
 very very slow mysql server, this is not worth the tremendous amount of
 trouble you would have to go through. And if you are dealing with enormous
 data sets or slow servers, it would be far more beneficial to address those
 issue then to implement the query killing thing.
 
 MySQL commands in question are:
 SHOW PROCESSLIST;
 KILL [thread];
 
 You can also hook into if you really wanted to with some C through the API,
 but again, it is far more trouble than most people need, and problems often
 lay else-where (for example inefficient query or bad database design or
 matching on non-indexed cols etc...) A query that ties together 3 tables and
 pulls 80-90k rows @10 columns shouldn't take more than 0.25 sec to execute,
 maybe a second for the whole operation from connect to result, if your mysql
 server is one hop away (i.e. they are on the same switch), the tcp hand
 shake can take up to 100ms, plus you need to get the process list, traverse
 it for your query, and send a kill command. I'm going to guess that the kill
 process will take longer to connect, list, parse and kill, then it will take
 the query to finish and return data...
 
 What is your data set like, what are you trying to accomplish by this other
 than complicating your code?
 
 Also yes, AJAX is your friend (avoid pulling large or any data sets if you
 can), as well as some query and database optimization, and caching ;)
 
 
 
 --
 The trouble with programmers is that you can never tell what a programmer is
 doing until it’s too late.  ~Seymour Cray
 

My statement still stands.

 What this means is PHP will not be able to do anything else until the db
 has finished its step and handed data back to the processing script.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Stop PHP execution on client connection closed

2011-09-13 Thread Alex Nikitin
Absolutely, it was only a minor correction of a sub-point.

--
The trouble with programmers is that you can never tell what a programmer is
doing until it’s too late.  ~Seymour Cray



On Tue, Sep 13, 2011 at 3:20 PM, Jim Lucas li...@cmsws.com wrote:

 On 9/13/2011 11:58 AM, Alex Nikitin wrote:
  On Tue, Sep 13, 2011 at 11:44 AM, Jim Lucas li...@cmsws.com wrote:
 
  On 9/12/2011 7:40 AM, Marco Lanzotti wrote:
  Hi all, I'm new in the list and I already have a question for you.
  I'm running an heavy query on my DB in a PHP script called by AJAX.
  Because client often abort AJAX connection to ask a new query, I need
 to
  stop query because DB will be too loaded.
  When AJAX connection is aborted, PHP script doesn't stop until it send
  some output to client, so I need to wait query execution to know client
  aborted connection.
  How can I abort query (or script) when AJAX connection is aborted?
 
  Thank you,
  Marco
 
 
 
  You cannot stop a DB query.
 
  What this means is PHP will not be able to do anything else until the db
  has
  finished its step and handed data back to the processing script.  At
 that
  point,
  you can check to see if the connection is still active and take
 appropriate
  action.
 
  Jim Lucas
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
  Correction on Marco's post. You can absolutely stop a mysql query, it is
  done with a large amount of success at Facebook for example, where they
 have
  very strict query execution rules, e.g. if your query takes too long to
 run,
  it is killed. However unless you are dealing with enormous data sets, or
  very very slow mysql server, this is not worth the tremendous amount of
  trouble you would have to go through. And if you are dealing with
 enormous
  data sets or slow servers, it would be far more beneficial to address
 those
  issue then to implement the query killing thing.
 
  MySQL commands in question are:
  SHOW PROCESSLIST;
  KILL [thread];
 
  You can also hook into if you really wanted to with some C through the
 API,
  but again, it is far more trouble than most people need, and problems
 often
  lay else-where (for example inefficient query or bad database design or
  matching on non-indexed cols etc...) A query that ties together 3 tables
 and
  pulls 80-90k rows @10 columns shouldn't take more than 0.25 sec to
 execute,
  maybe a second for the whole operation from connect to result, if your
 mysql
  server is one hop away (i.e. they are on the same switch), the tcp hand
  shake can take up to 100ms, plus you need to get the process list,
 traverse
  it for your query, and send a kill command. I'm going to guess that the
 kill
  process will take longer to connect, list, parse and kill, then it will
 take
  the query to finish and return data...
 
  What is your data set like, what are you trying to accomplish by this
 other
  than complicating your code?
 
  Also yes, AJAX is your friend (avoid pulling large or any data sets if
 you
  can), as well as some query and database optimization, and caching ;)
 
 
 
  --
  The trouble with programmers is that you can never tell what a programmer
 is
  doing until it’s too late.  ~Seymour Cray
 

 My statement still stands.

  What this means is PHP will not be able to do anything else until the db
  has finished its step and handed data back to the processing script.




Re: [PHP] Querying a database for 50 users' information: 50 queries or a WHERE array?

2011-09-13 Thread Dotan Cohen
On Tue, Sep 13, 2011 at 17:29, Ashley Sheridan a...@ashleysheridan.co.uk 
wrote:
 SELECT * FROM table WHERE userID IN (1,2,3,4,5,etc)

 Much smaller than what you proposed in #3, and easier to make if your user is 
 list is already an array.


Thank you Ash, that is exactly what I was looking for!

-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Querying a database for 50 users' information: 50 queries or a WHERE array?

2011-09-13 Thread Dotan Cohen
On Tue, Sep 13, 2011 at 17:32, muad shibani muad.shib...@gmail.com wrote:
 Yes there is but all the IDs in one string like this
 $ids =  $id1.', '.$id2.', ' ;
 note : remove the last comma from the string
 the make the query like this:
 mysql_query(SELECT * FROM table WHERE
 userID= in($ids ) }

Thank you Muad!


-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Querying a database for 50 users' information: 50 queries or a WHERE array?

2011-09-13 Thread Dotan Cohen
On Tue, Sep 13, 2011 at 17:34, Steve Staples sstap...@mnsi.net wrote:
 what criteria are you using to get the stats for these 50 users?


They are passed as an array into a function I'm cleaning up.


 also, wouldn't this be much better suited for the mysql mailing list?


Yes.


 if you know all the userids, then you could just do it as:

 $sql = SELECT * FROM table WHERE userid IN (. implode(', ',
 $usersids) .);

 not very elegant, and I am not sure that the IN is any better than doing
 50 mysql calls, but this is only 1 call, and gets you the data.


This is exactly what I need, thanks!


 Are you querying the database to get the id's in the frist place?  if
 so, you could look at doing an inner join on the 2 tables.


Actually, I do suspect that is where it's coming from. But the calling
function is not in my hands.


-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Querying a database for 50 users' information: 50 queries or a WHERE array?

2011-09-13 Thread Dotan Cohen
On Tue, Sep 13, 2011 at 21:06, Steve Staples sstap...@mnsi.net wrote:
 I mentioned that implode earlier, but there is also the underlying
 question (which I also asked earlier)... how is he getting the 50 id's
 to populate?

 here are 2 other ways of skinning the cat:

 using an inner join:
 select table.* from table inner join othertable on (table.userid =
 othertable.userid) where (use the way your getting the 50 id's here);

 OR by using a subselect,
 select * from table where userid IN (select group_concat(userid,
 separator ', ') FROM othertable where (using logic here));

 guess it all depends on how you want to do it...  but that would make it
 1 db query


I personally would stick with the inner join as I know that syntax,
but thanks for introducing me to the subselect. I have never seen
that.


-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Querying a database for 50 users' information: 50 queries or a WHERE array?

2011-09-13 Thread Dotan Cohen
On Tue, Sep 13, 2011 at 21:34, Alex Nikitin niks...@gmail.com wrote:
 And this will be faster or at least more efficient with a limit (e.g. limit
 50) this way when you have found the 50 users in the in statement, you
 don't continue iterating through the rest of your data set...


The number is never exactly 50 but rather some arbitrary large number.
But there is no need for LIMIT, that is the purpose of the _INNER_
JOIN. INNER means to only return the matching rows.


-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Querying a database for 50 users' information: 50 queries or a WHERE array?

2011-09-13 Thread Alex Nikitin
On Tue, Sep 13, 2011 at 3:45 PM, Dotan Cohen dotanco...@gmail.com wrote:

 On Tue, Sep 13, 2011 at 21:34, Alex Nikitin niks...@gmail.com wrote:
  And this will be faster or at least more efficient with a limit (e.g.
 limit
  50) this way when you have found the 50 users in the in statement, you
  don't continue iterating through the rest of your data set...
 

 The number is never exactly 50 but rather some arbitrary large number.
 But there is no need for LIMIT, that is the purpose of the _INNER_
 JOIN. INNER means to only return the matching rows.


 --
 Dotan Cohen

 http://gibberish.co.il
 http://what-is-what.com


Dotan,

IN (the function used in all of the queries above) is not the same as an
INNER_JOIN, inner join joins 2 tables, as you have already described, IN
however is a function that return 1 if the value being searched for is in
the array of its values or 0 if it is not, thus IN is not an inner join, but
a comparator function, thus if you are using IN, limit will indeed be more
efficient than it's omission for exactly the reason i have stated in my
previous post. Because your user array seems to be in php, and implode has
been a topic of discussion above as well, setting an adequate limit is a
simple task with the php's count function.

This is all ofcourse void if the user array being pulled from mysql, in
which case you could simply join the two tables to get your resulting data
set. The trick there is to use the USING clause which seems to run a lot
faster than any ON clause, or work on an optimized subselect, especially if
you are running a cluster.


--
The trouble with programmers is that you can never tell what a programmer is
doing until it’s too late.  ~Seymour Cray


[PHP] What would you like to see in most in a text editor?

2011-09-13 Thread Brad Huskins

Hello all you php coders out there,

I'm doing an Open Source text editor (just a hobby) that's designed for 
PHP developers and is accessible through the web. This has been stewing 
for a while, and has gotten to the point where I can use it for my own 
work. I would like any feedback on things that people really 
like/dislike about their current editors, as I believe some of these 
things could be resolved in mine.


I currently have username/password protection (with Salted-Hash 
passwords), a file-system browser, file loading/saving, and syntax 
highlighting -- and these things seem to work reasonably well. As well, 
most things about the editor are scriptable with JavaScript. This would 
seem to imply that in a few weeks I would have something useful. So I 
would like to get some feedback on what features people would most want, 
since I am still at a very flexible stage in development.


If you would like to see what I have, you can go to 
un1tware.wordpress.com. You can also peruse the code at 
github.com/bhus/scriptr. In particular, the README on github gives a 
little bit better rationality for why something like this might be 
useful, and how things are currently structured.


--Brad

[ Yes, this is based on the layout of Linus' original post to 
comp.os.minix. ]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] What would you like to see in a text editor?

2011-09-13 Thread Brad Huskins
Hello all you PHP devs,

I'm building an Open Source text editor accessible through the web. It 
has been brewing for a while in one form or another. But I think I 
finally have something solid to build on. I would like some feedback on 
things people like/dislike about their current editors.

I currently have a basic system working with a login, file browser, 
ability to load/save files and syntax highlighting working. All 
keystrokes are sent through a client-side JavaScript API built on JQuery. 
This would seem to imply that something usable is not more than a few 
weeks away, so I figured I would get some input now while things are 
still quite flexible. All suggestions are welcome, though not all will be 
implemented.

If you want, you can visit the web site for the project at 
un1tware.wordpress.com. There's a link to a video demo, as well as a the 
current version of the source code to try out.

As well, the project can be found at github.com/bhus/scriptr. I have 
tried to make the README readable and yet comprehensive.

--Brad

[And yes, this message is modeled after Linus' original post to 
comp.os.minix]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] What would you like to see in most in a text editor?

2011-09-13 Thread Brad Huskins

Hello all you php coders out there,

I'm doing an Open Source text editor (just a hobby) that's designed for 
PHP developers and is accessible through the web. This has been stewing 
for a while, and has gotten to the point where I can use it for my own 
work. I would like any feedback on things that people really 
like/dislike about their current editors, as I believe some of these 
things could be resolved in mine.


I currently have username/password protection (with Salted-Hash 
passwords), a file-system browser, file loading/saving, and syntax 
highlighting -- and these things seem to work reasonably well. As well, 
most things about the editor are scriptable with JavaScript. This would 
seem to imply that in a few weeks I would have something useful. So I 
would like to get some feedback on what features people would most want, 
since I am still at a very flexible stage in development.


If you would like to see what I have, you can go to 
un1tware.wordpress.com. You can also peruse the code at 
github.com/bhus/scriptr. In particular, the README on github gives a 
little bit better rationality for why something like this might be 
useful, and how things are currently structured.


--Brad

[ Yes, this is based on the layout of Linus' original post to 
comp.os.minix. ]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] What would you like to see in most in a text editor?

2011-09-13 Thread Robert Cummings

On 11-09-13 03:56 PM, Brad Huskins wrote:

Hello all you php coders out there,

I'm doing an Open Source text editor (just a hobby) that's designed for
PHP developers and is accessible through the web. This has been stewing
for a while, and has gotten to the point where I can use it for my own
work. I would like any feedback on things that people really
like/dislike about their current editors, as I believe some of these
things could be resolved in mine.

I currently have username/password protection (with Salted-Hash
passwords), a file-system browser, file loading/saving, and syntax
highlighting -- and these things seem to work reasonably well. As well,
most things about the editor are scriptable with JavaScript. This would
seem to imply that in a few weeks I would have something useful. So I
would like to get some feedback on what features people would most want,
since I am still at a very flexible stage in development.

If you would like to see what I have, you can go to
un1tware.wordpress.com. You can also peruse the code at
github.com/bhus/scriptr. In particular, the README on github gives a
little bit better rationality for why something like this might be
useful, and how things are currently structured.


I'm a big fan of editors that work in the terminal.

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Sorry!

2011-09-13 Thread Brad Huskins
My apologies for the triplicate errors. My newsgroup client is doing 
screwy things.


Again, I am SO sorry for the multiple posts.

/Brad.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: htmlentities

2011-09-13 Thread Shawn McKenzie
On 09/13/2011 01:38 PM, Ron Piggott wrote:
 
 Is there a way to only change accented characters and not HTML (Example: p 
 /p a href =”” /a )
 
 The syntax
 
 echo htmlentities( stripslashes(mysql_result($whats_new_result,0,message)) 
 ) . \r\n;
 
 is doing everything (as I expect).  I store breaking news within the database 
 as HTML formatted text.  I am trying to see if a work around is available?  
 Do I need to do a variety of search / replace to convert the noted characters 
 above back after htmlentities ?
 
 (I am just starting to get use to accented letters.)
 
 Thanks a lot for your help.
 
 Ron
 
 The Verse of the Day
 “Encouragement from God’s Word”
 http://www.TheVerseOfTheDay.info  
 

If it is meant to be HTML then why run htmlentities(), especially before
storing it in the DB?

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] What would you like to see in most in a text editor?

2011-09-13 Thread Alex Nikitin
+1 on terminal.

For gui-based ones, i like to be able to syntax check my code and run it
from within the editor window, tabs for dozens of files i usually have open
at once, highlight that supports many languages as i can be working on many
at once (php, css, js, ruby, python, C, lua, sql, for the ones i have open
in geany atm), shortcuts are essential for things like find or replace in a
selected area or what have you, regex support in search, and something that
can be themed with white on black.

For web-based ones, i never want to have to physically press anything to
save my work, and i expect it to be within a few words if i just closed the
browser and came back. It can't use any more resources than a usual web-page
and has to be responsive.

For other features to think about, built in version control system, ability
to sync with github or really any cvs/svn/git repo, diff tool integrated
into the editor, collaboration.

Essential 1: utmost security, if they pwn your servers, they should not be
able to have my data, this means that some part of what i pass to you in my
credentials needs to not even reside on your servers (for example you can
use the salted hash to check my the password, but the clear text version is
still needed to decrypt that user's data store) and for the ultra paranoid,
i should be able to further protect my data store with another password the
hash for which you don't store, but rather store the md5 of the hash.
Essential 2: reliability, i would like to be in an N+N+1 where the service
and my data are both highly available without performance degradation when
one of the services/servers goes kablewey (technical term)

Enjoy.


--
The trouble with programmers is that you can never tell what a programmer is
doing until it’s too late.  ~Seymour Cray



On Tue, Sep 13, 2011 at 4:35 PM, Robert Cummings rob...@interjinn.comwrote:

 On 11-09-13 03:56 PM, Brad Huskins wrote:

 Hello all you php coders out there,

 I'm doing an Open Source text editor (just a hobby) that's designed for
 PHP developers and is accessible through the web. This has been stewing
 for a while, and has gotten to the point where I can use it for my own
 work. I would like any feedback on things that people really
 like/dislike about their current editors, as I believe some of these
 things could be resolved in mine.

 I currently have username/password protection (with Salted-Hash
 passwords), a file-system browser, file loading/saving, and syntax
 highlighting -- and these things seem to work reasonably well. As well,
 most things about the editor are scriptable with JavaScript. This would
 seem to imply that in a few weeks I would have something useful. So I
 would like to get some feedback on what features people would most want,
 since I am still at a very flexible stage in development.

 If you would like to see what I have, you can go to
 un1tware.wordpress.com. You can also peruse the code at
 github.com/bhus/scriptr. In particular, the README on github gives a
 little bit better rationality for why something like this might be
 useful, and how things are currently structured.


 I'm a big fan of editors that work in the terminal.

 Cheers,
 Rob.
 --
 E-Mail Disclaimer: Information contained in this message and any
 attached documents is considered confidential and legally protected.
 This message is intended solely for the addressee(s). Disclosure,
 copying, and distribution are prohibited unless authorized.


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] What would you like to see in most in a text editor?

2011-09-13 Thread Igor Escobar
+ extensible plug-ins.


Regards,
Igor Escobar
*Software Engineer
*
+ http://blog.igorescobar.com
+ http://www.igorescobar.com
+ @igorescobar http://www.twitter.com/igorescobar





On Tue, Sep 13, 2011 at 6:13 PM, Alex Nikitin niks...@gmail.com wrote:

 +1 on terminal.

 For gui-based ones, i like to be able to syntax check my code and run it
 from within the editor window, tabs for dozens of files i usually have open
 at once, highlight that supports many languages as i can be working on many
 at once (php, css, js, ruby, python, C, lua, sql, for the ones i have open
 in geany atm), shortcuts are essential for things like find or replace in a
 selected area or what have you, regex support in search, and something that
 can be themed with white on black.

 For web-based ones, i never want to have to physically press anything to
 save my work, and i expect it to be within a few words if i just closed the
 browser and came back. It can't use any more resources than a usual
 web-page
 and has to be responsive.

 For other features to think about, built in version control system, ability
 to sync with github or really any cvs/svn/git repo, diff tool integrated
 into the editor, collaboration.

 Essential 1: utmost security, if they pwn your servers, they should not be
 able to have my data, this means that some part of what i pass to you in my
 credentials needs to not even reside on your servers (for example you can
 use the salted hash to check my the password, but the clear text version is
 still needed to decrypt that user's data store) and for the ultra paranoid,
 i should be able to further protect my data store with another password the
 hash for which you don't store, but rather store the md5 of the hash.
 Essential 2: reliability, i would like to be in an N+N+1 where the service
 and my data are both highly available without performance degradation when
 one of the services/servers goes kablewey (technical term)

 Enjoy.


 --
 The trouble with programmers is that you can never tell what a programmer
 is
 doing until it’s too late.  ~Seymour Cray



 On Tue, Sep 13, 2011 at 4:35 PM, Robert Cummings rob...@interjinn.com
 wrote:

  On 11-09-13 03:56 PM, Brad Huskins wrote:
 
  Hello all you php coders out there,
 
  I'm doing an Open Source text editor (just a hobby) that's designed for
  PHP developers and is accessible through the web. This has been stewing
  for a while, and has gotten to the point where I can use it for my own
  work. I would like any feedback on things that people really
  like/dislike about their current editors, as I believe some of these
  things could be resolved in mine.
 
  I currently have username/password protection (with Salted-Hash
  passwords), a file-system browser, file loading/saving, and syntax
  highlighting -- and these things seem to work reasonably well. As well,
  most things about the editor are scriptable with JavaScript. This would
  seem to imply that in a few weeks I would have something useful. So I
  would like to get some feedback on what features people would most want,
  since I am still at a very flexible stage in development.
 
  If you would like to see what I have, you can go to
  un1tware.wordpress.com. You can also peruse the code at
  github.com/bhus/scriptr. In particular, the README on github gives a
  little bit better rationality for why something like this might be
  useful, and how things are currently structured.
 
 
  I'm a big fan of editors that work in the terminal.
 
  Cheers,
  Rob.
  --
  E-Mail Disclaimer: Information contained in this message and any
  attached documents is considered confidential and legally protected.
  This message is intended solely for the addressee(s). Disclosure,
  copying, and distribution are prohibited unless authorized.
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 



Re: [PHP] What would you like to see in most in a text editor?

2011-09-13 Thread Brad Huskins

On 09/13/2011 04:35 PM, Robert Cummings wrote:

On 11-09-13 03:56 PM, Brad Huskins wrote:

Hello all you php coders out there,

I'm doing an Open Source text editor (just a hobby) that's designed for
PHP developers and is accessible through the web. This has been stewing
for a while, and has gotten to the point where I can use it for my own
work. I would like any feedback on things that people really
like/dislike about their current editors, as I believe some of these
things could be resolved in mine.

I currently have username/password protection (with Salted-Hash
passwords), a file-system browser, file loading/saving, and syntax
highlighting -- and these things seem to work reasonably well. As well,
most things about the editor are scriptable with JavaScript. This would
seem to imply that in a few weeks I would have something useful. So I
would like to get some feedback on what features people would most want,
since I am still at a very flexible stage in development.

If you would like to see what I have, you can go to
un1tware.wordpress.com. You can also peruse the code at
github.com/bhus/scriptr. In particular, the README on github gives a
little bit better rationality for why something like this might be
useful, and how things are currently structured.


I'm a big fan of editors that work in the terminal.

Cheers,
Rob.


Thanks for the input.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] What would you like to see in most in a text editor?

2011-09-13 Thread Daniel Brown
On Tue, Sep 13, 2011 at 18:50, Brad Huskins brad.husk...@gmail.com wrote:

 Thanks for the input.

Brad, I'd be willing to bet that, if you added in the ability for
multiple users to simultaneously view and edit the same file without
issues of corruption and such (think along the same lines as Google
Docs), you'd have quite a winner on your hands there.

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] What would you like to see in most in a text editor?

2011-09-13 Thread tamouse mailing lists
On Tue, Sep 13, 2011 at 3:35 PM, Robert Cummings rob...@interjinn.com wrote:
 I'm a big fan of editors that work in the terminal.

You'll get my emacs when you pry it out of my cold dead hands.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] What would you like to see in most in a text editor?

2011-09-13 Thread Jim Lucas
On 9/13/2011 5:23 PM, tamouse mailing lists wrote:
 On Tue, Sep 13, 2011 at 3:35 PM, Robert Cummings rob...@interjinn.com wrote:
 I'm a big fan of editors that work in the terminal.
 
 You'll get my emacs when you pry it out of my cold dead hands.
 

+1

mg too



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] What would you like to see in most in a text editor?

2011-09-13 Thread James Yerge
On 09/13/2011 08:40 PM, Jim Lucas wrote:
 On 9/13/2011 5:23 PM, tamouse mailing lists wrote:
 On Tue, Sep 13, 2011 at 3:35 PM, Robert Cummings rob...@interjinn.com 
 wrote:
 I'm a big fan of editors that work in the terminal.
 You'll get my emacs when you pry it out of my cold dead hands.

 +1

 mg too




I'd have to go agree with the exception of s/emacs/vi/ :P

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] What would you like to see in most in a text editor?

2011-09-13 Thread Brad Huskins

Daniel,

Thanks for your response. That's the direction I was thinking of taking 
this, but wanted to get some input before I got ahead of myself.


-Brad.

On 09/13/2011 06:54 PM, Daniel Brown wrote:

On Tue, Sep 13, 2011 at 18:50, Brad Huskinsbrad.husk...@gmail.com  wrote:


Thanks for the input.


 Brad, I'd be willing to bet that, if you added in the ability for
multiple users to simultaneously view and edit the same file without
issues of corruption and such (think along the same lines as Google
Docs), you'd have quite a winner on your hands there.




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] What would you like to see in most in a text editor?

2011-09-13 Thread Brad Huskins

Oh geez. Didn't mean to start a flame war...

On 09/13/2011 08:56 PM, James Yerge wrote:

On 09/13/2011 08:40 PM, Jim Lucas wrote:

On 9/13/2011 5:23 PM, tamouse mailing lists wrote:

On Tue, Sep 13, 2011 at 3:35 PM, Robert Cummingsrob...@interjinn.com  wrote:

I'm a big fan of editors that work in the terminal.

You'll get my emacs when you pry it out of my cold dead hands.


+1

mg too





I'd have to go agree with the exception of s/emacs/vi/ :P



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Querying a database for 50 users' information: 50 queries or a WHERE array?

2011-09-13 Thread chetan rane
Hi,

There are 2 peoblems with subselect

1. You cant use a limit on the nested select
2. Id the number of elements in the in clause exceeds the subselect buffer
you will run into performance issues ans eventually you query will be
doomed. Inner joins in,this is the best option for this . You can use a temp
table for this
On 14 Sep 2011 01:35, Alex Nikitin niks...@gmail.com wrote:
 On Tue, Sep 13, 2011 at 3:45 PM, Dotan Cohen dotanco...@gmail.com wrote:

 On Tue, Sep 13, 2011 at 21:34, Alex Nikitin niks...@gmail.com wrote:
  And this will be faster or at least more efficient with a limit (e.g.
 limit
  50) this way when you have found the 50 users in the in statement,
you
  don't continue iterating through the rest of your data set...
 

 The number is never exactly 50 but rather some arbitrary large number.
 But there is no need for LIMIT, that is the purpose of the _INNER_
 JOIN. INNER means to only return the matching rows.


 --
 Dotan Cohen

 http://gibberish.co.il
 http://what-is-what.com


 Dotan,

 IN (the function used in all of the queries above) is not the same as an
 INNER_JOIN, inner join joins 2 tables, as you have already described, IN
 however is a function that return 1 if the value being searched for is in
 the array of its values or 0 if it is not, thus IN is not an inner join,
but
 a comparator function, thus if you are using IN, limit will indeed be more
 efficient than it's omission for exactly the reason i have stated in my
 previous post. Because your user array seems to be in php, and implode has
 been a topic of discussion above as well, setting an adequate limit is a
 simple task with the php's count function.

 This is all ofcourse void if the user array being pulled from mysql, in
 which case you could simply join the two tables to get your resulting data
 set. The trick there is to use the USING clause which seems to run a lot
 faster than any ON clause, or work on an optimized subselect, especially
if
 you are running a cluster.


 --
 The trouble with programmers is that you can never tell what a programmer
is
 doing until it’s too late. ~Seymour Cray


Re: [PHP] What would you like to see in most in a text editor?

2011-09-13 Thread Jim Lucas

On 9/13/2011 7:11 PM, Brad Huskins wrote:

Oh geez. Didn't mean to start a flame war...


Quit fanning it then... :)



On 09/13/2011 08:56 PM, James Yerge wrote:

On 09/13/2011 08:40 PM, Jim Lucas wrote:

On 9/13/2011 5:23 PM, tamouse mailing lists wrote:

On Tue, Sep 13, 2011 at 3:35 PM, Robert
Cummingsrob...@interjinn.com wrote:

I'm a big fan of editors that work in the terminal.

You'll get my emacs when you pry it out of my cold dead hands.


+1

mg too





I'd have to go agree with the exception of s/emacs/vi/ :P






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php