本文整理汇总了PHP中Driver类的典型用法代码示例。如果您正苦于以下问题:PHP Driver类的具体用法?PHP Driver怎么用?PHP Driver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Driver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: serialize
/**
* @param $value
*
* @return mixed|string
*/
public static function serialize($value)
{
if (empty(self::$driver)) {
self::$driver = new Driver();
}
return self::$driver->serialize($value);
}
示例2: isTransient
/**
* Whether the class with the specified name should have its metadata loaded.
*
* This is only the case for non-transient classes either mapped as an Document or MappedSuperclass.
*
* @param string $className
* @return boolean
*/
public function isTransient($className)
{
if (strpos($className, self::NAME_SPACE) === 0) {
return $this->builtinDriver->isTransient($className);
}
return $this->wrappedDriver->isTransient($className);
}
示例3: __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);
}
示例4: drive
/**
* @inheritdoc
*/
public function drive(Driver $driver)
{
if ($driver->isDrunk()) {
return 'Driver cannot drive';
}
return $this->car->drive($driver);
}
示例5: __construct
/**
* @param Driver $driver
* @param Table $table
* @param Query $query
* @param bool $asArray
*/
public function __construct(Driver $driver, Table $table, Query $query, $asArray = false)
{
$this->asArray = $asArray;
$this->table = $table;
$params = [];
$this->tableName = $table->getName();
if (!$this->asArray) {
$this->recordClasses = [$this->tableName => $table->getDatabase()->getClassMapper()->getClassForRecord($this->tableName)];
}
$sql = $query->getRawSql();
if ($sql === null) {
$sql = $driver->buildSQL($table, $query, $params);
$this->fetchStyle = \PDO::FETCH_NUM;
foreach ($table->getColumns() as $column) {
if ($column->isPrimaryKey()) {
$this->primaryKeyOrdinals[$this->tableName][$column->getOrdinal()] = true;
}
$this->columnOrdinalMap[$this->tableName][$column->getOrdinal()] = $column->getName();
}
$offset = count($table->getColumns());
foreach ($query->getJoins() as $join) {
if (isset($join['cardinality'])) {
$joinedTableName = $join['table'];
$joinedTable = $table->getDatabase()->getTable($joinedTableName);
$this->joinedTables[$joinedTableName] = $joinedTable;
if (!$this->asArray) {
$this->recordClasses[$joinedTableName] = $joinedTable->getDatabase()->getClassMapper()->getClassForRecord($joinedTableName);
}
foreach ($joinedTable->getColumns() as $column) {
if ($column->isPrimaryKey()) {
$this->primaryKeyOrdinals[$joinedTableName][$offset + $column->getOrdinal()] = true;
}
$this->columnOrdinalMap[$joinedTableName][$offset + $column->getOrdinal()] = $column->getName();
}
$this->cardinalities[$joinedTableName] = $join['cardinality'];
if ($join['cardinality'] === Query::CARDINALITY_ONE_TO_MANY) {
$this->properties[$joinedTableName] = $joinedTableName;
} else {
$this->properties[$joinedTableName] = array_keys($join['on']);
}
$offset += count($joinedTable->getColumns());
}
}
} else {
$this->fetchStyle = \PDO::FETCH_ASSOC;
$this->rawSql = true;
}
$this->result = $driver->query($sql, $params);
$this->fetchNextRow();
}
示例6: calculateCrumb
protected function calculateCrumb(BaseObject $object)
{
$parentId = $object->getParentId();
if (!$parentId) {
$this->crumbsByObjectId[$object->getId()] = array($object->getName());
return $this->crumbsByObjectId[$object->getId()];
}
if (isset($this->crumbsByObjectId[$parentId])) {
$this->crumbsByObjectId[$object->getId()] = $this->crumbsByObjectId[$parentId];
$this->crumbsByObjectId[$object->getId()][] = $object->getName();
return $this->crumbsByObjectId[$object->getId()];
}
$storage = $object->getStorage();
$fake = Driver::getInstance()->getFakeSecurityContext();
$this->crumbsByObjectId[$object->getId()] = array();
foreach ($object->getParents($fake, array('select' => array('ID', 'NAME', 'TYPE')), SORT_DESC) as $parent) {
if ($parent->getId() == $storage->getRootObjectId()) {
continue;
}
$this->crumbsByObjectId[$object->getId()][] = $parent->getName();
}
unset($parent);
$this->crumbsByObjectId[$parentId] = $this->crumbsByObjectId[$object->getId()];
$this->crumbsByObjectId[$object->getId()][] = $object->getName();
return $this->crumbsByObjectId[$object->getId()];
}
示例7: titulacionRenderComboBox
function titulacionRenderComboBox()
{
$render = new templateEngine();
$db = Driver::getInstance();
$titulaciones = new Titulacion($db);
$render->titulaciones = $titulaciones->all();
return $render->render('titulacionCB_v.php');
}
示例8: run
function run()
{
set_time_limit(0);
try {
DB::query("UPDATE Driver SET Active = 0");
DB::query("UPDATE DriverRelease SET Active = 0");
$url = 'http://stackalytics.com/driverlog/api/1.0/drivers';
$jsonResponse = @file_get_contents($url);
$driverArray = json_decode($jsonResponse, true);
$array = $driverArray['drivers'];
foreach ($array as $contents) {
if (!isset($contents['project_name']) || !isset($contents['name'])) {
continue;
}
$driver = Driver::get()->filter(array("Name" => trim($contents['name']), "Project" => trim($contents['project_name'])))->first();
if (!$driver) {
$driver = new Driver();
}
$driver->Name = trim($contents['name']);
$driver->Description = isset($contents['description']) ? $contents['description'] : null;
$driver->Project = $contents['project_name'];
$driver->Vendor = isset($contents['vendor']) ? $contents['vendor'] : null;
$driver->Url = isset($contents['wiki']) ? $contents['wiki'] : null;
$driver->Active = 1;
if (isset($contents['releases_info'])) {
$releases = $contents['releases_info'];
foreach ($releases as $release) {
$driver_release = DriverRelease::get()->filter("Name", trim($release['name']))->first();
if (!$driver_release) {
$driver_release = new DriverRelease();
}
$driver_release->Name = trim($release['name']);
$driver_release->Url = $release['wiki'];
$driver_release->Active = 1;
$driver_release->write();
$driver->Releases()->add($driver_release);
}
}
$driver->write();
}
return 'OK';
} catch (Exception $ex) {
SS_Log::log($ex, SS_Log::ERR);
echo $ex->getMessage();
}
}
示例9: send
/**
* {@inheritdoc}
*/
public function send(Message $message)
{
$queueName = $this->router->queueFor($message);
if (!$queueName) {
throw new Exception\QueueNotFound(sprintf('Could not find a queue for "%s"', $message->getName()));
}
$this->driver->enqueue($queueName, $message);
}
示例10: stop
/**
* Makes sure timer is stopped and measurement registered. Subsequent call gives no effect.
*/
public function stop()
{
if ($this->startTime !== null) {
$time = \microtime(true) - $this->startTime;
$this->driver->measureTime($this->measurementName, $time);
$this->startTime = null;
}
}
示例11: query
/**
* 事务查询
* @param string $sql
*/
protected function query($sql)
{
try {
if ($this->driver->query($sql, null, true)) {
$status = true;
} else {
$status = false;
}
} catch (\Exception $e) {
$status = false;
}
return $status;
}
示例12: getInstance
public static function getInstance()
{
if (!isset(self::$_instance)) {
self::$_instance = new self();
}
return self::$_instance;
}
示例13: rm
/**
* {@inheritdoc}
*/
public function rm($hash)
{
$this->setConnectorFromPlugin();
if ($this->allow()) {
return parent::rm($hash);
}
}
示例14: rm
/**
* {@inheritdoc}
*/
public function rm($hash)
{
$this->setConnectorFromPlugin();
if ($this->connector->security->isGranted('ROLE_ADMIN')) {
return parent::rm($hash);
}
}
示例15: upload
/**
* {@inheritdoc}
*/
public function upload($fp, $dst, $name, $tmpname)
{
$this->setConnectorFromPlugin();
// upload file by elfinder.
$result = parent::upload($fp, $dst, $name, $tmpname);
$name = $result['name'];
$filtered = \URLify::filter($result['name'], 80);
if (strcmp($name, $filtered) != 0) {
/*$arg = array('target' => $file['hash'], 'name' => $filtered);
$elFinder->exec('rename', $arg);*/
$this->rename($result['hash'], $filtered);
}
$realPath = $this->realpath($result['hash']);
if (!empty($realPath)) {
// Getting file info
//$info = $elFinder->exec('file', array('target' => $file['hash']));
/** @var elFinderVolumeLocalFileSystem $volume */
//$volume = $info['volume'];
//$root = $volume->root();
//var/www/chamilogits/data/courses/NEWONE/document
$realPathRoot = $this->getCourseDocumentSysPath();
// Removing course path
$realPath = str_replace($realPathRoot, '/', $realPath);
\FileManager::add_document($this->connector->course, $realPath, 'file', intval($result['size']), $result['name']);
}
return $result;
}