/** * Generic way of using a class to define how to update a single database table. * * @param $dbObj (object) Connected instance of cs_phpDB{}. * @param $tableName (str) Name of table inserting/updating. * @param $seqName (str) Name of sequence, used with PostgreSQL for retrieving the last inserted ID. * @param $pkeyField (str) Name of the primary key field, for performing updates & retrieving specific records. * @param $cleanStringArr (array) Array of {fieldName}=>{dataType} for allowing updates & creating records. */ public function __construct(Database $dbObj, $tableName, $seqName, $pkeyField, array $cleanStringArr) { $this->set_version_file_location(dirname(__FILE__) . '/../VERSION'); parent::__construct(true); if (isset($dbObj) && is_object($dbObj) && $dbObj->is_connected()) { $this->dbObj = $dbObj; } else { throw new exception(__METHOD__ . ":: database object not connected or not passed"); } if (is_string($tableName) && strlen($tableName)) { $this->tableName = $tableName; } else { throw new exception(__METHOD__ . ":: invalid table name (" . $tableName . ")"); } if (is_string($seqName) && strlen($seqName)) { $this->seqName = $seqName; } else { throw new exception(__METHOD__ . ":: invalid sequence name (" . $seqName . ")"); } if (is_string($pkeyField) && strlen($pkeyField)) { $this->pkeyField = $pkeyField; } else { throw new exception(__METHOD__ . ":: invalid primary key field name (" . $pkeyField . ")"); } if (is_array($cleanStringArr) && count($cleanStringArr)) { $this->cleanStringArr = $cleanStringArr; } else { throw new exception(__METHOD__ . ":: invalid clean string array"); } }
public static function GetVersionObject() { if (!is_object(self::$version)) { self::$version = new cs_version(dirname(__FILE__) . '/../VERSION'); } return self::$version; }
/** * The constructor. */ public function __construct(Database $db, $logCategory = null, $checkForUpgrades = true) { //assign the database object. if (is_object($db)) { $this->db = $db; } else { throw new exception(__METHOD__ . ":: invalid database object"); } $this->set_version_file_location(__DIR__ . '/../VERSION'); parent::__construct(true); //see if there's an upgrade to perform... if ($checkForUpgrades === true) { $this->suspendLogging = true; $upgObj = new cs_webdbupgrade(__DIR__ . '/../VERSION', __DIR__ . '/../upgrades/upgrade.ini', $db); $upgObj->check_versions(true); $this->suspendLogging = false; $this->handle_suspended_logs(); } //assign the category_id. if (strlen($logCategory)) { if (!is_numeric($logCategory)) { //attempt to retreive the logCategoryId (assuming they passed a name) $this->logCategoryId = $this->get_category_id($logCategory); } else { //it was numeric: set it! $this->logCategoryId = $logCategory; } } //check for a uid in the session. $this->defaultUid = $this->get_uid(); //build our cache. $this->build_cache(); }