Should beginners to php use PEAR???
Moderator: General Moderators
-
ant_sutton
- Forum Commoner
- Posts: 32
- Joined: Thu May 05, 2005 5:27 am
Should beginners to php use PEAR???
Hi guys. I'm fairly new to php and have come across the PEAR code packages. I know this makes it easier for programmers when building sites but my question is because I'm quite enw to PHP would it be better for me to learn how to code the funtions myself instead of just linking to PEAR code which I don't understand??
Also, do you professional web developers use PEAR alot or code everything yourself?
thanks alot
Anthony
Also, do you professional web developers use PEAR alot or code everything yourself?
thanks alot
Anthony
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
-
ant_sutton
- Forum Commoner
- Posts: 32
- Joined: Thu May 05, 2005 5:27 am
re
Hey. thanks for your reply. I think I will give it a go. Another question: This is the way I'm trying to create a table. I can do it without PEAR easily but this way table isn't being created. ANy ideas?
cheers
cheers
Code: Select all
require 'DB.php';
$db = DB::connect('mysql://root@localhost/restaurant');
if (DB::isError($db)) { die("Can't connect: " . $db->getMessage( )); }
$q = $db->query("CREATE TABLE dishes (
dish_id INT,
dish_name VARCHAR(255),
price DECIMAL(4,2),
is_spicy INT
)");-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
Try changing the following:
To:
Code: Select all
$q = $db->query("CREATE TABLE dishes (
dish_id INT,
dish_name VARCHAR(255),
price DECIMAL(4,2),
is_spicy INT
)");Code: Select all
$db->query("CREATE TABLE dishes (
dish_id INT,
dish_name VARCHAR(255),
price DECIMAL(4,2),
is_spicy INT
)");The only Pear package I use frequently is HTML_QuickForm, and I am pretty happy with it... it's far from perfect, but it's definately better than any other form library I've come across. One nice thing I can say about PEAR is that its installer couldn't be any easier.
There's no problem with using libraries/packages... a lot of time, in the real world there are deadlines and you have no choice but to use them.. it just makes sense. I'm sure you've heard the saying "Why re-invent the wheel?"
The longer you code though, the more you will find yourself stretching the limits of the libraries, and beginning to see their pitfalls as well... but by that time you'll be a pro and have a stockpile of your own code all over your hard drive.
There's no problem with using libraries/packages... a lot of time, in the real world there are deadlines and you have no choice but to use them.. it just makes sense. I'm sure you've heard the saying "Why re-invent the wheel?"
The longer you code though, the more you will find yourself stretching the limits of the libraries, and beginning to see their pitfalls as well... but by that time you'll be a pro and have a stockpile of your own code all over your hard drive.
I've never used pear.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
-
ant_sutton
- Forum Commoner
- Posts: 32
- Joined: Thu May 05, 2005 5:27 am
re
Hi guys. thanks so much for your responses, great help. I think I've decided to learn php a bit more before trying to use PEAR since it's oviously not strictly necessary at this point if some of you rarely use it. But I do realise the benefits of it. I've also decided this as I still can't seem to create a simple table using pear anyway
I've added a primary key and chnaged the code that the guy with the weird user name suggested but I still can't get it to create the table.
ANy more ideas on why this is happening will be much appreciated. thanks alot
Anthony
ANy more ideas on why this is happening will be much appreciated. thanks alot
Anthony
-
ant_sutton
- Forum Commoner
- Posts: 32
- Joined: Thu May 05, 2005 5:27 am
re
Hi tim. thanks for your reply.
I'm sure I have all privileges to make a table. I can do it using the same user and password wihtout pear. the get error doesn't return any error message. I run the script and the page is just blank as it should be but the table doesn't get created
cheers
Anthony
I'm sure I have all privileges to make a table. I can do it using the same user and password wihtout pear. the get error doesn't return any error message. I run the script and the page is just blank as it should be but the table doesn't get created
cheers
Anthony
Try checking if $q is an error -ant_sutton wrote:Code: Select all
$q = $db->query("CREATE TABLE dishes ( dish_id INT, dish_name VARCHAR(255), price DECIMAL(4,2), is_spicy INT )");
Code: Select all
if(DB::isError($q)) { die("Error in query: " . $q->getMessage( )); }Assigning the result of $db->query to $q has no effect on whether the table is created or not.
-
ant_sutton
- Forum Commoner
- Posts: 32
- Joined: Thu May 05, 2005 5:27 am
re
Hi dranger. thanks for the code. I added it but still no error s returned. just a blank page. I'mreally not sure waht that means. I'ts getting really annoying now.
cheers
Anthony
cheers
Anthony