Re: Php-Object Orientated php(oop)
| From: | David Tajchreber | Date: | Thu, 17 Jun 2010 05:04:34 +0000 |
| Subject: | Re: Php-Object Orientated php(oop) | ||
| References: | 1 | Groups: | php.webmaster |
| Request: | Send a blank email to php-webmaster+get-8377@lists.php.net to get a copy of this message | ||
On Wed, 16 Jun 2010 12:00:18 +1000, Aaron Thompson wrote:
> Hello, my name is Aaron1178
> I have lots of exp with php, but when it comes to Object orientated php,
> im pretty fresh.
> I have just developed a a error handler.
>
> <?php
> class error_handle
> {
>
> function connect($on,$page,$line)
> {
>
> $this->on = $on;
> $this->page = $page;
> $this->line = $line;
> if($this->on == 1)
> {
> $error = die ("The Mysql Driver has been turned
off by the Admin,
> The site might be under-going maintainence, Please come back later.");
> return $error;
> exit;
> }
>
> else
> {
> $error = die("You have a Syntax error in your
'Connect'
> Statement.<br />Page: {$this->page}<br />Line: {$this->line}");
> return $error;
> exit;
> }
>
> }
>
> function db($on,$page,$line)
> {
>
> $this->on = $on;
> $this->page = $page;
> $this->line = $line;
> $this->on = $on;
> if($this->on == 1)
> {
> $error = die ("The Mysql Driver has been turned
off by the Admin,
> The site might be under-going maintainence, Please come back later.");
> return $error;
> exit;
> }
>
> else
> {
> $error = die ("You have a Syntax error in your
'Database selection'
> statement.<br />Page: {$this->page}<br />Line: {$this->line}");
> }
> }
>
> function query($on,$page,$line)
> {
>
> $this->on = $on;
> $this->page = $page;
> $this->line = $line;
> $this->on = $on;
> if($this->on == 1)
> {
> $error = die ("The Mysql Driver has been turned
off by the Admin,
> The site might be under-going maintainence, Please come back later.");
> return $error;
> exit;
> }
>
> else
> {
> $error = die ("You have a Syntax error in your
'Query'
> statement.<br />Page: {$this->page}<br />Line: {$this->line}");
> }
> }
>
> function fetch_array($on,$page,$line) {
>
> $this->on = $on;
> $this->page = $page;
> $this->line = $line;
> $this->on = $on;
> if($this->on == 1)
> {
> $error = die ("The Mysql Driver has been turned
off by the Admin,
> The site might be under-going maintainence, Please come back later.");
> return $error;
> exit;
> }
>
> else
> {
> $error = die ("You have a Syntax error in your
'Fetch_array'
> statement.<br />Page: {$this->page}<br />Line: {$this->line}");
> }
> }
>
> function num_rows($on,$page,$line)
> {
>
> $this->on = $on;
> $this->page = $page;
> $this->line = $line;
> $this->on = $on;
> if($this->on == 1)
> {
> $error = die ("The Mysql Driver has been turned
off by the Admin,
> The site might be under-going maintainence, Please come back later.");
> return $error;
> exit;
> }
>
> else
> {
> $error = die ("You have a Syntax error in your
'Query'
> statement.<br />Page: {$this->page}<br />Line: {$this->line}");
> }
> }
>
> }
>
> ?>
>
> That is the error_handle page.php now in my classes.php i have this
> function:
>
> function handle($query,$page,$line)
> {
> $this->page = $page;
> $this->line = $line;
> $this->query = strtolower($query);
> include "error_handle.php";
> $error = new error_handle;
> //To make life easier
> $qa = explode(">",$this->query);
> $qa2 = explode("()",$qa['1']);
> if(method_exists($error,$qa2['0']))
> {
> if($this->sql == false)
> {
> $on = 1;
> }
> else
> {
> $on = 0;
> }
>
> $error->$qa2['0']($on,$page,$line);
> }
>
> else
> {
> $rand = rand(1,35);
> $error_code = "M_{$rand}({$qa2['0']})"; $i = die ("Sorry,
You
> are curently experiancing an game
> error, please email help@king-Arthur-And-Camelot.com with the following
> error code<br />{$error_code}");
> return $i;
> }
> }
>
> Then on normal pages i write:
> $kaac = new driver(name of class);
> $kaac->connect() or
> $kaac->handle('$kaac->connect','page','line');
>
> Now it all works, i was wondering if it is a good error_handler. it will
> only work for mysql so far. but when i add it to errors would it be a
> quick process or what.
>
> I am enquiring on behalf of myself Aaron1178, to see if this is a good
> error_handler
>
> Thanks for reading
>
> Thanks Aaron1178
Aaron, send your question to the php.general newsgroup. php.webmaster is
for topics related to the php.net website. You can read more here: http://
php.net/mailinglists
David