本文整理匯總了PHP中Driver::connect方法的典型用法代碼示例。如果您正苦於以下問題:PHP Driver::connect方法的具體用法?PHP Driver::connect怎麽用?PHP Driver::connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Driver
的用法示例。
在下文中一共展示了Driver::connect方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
/**
*
* @param string $name database name
* @param string $driver Driver implementation class name
* @param array $parameters Driver-specific parameters
* @param array $classMapper Class mapper configuration (optional)
*/
public function __construct($name, $driver, $parameters, $classMapper = [])
{
$this->name = $name;
if (isset($parameters['prefix'])) {
$this->prefix = $parameters['prefix'];
unset($parameters['prefix']);
}
// load driver
if ($driver[0] !== '\\') {
// class is relative to this namespace
$driver = "\\selective\\ORM\\Driver\\{$driver}";
}
$this->driver = new $driver();
$this->driver->loadParameters($parameters);
$this->driver->connect($this);
// load class mapper
if (isset($classMapper['class'])) {
$classMapperClass = $classMapper['class'];
unset($classMapper['class']);
if ($classMapperClass[0] !== '\\') {
// class is relative to this namespace
$classMapperClass = "\\selective\\ORM\\ClassMapper\\{$classMapperClass}";
}
} else {
$classMapperClass = "\\selective\\ORM\\ClassMapper\\BuiltIn";
}
$this->classMapper = new $classMapperClass();
$this->classMapper->loadParameters($classMapper);
}
示例2: driver_controller
//.........這裏部分代碼省略.........
if (isset($keyvalue[1])) {
if ($keyvalue[0] != 'type' or $keyvalue[0] != 'description') {
$valid = false;
$error = "Format error, json key missing or invalid character";
}
if ($keyvalue[0] == 'type') {
$driverid = $keyvalue[1];
} else {
$description = $keyvalue[1];
}
}
}
$userid = $session['userid'];
$result = $driver->add($userid, $driverid, $description);
$valid = true;
} else {
$valid = false;
$error = "Request contains no data via csv, json or data tag";
}
if (!$valid) {
$result = "Error: {$error}\n";
}
}
/*
if ($route->action == "clean") $result = $input->clean($session['userid']);
*/
if ($route->action == "list") {
$result = $driver->getlist($session['userid']);
}
//allocate a node
if ($route->action == "nodes") {
$result = $driver->driversNodes($session['userid']);
}
if ($route->action == "release" or $route->action == "connect") {
if (isset($_GET['json'])) {
$datain = get('json');
$json = preg_replace('/[^\\w\\s-.: ,]/', '', $datain);
$datapairs = explode(',', $json);
for ($i = 0; $i < count($datapairs); $i++) {
$keyvalue = explode(':', $datapairs[$i]);
//echo $keyvalue[0]." ".$keyvalue[1];
if (isset($keyvalue[1])) {
if ($keyvalue[0] == 'driverID') {
$driverid = $keyvalue[1];
} else {
if ($keyvalue[0] == 'nodeID') {
$nodeid = $keyvalue[1];
}
}
}
}
if ($route->action == "release") {
$result = $driver->release($session['userid'], $driverid, $nodeid);
} else {
$result = $driver->connect($session['userid'], $driverid, $nodeid);
}
} else {
$result = -1;
}
}
if ($route->action == "reserve") {
if (isset($_GET['driverID'])) {
$result = $driver->reserve($session['userid'], $_GET['driverID']);
} else {
$result = -1;
}