Пример #1
0
 /**
  * Erstells aus einem CamelCase Namen oder einer Klasse oder einem String eine html-klasse
  */
 public static function string2class($stringValue)
 {
     // dirty hack: Psc\Code\Code::camelCase2dash benutzt dies hier: also aufpassen, bei großen Änderungen refactorn
     $stringValue = trim($stringValue);
     if ($stringValue === '') {
         return $stringValue;
     }
     if (Preg::match($stringValue, '/^[A-Z0-9]+$/')) {
         return mb_strtolower($stringValue);
     }
     $specials = preg_quote(implode("", array('.', '@', '\\', ' ', '[', ']', '(', ')')), '/');
     $stringValue = Preg::replace($stringValue, sprintf('/%s|[%s]/', "(?<=\\w)([A-Z]|[0-9])", $specials), '-\\1');
     $stringValue = mb_strtolower($stringValue);
     return $stringValue;
 }
Пример #2
0
 public static function printSQLLog($filter = NULL, $return = FALSE, EntityManager $em = NULL)
 {
     $em = $em ?: self::em();
     $br = "<br />\n";
     $config = $em->getConnection()->getConfiguration();
     $ret = NULL;
     if (!is_object($config->getSQLLogger())) {
         throw new \Psc\Exception('Logger muss vorher gestartet worden sein');
     }
     $time = 0;
     foreach ((array) $config->getSQLLogger()->queries as $item) {
         if (isset($filter) && Preg::match($item['sql'], $filter) == 0) {
             continue;
         }
         $time += $item['executionMS'] * 1000000;
         $sql = $item['sql'];
         if (isset($item['params']) && is_array($item['params'])) {
             foreach ($item['params'] as $p) {
                 try {
                     if (is_array($p)) {
                         $p = self::implodeIdentifiers($p);
                     }
                 } catch (\Exception $e) {
                     $p = '[unconvertible array]';
                 }
                 if (is_string($p)) {
                     $p = "'" . $p . "'";
                 }
                 if ($p instanceof \DateTime) {
                     $p = $p->format('YDM-H:I');
                 }
                 $sql = preg_replace('/\\?/', (string) $p, $sql, 1);
                 // ersetze das erste ? mit dem parameter
             }
         }
         $ret .= $sql . ';' . $br;
     }
     $ret .= 'Time (cumulated): ' . $time / 1000000;
     if (!$return) {
         print $ret;
     }
     return $ret;
 }
Пример #3
0
 protected function remoteUpdateDB($mode, $project)
 {
     $this->out('[DeployCommand] ** remote Update DB');
     $con = $this->getRemoteDBCon($mode);
     $out = '';
     $bin = 'bin/';
     $this->remoteExec(sprintf('./cli.sh orm:update-schema --dry-run --con="%s"', $con), $bin, $out);
     if (!Preg::match($out, '/nothing to do/')) {
         if ($this->confirm('Do you want to update the schema? (see above for changes)')) {
             $this->remoteExec(sprintf('./cli.sh orm:update-schema --con="%s"', $con), $bin);
         }
     }
     $this->br();
 }