function create_table($n, $fields) { $f = new STR($fields); $q = ''; foreach ($f->toDRW() as $i => $v) { $q .= $i . ' ' . $v . ','; } $this->query('create table ' . $n . '(' . substr($q, 0, strlen($q) - 1) . ')'); return $this; }
function repl(&$c = null, $opt = false, $t = true, $s1, $s2 = '') { static $c1 = 0; static $s; if (isStr($s1)) { preg_match_all('/[^' . $s1 . ']+/', $u = $s ? $s : $this->O, $m); $s = new STR($u); if ($s->pos($s1) === 0) { $l = 1; } elseif ($s->pos($s1) == $s->len() - strlen($s1)) { $r = 1; } preg_match_all('/^[' . $s1 . ']+|[' . $s1 . ']+$/', $u, $p); $s = str_replace($s1, $s2, $u, $c); $c1 += $c; $c = $c1; if ($t) { $s = ''; foreach ($m[0] as $v) { $s .= $v . $s2; } $s = substr($s, 0, strlen($s) - strlen($s2)); $s = (isset($l) ? $s2 . $s : $s) . (isset($r) || count($p[0]) == 2 ? $s2 : ''); } if ($opt = true) { $this->O = $s; } return $s; } if (isDrw($s1)) { foreach ($s1 as $i => $v) { $s = $this->repl($c, $opt, $t, $i, $v); } return $s; } }
/** * Get destination path for generated file. * * @return string */ public function getPath() { $name = STR::snake($this->getName()); $name = str_replace('/_', '/', $name); return $this->getBasePath() . $name . '.blade.php'; }