/** * The constructor. */ public function __construct($rootDir, $cwd = NULL, $initialMode = NULL) { //set the root directory that we'll be using; this is considered just like "/" in // linux. Directories above it are considered non-existent. if (!is_null($rootDir)) { parent::__construct(true); $this->root = ToolBox::resolve_path_with_dots($rootDir); //set the CURRENT working directory... this should be a RELATIVE path to $this->root. if (!is_null($cwd) and is_dir($rootDir . '/' . $cwd) and !preg_match('~' . $cwd . '~', $this->root)) { //looks good. Use it. $this->cwd = $cwd; $this->realcwd = $this->root . '/' . $cwd; } else { //no dice. Use the root. $this->cwd = '/'; $this->realcwd = $this->root; } $this->realcwd = preg_replace('~/{2,}~', '/', $this->realcwd); chdir($this->realcwd); //check for the initialMode... $useableModes = array('r', 'r+', 'w', 'w+', 'a', 'a+', 'x', 'x+', 'c', 'c+'); if ($initialMode and in_array($initialMode, $useableModes)) { // $this->mode = $initialMode; } else { //define the DEFAULT mode. $this->mode = "r+"; } } else { throw new InvalidArgumentException(__METHOD__ . ": invalid root directory (" . $rootDir . ")"); } }
/** * 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. */ public function __construct(Database $dbObj, $tableName, $seqName, $pkeyField) { parent::__construct(); #self::$version->set_version_file_location(dirname(__FILE__) . '/../VERSION'); 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 . ")"); } }
public function __construct($dsn, $username, $password, array $driverOptions = null, $writeCommandsToFile = null) { parent::__construct(); try { $this->reconnect($dsn, $username, $password, $driverOptions, $writeCommandsToFile); } catch (\Exception $ex) { throw $ex; } }
/** * The constructor. */ public function __construct($rootDir) { //set the root directory that we'll be using; this is considered just like "/" in // linux. Directories above it are considered non-existent. if (!is_null($rootDir)) { parent::__construct(true); $this->root = ToolBox::resolve_path_with_dots($rootDir); //no dice. Use the root. $this->cwd = '/'; $this->realcwd = $this->root; $this->realcwd = preg_replace('~/{2,}~', '/', $this->realcwd); $this->mode = "r+"; if (is_dir($this->realcwd)) { chdir($this->realcwd); } else { throw new InvalidArgumentException("directory does not exist (" . $this->realcwd . ")"); } } else { throw new InvalidArgumentException(__METHOD__ . ": invalid root directory (" . $rootDir . ")"); } }