Re: [PHP] Weird MySQL+Gearman issue - SOLVED

2012-12-14 Thread FeIn
On Fri, Dec 14, 2012 at 7:41 AM, FeIn aci...@gmail.com wrote:
 Hi all,

 I have a typical web application that does some basic CRUD operations.
 Operations that modify the database (inserts, updates, deletes)
 trigger a background gearman job to refresh the cache that is used for
 another application. The problem is that when I do an update the
 gearman worker script (which has its own database connection) does not
 pick up the updates. For example if I were to update a row: UPDATE
 table SET rowname = 'updated value' WHERE rowid = 1, the respective
 row is updated correctly, but when the worker gets around to handle
 the job of refreshing the cache for that row the SELECT FROM table
 WHERE rowid = 1 picks up the older value (the one before the update).
 I activated the mysql log and the queries are definitely run in the
 correct order (first the update and the select on a another
 connection). Has anybody encountered this issue before? I should also
 mention that the worker is setup to run a certain number of cache
 refreshing jobs after which it will die, but it will use the same
 connection to do those jobs. If I force the worker to use a new
 connection for each job everything works fine, otherwise the update is
 picked up only for the first job but not for the subsequent jobs. Any
 ideas?

 Thanks in advance.

The problem was on my side, and it had to with Doctrine's identity
map. I cleared Doctrine's entity manager for every job handled by the
Gearman worker and it seems that everything works fine now.

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



Re: [PHP] Formatting -- defining sections of code

2012-12-14 Thread Paul M Foster
On Fri, Dec 14, 2012 at 10:48:05AM -0500, Andy McKenzie wrote:

 Hey folks, kind of a strange question here.
 
 Basically, I've been trying to move my style from self taught to Oh
 yeah, there IS a standard for this.  One of the things I frequently
 want to do is define sections of my code:  to take a simplistic
 example, this outputs everything that needs to be in file A, this
 outputs what needs to be in file B, and so on.
 
 Up until now, I've used my own standards (generally 
 SectionName, since it's easy to search for).  But it occurs to me to
 wonder;  IS there a standard for this?  Most likely, the programming
 world being what it is, there either isn't one or there are lots of
 competing standards, but I'd be interested to know...

A *standard* for something? ROTFL! Yeah, like there's a standard for
herding cats! [guffaw]

Seriously, no I know of no such standards. It sounds like you're
thinking of the kind of thing that's more common in languages like COBOL
than anything modern. Plus, it's near impossible on any significantly
sized project to segregate code in such a way.

That said, I would recommend PHPDoc or similar. It's a package for
generating code documentation from the comments embedded in your code.
You adhere to certain conventions in the format of your comments, and
PHPDoc can scan your code and produce pretty docs. Plus, the comments
themself serve as a sort of discipline in explaining what functions and
sections of code do. If you keep your functions to singular, small tasks
(as you should), the comments are invaluable when you come back later to
try to figure out what you were thinking when you wrote this or that
block of code.

I don't know how extensive your experience is with coding or PHP. So in
case you're a relative newbie, I'd also suggest that you keep classes in
their own files (one file per class) in a libraries directory or
somesuch. In fact, I'd suggest downloading something like CodeIgniter,
and studying the way they structure their code physically. They may not
be the optimum example, but for a well-known framework, their code base
is relatively slim and well-organized. Also, obviously, study the MVC
(model-view-controller) paradigm. It's a very useful way of dividing up
your code's functionality.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] Formatting -- defining sections of code

2012-12-14 Thread Larry Martell
On Fri, Dec 14, 2012 at 11:20 AM, Paul M Foster pa...@quillandmouse.com wrote:
 On Fri, Dec 14, 2012 at 10:48:05AM -0500, Andy McKenzie wrote:

 Hey folks, kind of a strange question here.

 Basically, I've been trying to move my style from self taught to Oh
 yeah, there IS a standard for this.  One of the things I frequently
 want to do is define sections of my code:  to take a simplistic
 example, this outputs everything that needs to be in file A, this
 outputs what needs to be in file B, and so on.

 Up until now, I've used my own standards (generally 
 SectionName, since it's easy to search for).  But it occurs to me to
 wonder;  IS there a standard for this?  Most likely, the programming
 world being what it is, there either isn't one or there are lots of
 competing standards, but I'd be interested to know...

 A *standard* for something? ROTFL! Yeah, like there's a standard for
 herding cats! [guffaw]

The nice thing about standards is that there are so many of them to choose from.
  -Andrew S. Tanenbaum

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