Since you know have complete class information, I have updated my answer to give more specific review comments on your code below. My comments are within multi-line comments.
/*
Class name seems non-specific
*/
class Spec
{
/*
Typical style guides would have class properties defined before class methods.
All methods should have visibility (i.e. public, protected, private) explicitly
defined.
Consider using a constructor such that you could do something like:
$spec = new Spec($id);
Where the constructor could call the load method. This would allow you to make
load method private, meaning calling code couldn't destructively reload
the object. This will also allow you to validate the id input as integer
value greater than zero before trying to do any further work in instantiating
the class.
If you are going to use PHPDoc, use it on every method and property as well as
class itself. Don't partially use documentation.
*/
function load()
{
/*
Consider working with DB in an object-oriented fashion, with database object
dependency being passed to this class on instantiation.
Consider using parametrized prepared statements here rather than string
interpolation. String interpolation raises question as to whether you might
be opening up an SQL injection vulnerability.
Don't use 'SELECT *'. It makes expected return results unclear to the code
reader and also potentially negatively impacts performance if you end up
retrieving more fields than necessary.
This DB interaction only considers happy path. What if query fails for some
reason? What if an empty result set is returned?
*/
$result = db_query("SELECT * from spec where id = {$this->id}");
$row = db_fetch_array($result);
$this->n = $row['n'];
$this->sg = $row['sg'];
$this->q = $row['q'];
}
/**
* Computes and returns Pressure
* Outputs debug info
* Assigns internal parameter
*
/*
"number" is not a valid @return type. It looks like you should be using "float".
*/
* @return number
*/
/*
I really don't understand why you would need to make this method publicly
available. If you had a constructor, you could pass that constructor the id
(as well as a valid DB object if you choose to work with DB in OO fashion)
and then execute private load and calcPressure methods, setting up the object
for its intended use directly upon instantiation.
*/
function calcPressure()
{
$res = abs($this->n * sqrt($this->q) / 15164.93 * $this->sg);
/*
Don't output from this class.
*/
dump(" *** <u>Pressure</u> = $res");
$this->pressure = $res;
/*
You would probably not need a return if you made this private method called
from constructor.
*/
return $res;
}
/*
Consider whether these should be public. My guess is that they shouldn't be
unless you REALLY want the object to be mutable since you are reading this
information from a database and haven't shown an update method.
If you do intend to make the object mutable, then it still probably makes sense to make these private so that you can have proper setters that can trigger
methods to update the database and recalculate pressure.
If you make them private, you would obviously need to implement getters or
__get() magic method to allow caller to get to the information.
As you begin to work more with OOP, you will likely find that the use cases
for truly public properties are fairly limited.
*/
public $pressure;
public $sg;
public $q;
public $n;
public $id;
}