当前位置: 首页>>代码示例>>PHP>>正文


PHP DibiConnection::getDriver方法代码示例

本文整理汇总了PHP中DibiConnection::getDriver方法的典型用法代码示例。如果您正苦于以下问题:PHP DibiConnection::getDriver方法的具体用法?PHP DibiConnection::getDriver怎么用?PHP DibiConnection::getDriver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DibiConnection的用法示例。


在下文中一共展示了DibiConnection::getDriver方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * @param  string  SQL command or table or view name, as data source
  * @param  DibiConnection  connection
  */
 public function __construct($sql, DibiConnection $connection)
 {
     if (strpbrk($sql, " \t\r\n") === FALSE) {
         $this->sql = $connection->getDriver()->escape($sql, dibi::IDENTIFIER);
         // table name
     } else {
         $this->sql = '(' . $sql . ') t';
         // SQL command
     }
     $this->connection = $connection;
 }
开发者ID:ludik1,项目名称:transport_company,代码行数:15,代码来源:DibiDataSource.php

示例2: translate

 /**
  * Generates SQL.
  * @param  array
  * @return string
  * @throws DibiException
  */
 public function translate(array $args)
 {
     $this->identifiers = new DibiHashMap(array($this, 'delimite'));
     $this->driver = $this->connection->getDriver();
     $args = array_values($args);
     while (count($args) === 1 && is_array($args[0])) {
         // implicit array expansion
         $args = array_values($args[0]);
     }
     $this->args = $args;
     $this->limit = -1;
     $this->offset = 0;
     $this->hasError = FALSE;
     $commandIns = NULL;
     $lastArr = NULL;
     // shortcuts
     $cursor =& $this->cursor;
     $cursor = 0;
     // conditional sql
     $this->ifLevel = $this->ifLevelStart = 0;
     $comment =& $this->comment;
     $comment = FALSE;
     // iterate
     $sql = array();
     while ($cursor < count($this->args)) {
         $arg = $this->args[$cursor];
         $cursor++;
         // simple string means SQL
         if (is_string($arg)) {
             // speed-up - is regexp required?
             $toSkip = strcspn($arg, '`[\'":%?');
             if (strlen($arg) === $toSkip) {
                 // needn't be translated
                 $sql[] = $arg;
             } else {
                 $sql[] = substr($arg, 0, $toSkip) . preg_replace_callback('/(?=[`[\'":%?])(?:`(.+?)`|\\[(.+?)\\]|(\')((?:\'\'|[^\'])*)\'|(")((?:""|[^"])*)"|(\'|")|:(\\S*?:)([a-zA-Z0-9._]?)|%([a-zA-Z~][a-zA-Z0-9~]{0,5})|(\\?))/s', array($this, 'cb'), substr($arg, $toSkip));
                 if (preg_last_error()) {
                     throw new DibiPcreException();
                 }
             }
             continue;
         }
         if ($comment) {
             $sql[] = '...';
             continue;
         }
         if ($arg instanceof Traversable) {
             $arg = iterator_to_array($arg);
         }
         if (is_array($arg)) {
             if (is_string(key($arg))) {
                 // associative array -> autoselect between SET or VALUES & LIST
                 if ($commandIns === NULL) {
                     $commandIns = strtoupper(substr(ltrim($this->args[0]), 0, 6));
                     $commandIns = $commandIns === 'INSERT' || $commandIns === 'REPLAC';
                     $sql[] = $this->formatValue($arg, $commandIns ? 'v' : 'a');
                 } else {
                     if ($lastArr === $cursor - 1) {
                         $sql[] = ',';
                     }
                     $sql[] = $this->formatValue($arg, $commandIns ? 'l' : 'a');
                 }
                 $lastArr = $cursor;
                 continue;
             }
         }
         // default processing
         $sql[] = $this->formatValue($arg, FALSE);
     }
     // while
     if ($comment) {
         $sql[] = "*/";
     }
     $sql = implode(' ', $sql);
     if ($this->hasError) {
         throw new DibiException('SQL translate error', 0, $sql);
     }
     // apply limit
     if ($this->limit > -1 || $this->offset > 0) {
         $this->driver->applyLimit($sql, $this->limit, $this->offset);
     }
     return $sql;
 }
开发者ID:Scrik,项目名称:Need-For-Speed-World-Statistics-Website,代码行数:89,代码来源:DibiTranslator.php

