Low cost ecommerce web development India flash website design

if ($row = mysql_fetch_array($this->query, MYSQL_ASSOC)) {
return $row;
} else if ( $this->size() > 0 ) {
mysql_data_seek($this->query, 0);
return false;
} else {
return false;
}
}
/**
* Checks for MySQL errors
* @return boolean
* @access public
*/
function isError()
{
return $this->mysql->isError();
}
}
Now, hold your breath just a little longer until you’ve seen what using these
classes is like:
File: 5.php
<?php
// Include the MySQL class
require_once 'Database/MySQL.php';
$host = 'localhost'; // Hostname of MySQL server
$dbUser = 'harryf'; // Username for MySQL
$dbPass = 'secret'; // Password for user
$dbName = 'sitepoint'; // Database name
// Connect to MySQL
$db = &new MySQL($host, $dbUser, $dbPass, $dbName);
$sql = "SELECT * FROM articles ORDER BY title";
// Perform a query getting back a MySQLResult object
$result = $db->query($sql);
// Iterate through the results
while ($row = $result->fetch()) {
echo 'Title: ' . $row['title'] . '<br />';
echo 'Author: ' . $row['author'] . '<br />';
Fetching with Classes
echo 'Body: ' . $row['body'] . '<br />';
}
?>
If you’re not used to object oriented programming, this may seem very confusing,
but what’s most important is to concentrate on how you can use the classes, rather
than the detail hidden inside them. That’s one of the joys of object oriented
programming, once you get used to it. The code can get very complex behind the
scenes, but all you need to concern yourself with is the simple “interface” (API)
with which your code uses the class.
About APIs
It’s common to hear the term API mentioned around classes. API stands for
Application Programming Interface. What it refers to is the set of methods that act as
“doors” to the functionality contained within a class. A well-designed API will allow the
developer of the class to make radical changes behind the scenes without breaking any of
the code that uses the class.
Compare using the MySQL classes with the earlier procedural code; it should be
easy to see the similarities. Given that it’s so similar, you may ask, “Why not
stick to plain, procedural PHP?” Well, in this case, it hides many of the details
associated with performing the query. Tasks like managing the connection,
catching errors, and deciding what format to get the query results in are all handled
behind the scenes by the class. Classes also make the implementation of global
modifications (such as switching from MySQL to PostgreSQL) relatively painless
(i.e. you could just switch to a PostgreSQL class that provided the same API).

website designer freelance ASP PHP ecommerce web developer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110