php-general Digest 14 Nov 2011 18:56:23 -0000 Issue 7567

2011-11-14 Thread php-general-digest-help

php-general Digest 14 Nov 2011 18:56:23 - Issue 7567

Topics (messages 315671 through 315678):

Re: speeding up heavy web apps with a php-js cache manager
315671 by: Ashley Sheridan

Re: Novice MySQL problem
315672 by: David Robley
315673 by: Jim Giner
315674 by: David Robley
315675 by: Stuart Dallas

Re: problem with sending AT command in php
315676 by: Richard Quadling

Sniping on the List
315677 by: George Langley
315678 by: Fredric L. Rice

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 Sun, 2011-11-13 at 22:27 -0500, Plamen Ivanov wrote:

 On 11/13/2011 01:39 PM, Ashley Sheridan wrote: 
 
  On Sun, 2011-11-13 at 18:39 +0100, rene7705 wrote:
  

  
   Hi.
   
   I'm developing a CMS, with lots of javascript code.
   I haven't been satisfied with my page initialization speeds, so I've
   started on a caching system.
   
   First, i used to call up javascript as needed, and just-in-time. But that,
   on a localhost setup, results in a second and a half delay.
   So now I include all javascript for the entire CMS as inline js in the
   head of index.php. Index.php gets gzipped of course.
   The difference is really noticeable, without looking at any counters even.
   
   So far so good.
   
   Now I'd like to implement a caching system for ajax requests.
   I was thinking to take URL, GET, and POST send parameters, and compare 
   such
   a set to items in a local js cache.
   
   If the local cache is not available, the ajax request is sent as normal,
   and the result is put in the cache.
   Javascript implementation could be as easy as changing
   jQuery.ajax(ajaxCommand) to cacheManager.ajax(ajaxCommand)
   
   If the local cache is available, the onSuccess handler of the ajax request
   is called with the cached data.
   
   On the server end, the cached items are put in a global JSON FAT file,
   again with URL, GET and POST as keys to a flat plaintext filename.
   
   On the server, any normal ajaxable URL will call php code to update the
   server end cache.
   
   Index.php would query the cache for a subscription, a list of cache
   URL+GET+POST keys, and include these cached items as
   div id=cache_idx style=display:none!-- {keys :
   {URL+GET+POST+LAST_MODIFIED}, data : cached-data} --/div
   From where the javascript cache manager would be able to find the data.
   
   The javascript cache manager would include some kind of polling system, to
   get near realtime updates for it's cached data.
   
   I'm convinced caching of ajax results would further increase my page
   initialization speeds.
   
   I'm interested to learn about potential pitfalls, any opensource libraries
   that already do this, or any other tips you can think of.
   
   Thanks for your time.
   
  
  
  You shouldn't really cache POST requests. GET data is only ever meant to
  fetch data from a server, which works well with caching, but POST is
  meant to change the state of something on the server, so it may never
  make sense to cache that, and could cause problems later on with things
  being cached even if they appear as if they shouldn't.
  
  If there are certain chunks of the content that will never change then
  you could cache those I guess, although not sure how you would be able
  to do that at the server level.
  
  Another way to add some speed is to minify your Javascript, be it inline
  or in a different file, which results in less bandwidth being used to
  send the data, and less time to send it as it's smaller. Images can be
  combined into a sprite map which can reduce the requests in the same way
  you reduced them by making your Javascript inline.
  
  If you use libraries like JQuery, use a public one such as that found on
  Google Code. Many sites use it, so it is more likely a user has it
  cached on their machine already from visiting another site that uses it.
  
  These are all pretty basic techniques, and although they don't answer
  your question exactly, they may be useful for you to achieve the same
  goal.
  

 
 What exactly do you mean by i used to call up javascript as needed,
 and just-in-time.? If you have a lot of dependencies having lag makes
 sense because of the cascade of calls. Bundle up all your static
 scripts in one JS file and compress. It should get cached most modern
 browsers. Anyhoo, I don't really know how caching works, but this
 might help: HTTP ETag. 
 
 As a side note: don't do inline -
 http://robertnyman.com/2008/11/20/why-inline-css-and-javascript-code-is-such-a-bad-thing/
 
 


Please try to remember to keep the list copied into the replies so that
everyone can benefit.

-- 

[PHP] Re: Novice MySQL problem

2011-11-14 Thread David Robley
Jim Giner wrote:

 
 drive view drivev...@gmail.com wrote in message
 news:cam4sn2ip7yncw2-2soq-vjk8suer7u5x96fvpeqoitkkcaj...@mail.gmail.com...
 Hi,

 I'm a novice to MySQL and am currently facing the following difficulty.
 I'm trying to update a table with a row of data the primary key of which
 is
 an ID which I believe is an auto incrementing serial number.  My first
 question is how to check if this is the case.

 
 If you are updating a row, you should already know the id of the record,
 so
 in your update statement you reference it in the where clause.   (ie,
 where rec_id = $curr_rec_key)
 
 Secondly while trying to insert such a row leaving out this column mySql
 is
 inserting the row at ID 0 (the previous ID's in the table are from 1 to
 9),
 but then will not take further inserts.

 Thanks for any help available.


 Regards

 Toni

 
 I don't know what the problem here is.  Personally I never use auto-inc
 fields.

That statement tells us you have a poor understanding of the concept of
relational databases, or you don't use relational tables.


Cheers
-- 
David Robley

Sure, it's clean laundry. The cat's sitting on it, isn't he?
Today is Pungenday, the 26th day of The Aftermath in the YOLD 3177. 


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



[PHP] Re: Novice MySQL problem

