php-general Digest 15 Dec 2012 13:26:56 -0000 Issue 8066
Topics (messages 319884 through 319889):
Weird MySQL+Gearman issue
319884 by: FeIn
Re: Weird MySQL+Gearman issue - SOLVED
319885 by: FeIn
Formatting -- defining sections of code
319886 by: Andy McKenzie
319887 by: Paul M Foster
319888 by: Larry Martell
Re: storing & searching docs
319889 by: tamouse mailing lists
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
----------------------------------------------------------------------
--- Begin Message ---
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.
--- End Message ---
--- Begin Message ---
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.
--- End Message ---
--- Begin Message ---
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...
Thanks,
Andy
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
On Dec 13, 2012 4:50 PM, "Jim Giner" <jim.gi...@albanyhandball.com> wrote:
>
> Thanks for all the posts. After reading and googling all afternoon, I
think the best approach for me is:
>
> Create two macros in Word (done!) to export each of my .doc files to .txt
and .pdf formats.
>
> Create a sql table to hold the .txt contents of my .doc files, along with
a reference to the meeting date and the name of the corresponding .pdf file.
>
> Upload my two sets of files with an ftp client and then use a script to
load the table with my .txt file data.
>
Why not use php to upload the set of files?
> Now I just need a couple of scripts to allow a user to locate a file and
bring up the pdf for when he wants to read about a meeting. And a second
script to accept user input (search words) and perform a query against the
textual data and present some kind of results - probably a listing
containing a reference to the meeting date and a tbd-length string showing
the matching result for each occurrence, ie, something like n chars in
front of and after the match so the user can see the context of the match.
>
> Sizes - a 28k .doc file grows to 142kb in .pdf format and is only 5kb in
.txt format. (actually, if I 'print' the .doc as a pdf instead of using
the Word's "File,Save as", the resulting pdf is only 70kb. Might need a
new macro!)
>
> Thanks again!
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---