Jump to content

Needing help with OO MVC


TehManz

Recommended Posts

Hey guys, new here.

I am having some issues with my MVC framework I am building.

 

I have a model which extends a database abstract class.

 

class website extends database {

 

then under that i have all of my model functions to getting/setting data, etc..

 

in my 'website' controller i have the following code which is ran during one of my ajax actions:

 

$reindex_args = $this->wc->doNagivationDelete($id);
$this->wc->reindexNavigationSegment($reindex_args);

 

"$this->wc" is my 'website' model which is set in the 'website' controller __constructor() {}

 

doNagivationDelete is a simple function that deletes an item out of the database and returns a couple elements in an array (which is irrelevant)

 

here is the function:

public function doNagivationDelete($id) {
self::connect();
$query = 'SELECT `website`, `placement` FROM `navigation` WHERE `id` = \'' . $id . '\';';
$reindex_args = self::query_first($query);
$query = 'DELETE FROM `navigation` WHERE `id` = \'' . self::escape($id) . '\';';
self::query($query);	
self::close();	
return $reindex_args;
}

 

this function runs and returns data just fine ... just like all of the other function calls in the 'website' controller to the 'website' model.

 

now the odd thing (at least to me) is when the second function ('reindexNavigationSegment') tries to run.

 

once the second function runs, the parent class ('database' base class) of the 'website' model basically resets(?) ... All of the private values are back to null - resulting in an error that i am unable to connect to the server, unable to select database, unable to execute query, etc...

 

I sense that I am missing some simple OO concept here. I have been toying with this for hours! It seems that any time i try to run a second model function, the same thing happens! But the first model function always runs successful.

 

Any thoughts on this would be greatly appreciated!!

Link to comment
https://forums.phpfreaks.com/topic/200129-needing-help-with-oo-mvc/
Share on other sites

I was actually able to figure it out.

 

The close was completely destroying any further use.

 

I was not the one who wrote it, so I rewrote it to me needs.

 

I'm also now passing a database object in to the model instead of extending.

 

Problem solved :) .. those late nights will get ya

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.