2011-11-14 Thread Jim Giner
Actually, no it doesn't,  since I have a well-developed sense of all of 
that, but that's not helping to answer the OP's question now, is it?  Stay 
on point. 



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



[PHP] Re: Novice MySQL problem

2011-11-14 Thread David Robley
Jim Giner wrote:

 Actually, no it doesn't,  since I have a well-developed sense of all of
 that, but that's not helping to answer the OP's question now, is it?  Stay
 on point.

Probably it helps the OP about as much as your statement that 'I don't know
what the problem here is.  Personally I never use auto-inc fields.'



Cheers
-- 
David Robley

Useless Invention: Kickstand for a tank.
Today is Pungenday, the 26th day of The Aftermath in the YOLD 3177. 


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



Re: [PHP] Novice MySQL problem

2011-11-14 Thread Stuart Dallas
On 14 Nov 2011, at 11:47, Jim Giner wrote:

 Actually, no it doesn't,  since I have a well-developed sense of all of 
 that, but that's not helping to answer the OP's question now, is it?  Stay 
 on point. 

The OP's problem is solved, so the point is no longer relevant.

I'm curious to know what your well-developed sense of all of that does when 
in lieu of auto-incrementing fields, and why.

The only legitimate reason I've ever come across to avoid them is when you 
expect to need to partition data across multiple master DB servers. Is this why 
you avoid them?

-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



Re: [PHP] problem with sending AT command in php

2011-11-14 Thread Richard Quadling
On 12 November 2011 20:02, a dehqan dehqa...@gmail.com wrote:
 dio_write($handle, 'AT')  dio_write($handle, AT) make firefox times out
 on Waiting for localhost ... .
 But dio_write($handle, AT\n) makes it prints AT exactly the same command
 or  A  A , ..

 On Sat, Nov 12, 2011 at 10:02 PM, Negin Nickparsa nickpa...@gmail.comwrote:

 are you sure about ATD03518726535\n?

  can you try if ( dio_write($handle, 'AT') )?



Don't use \n, use \r.

http://en.wikipedia.org/wiki/AT_commands#Example_session



-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc : Fantasy Shopper
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea :
fan.sh/6/370

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



[PHP] Sniping on the List

2011-11-14 Thread George Langley
Am concerned over the number of posts that appear to be from people 
trying to over-inflate their self-importance.
If you are the world's best coder, then help those of us who aren't. If 
you happen to know a better way to do something that I'm struggling with, then 
please share it. But if you just want to take pot shots at us, then please keep 
your comments to yourself.

To that end, I wish to thank Ashley Sheridan, Daniel P. Brown, Tedd 
Sperling and Tommy Pham, to name but just a few of those who have submitted 
incredibly-helpful posts, that I have kept for reference. Your contributions 
are very much appreciated - thanks.


George Langley
Interactive Developer

www.georgelangley.ca

Re: [PHP] Sniping on the List

2011-11-14 Thread Fredric L. Rice
 If you are the world's best coder

That would be me. :)



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



[PHP] Problems with proc_open and getmypid

2011-11-14 Thread Francisco M. Marzoa Alonso
Hello,

I'm developing a PHP application that runs on GNU/Linux with php cli. A
process must launch another one and store its pid, so I use proc_open
and then proc_status to achieve that.

The child process must also get its own pid and write it down to a file.

After that, the calling process should compare both pids and they should
match, but in fact they shoudln't.

The problem is that when calling to proc_open like:

$res = proc_open (/usr/bin/php proc2.php, array(), $pipes);

Two processes are created, one for the sh shell that launchs the php
interpreter, and another for the php interpreter itself. Also, it seems
like proc_get_status($res) returns the status of the sh, while getmypid
in the second process returns the pid of the php interpreter.

I wonder if there's anyway of do something of these:

a) Get the pid of the php interpreter on proc_open instead of the sh one
on the parent process, or...

b) Get the pid of the sh process instead of the php interpreter on the
child process.

Or any manner in which two pids matches.

Thanks a lot in advance,

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



Re: [PHP] Novice MySQL problem

2011-11-14 Thread Tommy Pham
On Mon, Nov 14, 2011 at 4:11 AM, Stuart Dallas stu...@3ft9.com wrote:
 On 14 Nov 2011, at 11:47, Jim Giner wrote:

 Actually, no it doesn't,  since I have a well-developed sense of all of
 that, but that's not helping to answer the OP's question now, is it?  Stay
 on point.

 The OP's problem is solved, so the point is no longer relevant.

 I'm curious to know what your well-developed sense of all of that does when 
 in lieu of auto-incrementing fields, and why.

 The only legitimate reason I've ever come across to avoid them is when you 
 expect to need to partition data across multiple master DB servers. Is this 
 why you avoid them?

 -Stuart

 --
 Stuart Dallas
 3ft9 Ltd
 http://3ft9.com/



Even with clustering, not comparing inherent clustering technique
between RDBMSes, consider the following (MySQL) table example:

CREATE TABLE `my_cluster_sample` (
 `pkID1_AutoInc` bigint(11) NOT NULL AUTO_INCREMENT,
 `pkID2_SrvrID` int(11) NOT NULL DEFAULT '1' COMMENT 'Use # of
designated server ID',
 `name` varchar(50) NOT NULL,
 PRIMARY KEY (`pkID1_AutoInc`,`pkID2_SrvrID`)
)

The only reason that I see where not to use integer types with auto
increment for PK is when you have an insane _LARGE_ number of rows, in
any given DB instance/server.  Then, the integer type no longer
applies and the use of GUID/UUID or other surrogate types comes in,
aside from getting into hot debate/discussion about pros  cons of
natural vs surrogate keys even if you don't have large amount of data
;)

Regards,
Tommy

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