Class DB

Methods


fetchRowBySQL
Description:

Run a select statement and return the resulting row.

Syntax:

					array = fetchRowBySQL($sql)
				
Parameters:
Nametypedefaultdescription
$sqlstring-the select statement for the resulting row
return valuearray-the columns
Example:
$_DB->fetchRowBySQL("SELECT * FROM democontractor_customers WHERE id = $this->id");
Result:
object(stdClass)[26]
  public 'id' => int 1
  public 'Name' => string 'Purus Inc.' (length=10)
  public 'Street' => string 'Nec 3' (length=5)
  public 'Zipcode' => string '15441' (length=5)
  public 'City' => string 'Mattis' (length=6)
  public 'Country' => string 'USA' (length=3)
  public 'Tel' => string '07154 / 1732517' (length=15)
  public 'Fax' => string '07271 / 4721767' (length=15)
  public 'Email' => string 'john.purus@purus.com' (length=20)
  public 'Info' => string 'lorem ipsum' (length=11)
performSQL
Description:

a SQL UPDATE/INSERT/DELETE statement

Syntax:

					$response = $_DB->performSQL($params);
				
Parameters:
Nametypedefaultdescription
$params(object) array()-the select statement for the resulting row
return value(object) array()-the columns
Example:
$response = $_DB->performSQL((object) array(
		"type" => "INSERT",
		"table" => "_sys_userdesktop",
		"setFields" => array("User","name","callParams","DesktopParams"),
		"data" => (object) array(
				"User" => $_SESSION['UserId'],
				"name" => $data->Name,
				"callParams" => json_encode($data->callParams),
				"DesktopParams" => json_encode($data->DesktopParams)
		)
));
Result:
{
  "status": "success",
  "errorText": "",
  "timeStamp": "2018-03-19 10:47:15"
}