Your question isn't clear.
Given that you are using PHP 4 syntax for your objects, you can simply assign an object property directly to a variable. So to answer your question, yes since you have a var scoped variable which is an alias to public in PHP 5, you can simply assign it to another variable.
Public access to object properties in languages like PHP isn't exactly wise though. Since it is datatype weak, you have no way of enforcing the proper datatype to be used unless you use setters and getters.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
function count($sql_result) {
return @mysql_num_rows($sql_result);
}
function lastID() {
return @mysql_insert_id();
}
//extra functions to quicken development
//checks to see if an ID exists in a table
function doesIDExist($theTable,$idField,$theValue,&$resultSet) {
$this->queriesRun++;
$result = mysql_query("select * from $theTable where $idField=$theValue");
$myCount = mysql_num_rows($result);
if ($myCount > 0) {
$resultSet = mysql_fetch_assoc($result);
foreach($resultSet as $k=>$v) {
$resultSet[$k] = stripslashes($v);
}
return true;
} else {
return false;
}
}
//checks to see if a field is the same in another ID
function isUnique($theTable,$idField,$idValue,$uniqueField,$uniqueFieldValue) {
$this->queriesRun++;
$result = $this->query("select * from $theTable where $uniqueField=\"$uniqueFieldValue\" and $idField != $idValue");
$myCount = mysql_num_rows($result);
if ($myCount > 0) {
return false;
} else {
return true;
}
}
function doesRecordExist($theTable,$uniqueField,$uniqueFieldValue) {
$this->queriesRun++;
$result = $this->query("select * from $theTable where $uniqueField=\"$uniqueFieldValue\"");
$myCount = mysql_num_rows($result);
if ($myCount > 0) {
return true;
} else {
return false;
}
}
function deleteRecord($theTable,$idField,$idValue) {
$this->queriesRun++;
$result = $this->query("delete from $theTable where $idField=$idValue");
return true;
}
function updateRecord($theTable,$whereClause,$recArray,$myDebug=0) {
$this->queriesRun++;
$theQuery="update $theTable set ";
for ($f = 0; $f < count($recArray); $f++) {
if ($f > 0) { $theQuery .=","; }
switch ($recArray[$f][2]) {
case "S": //string
$recArray[$f][1] = str_replace("\\r\\n","{rnb}",$recArray[$f][1]);
$theQuery .= $recArray[$f][0]."=\"".mysql_real_escape_string($recArray[$f][1])."\"";
$theQuery = str_replace("{rnb}","\\r\\n",$theQuery);
break;
case "N": //number
$theQuery .= $recArray[$f][0]."=".makeInteger($recArray[$f][1]);
break;
case "YN": //yes no field
$theQuery .= $recArray[$f][0]."=\"".makeYesNo($recArray[$f][1])."\"";
break;
case "D":
$theQuery .= $recArray[$f][0]."=".makeDecimal($recArray[$f][1]);
break;
case "C":
$theQuery .= $recArray[$f][1];
break;
}
}
if ($whereClause != "") {
$theQuery .= " where ".$whereClause;
}
if ($myDebug == 1) { echo $theQuery; }
$result = $this->query($theQuery);
return $result;
}
function insertRecord($theTable,$recArray,$myDebug=0) {
$this->queriesRun++;
$theQuery="insert into $theTable (";
for ($f = 0; $f < count($recArray); $f++) {
if ($f > 0) { $theQuery .=","; }
$theQuery .= $recArray[$f][0];
}
$theQuery .= ") VALUES(";
for ($f = 0; $f < count($recArray); $f++) {
if ($f > 0) { $theQuery .=","; }
switch ($recArray[$f][2]) {
case "S": //string
$recArray[$f][1] = str_replace("\\r\\n","{rnb}",$recArray[$f][1]);
$theQuery .= "\"".mysql_real_escape_string($recArray[$f][1])."\"";
$theQuery = str_replace("{rnb}","\\r\\n",$theQuery);
break;
case "N": //number
$theQuery .= makeInteger($recArray[$f][1]);
break;
case "YN": //yes no field
$theQuery .= "\"".makeYesNo($recArray[$f][1])."\"";
break;
case "D":
$theQuery .= makeDecimal($recArray[$f][1]);
break;
}
}
$theQuery .= ")";
if ($myDebug == 1) { echo $theQuery; }
$result = $this->query($theQuery);
return true;
}
function replaceRecord($theTable,$recArray,$myDebug=0) {
$this->queriesRun++;
$theQuery="replace into $theTable (";
for ($f = 0; $f < count($recArray); $f++) {
if ($f > 0) { $theQuery .=","; }
$theQuery .= $recArray[$f][0];
}
$theQuery .= ") VALUES(";
for ($f = 0; $f < count($recArray); $f++) {
if ($f > 0) { $theQuery .=","; }
switch ($recArray[$f][2]) {
case "S": //string
$recArray[$f][1] = str_replace("\\r\\n","{rnb}",$recArray[$f][1]);
$theQuery .= "\"".mysql_real_escape_string($recArray[$f][1])."\"";
$theQuery = str_replace("{rnb}","\\r\\n",$theQuery);
break;
case "N": //number
$theQuery .= makeInteger($recArray[$f][1]);
break;
case "YN": //yes no field
$theQuery .= "\"".makeYesNo($recArray[$f][1])."\"";
break;
case "D":
$theQuery .= makeDecimal($recArray[$f][1]);
break;
}
}
$theQuery .= ")";
if ($myDebug == 1) { echo $theQuery; }
$result = $this->query($theQuery);
return true;
}
function getTableList() {
global $databaseName;
$tableList = "";
$result = mysql_query("SHOW TABLES FROM ".$databaseName);
while ($row = mysql_fetch_array($result)) {
$tableList[] = $row[0];
}
return $tableList;
}
function tableFields($result) {
return mysql_num_fields($result);
}
It'll show wherever you execute an $obj->showQueries() call. If you want to extract it to a variable, and you will need to do this on any script anyways, you can do so by rewriting the function to this:
PHP Code:
function &showQueries() { return "Total Queries: " . $this->queriesRun; }
And assigning it as:
PHP Code:
$var = &$obj->showQueries();
Now anytime you echo $var, it will be the value of $obj->showQueries.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Did you put that in a script, or did you rewrite the showQueries function? It has to be in the scope of a class since you refer to $this, so if its not in a function it'll throw an error since you cannot access $this.
I did biff this logic though. Return by references must be variables, not strings. So simply return the member:
PHP Code:
function &showQueries() { return $this->queriesRun; }
There is a downside to returning by reference though; you can rewrite a private member value this was as well since the $var in my example would refer to $this->queriesRun.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php