[PHP] newbie questions
Guys, I am fairly new to PHP. Here are a few questions, if anybody can answer it will help me get started. Thanks I am trying to build a website and I would like to do the following in my scripts 1. I want to return response to the browser and AFTERWARDS make a log entry in to a database. I need this so user can experience a fast response. 2. If the database update fails, I want to ignore it (since it is just log entry). Something like try-catch construct in Java. This is more important if item1 mentioned above is not possible. Essentially whether I make a database entry or not, I must return a valid response to user. 3. Is there something like connection pool in php? Do usually people open/close database connection for every request (I doubt that, it sounds really slow). Some code samples or pointers to documentation for the above would also be very helpful. Thanks Ravi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie questions
Documented research indicates that on Sun, 29 Aug 2004 21:00:06 +, Paul Waring wrote about "Re: [PHP] newbie questions": >> The constructor for Content accepts an >> object ... why is &$db used instead of $db? > >&$variable means to pass the variable by reference (as opposed to >passing by value, which is the default). Instead of making a copy of >the variable, you are telling $this->db to point to the same point in >memory as the original $db - in effect you are using two names to >point to the same data. If you modify $this->db, $db will also be >modified and vice versa. heh ... nice reply Paul ... much clearer than when my programming teacher tries to explain it heh (I'm studying for Programmer/System Developer, and our C++ teacher is rather crummy at explaining stuff) -- Rene Brehmer aka Metalbunny If your life was a dream, would you wake up from a nightmare, dripping of sweat, hoping it was over? Or would you wake up happy and pleased, ready to take on the day with a smile? http://metalbunny.net/ References, tools, and other useful stuff... Check out the new Metalbunny forums at http://forums.metalbunny.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] newbie questions
Hello Torsten, Thanks for the answers ... it's all becoming clearer. Sunday, August 29, 2004, 3:08:01 PM, you wrote: TR> Hi Kevin, TR> with PHP4 &$db means the value is passed by reference. Otherwise a copy of TR> $db would be passed to the method. See here: TR> http://de2.php.net/references TR> With PHP5 variable assignments or passing variables to functions by TR> reference is standard. $this->db is the PHP equal to this.varName. TR> You access property db of the current object. Methods are called this way: TR> $this->methodName() TR> Hope this clears things up a bit. -- Best regards, Kevin Bridges mailto:[EMAIL PROTECTED] Independent Contractor 303.809.4427 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie questions
> The constructor for Content accepts an > object ... why is &$db used instead of $db? &$variable means to pass the variable by reference (as opposed to passing by value, which is the default). Instead of making a copy of the variable, you are telling $this->db to point to the same point in memory as the original $db - in effect you are using two names to point to the same data. If you modify $this->db, $db will also be modified and vice versa. Only the author of the code could tell you exactly why they chose to do things this way, but one possible reason is that when you close the database link (using $this->db->disconnect() if it's PEAR::DB) it will disconnect all the pointers to that link rather than just the one local to the class (which would be the case if it was passed in by value). Passing a reference rather than a copy also means you're not storing multiple database links in memory which could affect performance if the code was called often (e.g. on a busy web site). Hope this helps, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] newbie questions
Greetings php-general, I'm just starting out with php ... judging from the posts I've been reading on this list I'm thinking this question is so basic it might almost be pathetic! I'm assuming the answers are in the php manual, but I have not found the correct pages ... any pointers to manual pages, tutorials, or an explanation would be greatly appreciated. db = $db; } } ?> I'm writing my first class following an example I found on the web and I have 2 questions. The constructor for Content accepts an object ... why is &$db used instead of $db? I'm used to a this.varName syntax from other languages ... I grasp what is happening with $this->db, but I don't understand the literal translation of -> and would like help understanding. -- Best regards, Kevin Bridges mailto:[EMAIL PROTECTED] Independent Contractor 303.809.4427 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie questions
Jason Wong wrote: Anything else anyone could tell me would be great! Depends on what you want to know. Almost every problem that you will come across will be covered in: - the php manual - the list archives - google Don't forget about Mr. Holmes. I betcha he's got php scribbled all over the walls of his house...so the OP could check there. ;) -- By-Tor.com It's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie questions
On Thursday 12 February 2004 01:03, James Marcinek wrote: > I have a couple of questions I'd like to ask: > > 1.) Are there built in libraries to connect to DB2? > Nothings clear from the documentation I've read. I see > that there's libraries for Oracle, Informix, MySQL. Apparently so, ask google. > 2.) If there is a DB2 library(support or whatever its > called, someone enlighten me please with the correct > term!) does anyone know if the Red Hat rpm comes with > the option to support this turned on? Ask RedHat? > 3.) I'm just coming across some information about > PEAR. My question to this: Is it better to use PEAR > than the regular libraries included? What exactly do you mean by "the regular libraries included"? Basically using the PEAR libraries will save you from re-inventing many wheels, the downside being the extra overhead required. www.phpclasses.org is also a great source of classes/libraries. > Anything else anyone could tell me would be great! Depends on what you want to know. Almost every problem that you will come across will be covered in: - the php manual - the list archives - google -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* All diplomacy is a continuation of war by other means. -- Chou En Lai */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Newbie questions
Hey Everyone, I have a couple of questions I'd like to ask: 1.) Are there built in libraries to connect to DB2? Nothings clear from the documentation I've read. I see that there's libraries for Oracle, Informix, MySQL. 2.) If there is a DB2 library(support or whatever its called, someone enlighten me please with the correct term!) does anyone know if the Red Hat rpm comes with the option to support this turned on? 3.) I'm just coming across some information about PEAR. My question to this: Is it better to use PEAR than the regular libraries included? Anything else anyone could tell me would be great! Thanks, James RHCE __ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie Questions
Also checkout webmonkey.com and devarticles.com =P e p i e D e s i g n s www.pepiedesigns.com Providing Solutions That Increase Productivity Web Developement. Database. Hosting. Multimedia. On Tue, 21 Jan 2003, Neil Freeman wrote: > Have a look on devshed.com > > Bryan Cassidy wrote: > > Could someone point me to a VERY good doc for learning PHP for a > > NEWBIE!!! Something I can understand from the beginning to the end. YES > > I am willing to put my time into learning and reading docs as long as > > they are clear and made for what they say they are made for. I wont > > waste my time with something for a second if it isn't clear to me and > > easy to understand. Thanks in advance. > > -- > -- > www.curvedvision.com > -- > > > -- > 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
Re: [PHP] Newbie Questions
I just know some very basic html. lol. ya i know i know. I just havent had time to set down and learn the things I want to learn until now. On Tue, 21 Jan 2003 11:00:29 -0500 David T-G <[EMAIL PROTECTED]> wrote: > Bryan -- > > [BTW, I could not find your key on us.php.net or eu.php.net; is it on > a keyserver?] > > ...and then Bryan Cassidy said... > % > % Could someone point me to a VERY good doc for learning PHP for a > % NEWBIE!!! Something I can understand from the beginning to the end. > YES > > Do you have any programming or scripting experience? If you know even > a bit of something it's generally helpful when you want to pick up > something else. > > I speak perl and shell well, do a lot of scripting, and can read some > C(plus other things that have faded into memory :-) When I hadn't yet > met php at all, a buddy bought me the PHP Developer's Cookbook from > SAMS and it was easy to understand and presented some useful examples, > and I was able to get started and do the work he wanted me to do (when > I tried twice to thank him for the book he told me to shut up because > "it's a self-serving gift" :-) It's no "Learning Perl", but then > again it isn't supposed to be. > > Having worked my way through that, currently my only reference is the > php manual from the web site; a quick search will take me to any > function that I want to use, and only rarely am I stumped with a "how > would I even approach this task?" problem -- and then this mailing > list is wonderfully helpful. > > > HTH & HAND > > :-D > -- > David T-G * There is too much animal courage in > (play) [EMAIL PROTECTED] * society and not sufficient moral > courage.(work) [EMAIL PROTECTED] -- Mary Baker Eddy, > "Science and Health" http://justpickone.org/davidtg/ Shpx gur > Pbzzhavpngvbaf Qrprapl Npg! > > msg93784/pgp0.pgp Description: PGP signature
Re: [PHP] Newbie Questions
Bryan -- [BTW, I could not find your key on us.php.net or eu.php.net; is it on a keyserver?] ...and then Bryan Cassidy said... % % Could someone point me to a VERY good doc for learning PHP for a % NEWBIE!!! Something I can understand from the beginning to the end. YES Do you have any programming or scripting experience? If you know even a bit of something it's generally helpful when you want to pick up something else. I speak perl and shell well, do a lot of scripting, and can read some C (plus other things that have faded into memory :-) When I hadn't yet met php at all, a buddy bought me the PHP Developer's Cookbook from SAMS and it was easy to understand and presented some useful examples, and I was able to get started and do the work he wanted me to do (when I tried twice to thank him for the book he told me to shut up because "it's a self-serving gift" :-) It's no "Learning Perl", but then again it isn't supposed to be. Having worked my way through that, currently my only reference is the php manual from the web site; a quick search will take me to any function that I want to use, and only rarely am I stumped with a "how would I even approach this task?" problem -- and then this mailing list is wonderfully helpful. HTH & HAND :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, "Science and Health" http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! msg93780/pgp0.pgp Description: PGP signature
RE: [PHP] Newbie Questions
This is geared to php and mysql but I started by downloading the first four chapters of this book, which are free. http://sitepoint.com/books/?bookid=kevinyank Eddie -Original Message- From: Neil Freeman [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 21, 2003 10:52 AM To: Bryan Cassidy Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Newbie Questions Have a look on devshed.com Bryan Cassidy wrote: > Could someone point me to a VERY good doc for learning PHP for a > NEWBIE!!! Something I can understand from the beginning to the end. YES > I am willing to put my time into learning and reading docs as long as > they are clear and made for what they say they are made for. I wont > waste my time with something for a second if it isn't clear to me and > easy to understand. Thanks in advance. -- -- www.curvedvision.com -- -- 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
Re: [PHP] Newbie Questions
Have a look on devshed.com Bryan Cassidy wrote: Could someone point me to a VERY good doc for learning PHP for a NEWBIE!!! Something I can understand from the beginning to the end. YES I am willing to put my time into learning and reading docs as long as they are clear and made for what they say they are made for. I wont waste my time with something for a second if it isn't clear to me and easy to understand. Thanks in advance. -- -- www.curvedvision.com -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Newbie Questions
Could someone point me to a VERY good doc for learning PHP for a NEWBIE!!! Something I can understand from the beginning to the end. YES I am willing to put my time into learning and reading docs as long as they are clear and made for what they say they are made for. I wont waste my time with something for a second if it isn't clear to me and easy to understand. Thanks in advance. msg93774/pgp0.pgp Description: PGP signature
Re: [PHP] (newbie) questions abot vars and args
1) To echo the variables name instead of it's value, surround it instead by single quotes, not double. echo '$var' OUTPUTS $var echo "$var" OUTPUTS the contents of $var 2) Checkout the func_get_args() function. http://www.php.net/manual/en/function.func-get-args.php HTH! Martin Clifford Homepage: http://www.completesource.net Developer's Forums: http://www.completesource.net/forums/ >>> "Alexander Ross" <[EMAIL PROTECTED]> 07/26/02 11:40AM >>> 1) Given a variable how can I echo the var's name, not its value?? 2) Is there a way for PHP function to handle a dynamic number of arguments? In other words, I want to write a function that takes any number of arguments (strings) and echos each of them with a appended to each of them. Thanks for your help everybody -- 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