示例3: formatValue

 /**
  * Apply modifier to single value.
  * @param  mixed
  * @param  string
  * @return string
  */
 public function formatValue($value, $modifier)
 {
     if ($this->comment) {
         return '...';
     }
     if (!$this->driver) {
         $this->driver = $this->connection->getDriver();
     }
     // array processing (with or without modifier)
     if ($value instanceof Traversable) {
         $value = iterator_to_array($value);
     }
     if (is_array($value)) {
         $vx = $kx = array();
         switch ($modifier) {
             case 'and':
             case 'or':
                 // key=val AND key IS NULL AND ...
                 if (empty($value)) {
                     return '1=1';
                 }
                 foreach ($value as $k => $v) {
                     if (is_string($k)) {
                         $pair = explode('%', $k, 2);
                         // split into identifier & modifier
                         $k = $this->identifiers->{$pair[0]} . ' ';
                         if (!isset($pair[1])) {
                             $v = $this->formatValue($v, FALSE);
                             $vx[] = $k . ($v === 'NULL' ? 'IS ' : '= ') . $v;
                         } elseif ($pair[1] === 'ex') {
                             // TODO: this will be removed
                             $vx[] = $k . $this->formatValue($v, 'ex');
                         } else {
                             $v = $this->formatValue($v, $pair[1]);
                             if ($pair[1] === 'l' || $pair[1] === 'in') {
                                 $op = 'IN ';
                             } elseif (strpos($pair[1], 'like') !== FALSE) {
                                 $op = 'LIKE ';
                             } elseif ($v === 'NULL') {
                                 $op = 'IS ';
                             } else {
                                 $op = '= ';
                             }
                             $vx[] = $k . $op . $v;
                         }
                     } else {
                         $vx[] = $this->formatValue($v, 'ex');
                     }
                 }
                 return '(' . implode(') ' . strtoupper($modifier) . ' (', $vx) . ')';
             case 'n':
                 // key, key, ... identifier names
                 foreach ($value as $k => $v) {
                     if (is_string($k)) {
                         $vx[] = $this->identifiers->{$k} . (empty($v) ? '' : ' AS ' . $this->identifiers->{$v});
                     } else {
                         $pair = explode('%', $v, 2);
                         // split into identifier & modifier
                         $vx[] = $this->identifiers->{$pair[0]};
                     }
                 }
                 return implode(', ', $vx);
             case 'a':
                 // key=val, key=val, ...
                 foreach ($value as $k => $v) {
                     $pair = explode('%', $k, 2);
                     // split into identifier & modifier
                     $vx[] = $this->identifiers->{$pair[0]} . '=' . $this->formatValue($v, isset($pair[1]) ? $pair[1] : (is_array($v) ? 'ex' : FALSE));
                 }
                 return implode(', ', $vx);
             case 'in':
                 // replaces scalar %in modifier!
             // replaces scalar %in modifier!
             case 'l':
                 // (val, val, ...)
                 foreach ($value as $k => $v) {
                     $pair = explode('%', $k, 2);
                     // split into identifier & modifier
                     $vx[] = $this->formatValue($v, isset($pair[1]) ? $pair[1] : (is_array($v) ? 'ex' : FALSE));
                 }
                 return '(' . ($vx || $modifier === 'l' ? implode(', ', $vx) : 'NULL') . ')';
             case 'v':
                 // (key, key, ...) VALUES (val, val, ...)
                 foreach ($value as $k => $v) {
                     $pair = explode('%', $k, 2);
                     // split into identifier & modifier
                     $kx[] = $this->identifiers->{$pair[0]};
                     $vx[] = $this->formatValue($v, isset($pair[1]) ? $pair[1] : (is_array($v) ? 'ex' : FALSE));
                 }
                 return '(' . implode(', ', $kx) . ') VALUES (' . implode(', ', $vx) . ')';
             case 'm':
                 // (key, key, ...) VALUES (val, val, ...), (val, val, ...), ...
                 foreach ($value as $k => $v) {
                     if (is_array($v)) {
//.........这里部分代码省略.........
开发者ID:jakubmacek,项目名称:dibi,代码行数:101,代码来源:DibiTranslator.php

示例4:

IDataSource{private$connection;private$sql;private$result;private$count;private$totalCount;private$cols=array();private$sorting=array();private$conds=array();private$offset;private$limit;function
__construct($sql,DibiConnection$connection){if(strpbrk($sql," \t\r\n")===FALSE){$this->sql=$connection->getDriver()->escape($sql,dibi::IDENTIFIER);}else{$this->sql='('.$sql.') t';}$this->connection=$connection;}function
开发者ID:nosko,项目名称:socialSearch,代码行数:2,代码来源:dibi.min.php

示例5: __construct

 public function __construct(DibiConnection $connection)
 {
     $this->connection = $connection;
     $this->driver = $connection->getDriver();
     $this->identifiers = new DibiHashMap(array($this, 'delimite'));
 }
开发者ID:Eflyax,项目名称:KIVWEB,代码行数:6,代码来源:DibiTranslator.php

示例6: __construct

 public function __construct($sql, DibiConnection $connection)
 {
     if (strpos($sql, ' ') === FALSE) {
         $this->sql = $connection->getDriver()->escape($sql, dibi::IDENTIFIER);
     } else {
         $this->sql = '(' . $sql . ') t';
     }
     $this->connection = $connection;
 }
开发者ID:svoby,项目名称:graweb2010,代码行数:9,代码来源:dibi.min.php


注:本文中的DibiConnection::getDriver方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。