Hi,

I have a function in my database management class. What i want it to perform is that when i query the database which returns a single value, the function can do it for me.

For example:
My query is "SELECT Username FROM Customer WHERE CustomerID = 1"

This query will return a single value result.

My current function is this:

public function executeScalar($aQuery) {
$this->dbResult = mysql_query($aQuery,$this->getDBConnection()) ;
$this->dbDataRow = mysql_fetch_row($this->dbResult) ;
$this->retrievedValue = $this->dbDataRow[0] ;
return $this->retrievedValue ;
}

I have other functions such as:
- connect() : This function connect to the database with the login information
- close() : This function closes the connection to the database
- getDBConnection() : This function returns the current database connection
- isConnected() : This function returns boolean variable whether there is connectivity to the database.

I hope someone can assist me with this. Besides this, I also need a function to perform commands such as UPDATE, DELETE and INSERT.

The function would actually returns the number of rows affected in the query. Could someone please assist me in that function? This is because I've tried many ways and I could not derive at the solution.

The function header is:
public function executeNonQuery($aQuery) {
//Returns an integer indicating the number of rows affected in this query
}

Thank you.