public function __construct($query, &$conn, &$orm = null) { $this->conn = $conn; $this->res = null; $this->orm = $orm; $this->rowOrm = null; $this->success = false; $this->fields = null; $this->EOF = true; $this->BOF = true; $this->index = 0; $this->count = 0; $this->insertID = 0; $type = strtolower(substr(trim(str_replace("\n", " ", $query)), 0, 7)); $typeIsSelect = $type == "select "; $typeIsShowTables = $type == "show ta"; $typeIsInsert = $type == "insert "; $query = Str::finish($query, ";"); if ($this->res = @mysql_query($query, $this->conn->res)) { $this->success = true; if ($typeIsSelect || $typeIsShowTables) { $this->count = mysql_num_rows($this->res); $this->moveFirst(); } else { if ($typeIsInsert) { $this->insertID = mysql_insert_id($this->conn->res); } } } else { trigger_error("SQL error: " . $query . "\n<br><b>'" . mysql_error($this->conn->res) . "'</b>"); } }
/** * Bind URLs * * @return void */ public function bindUrls() { $root = \Str::finish(URL::to('/'), '/'); $urls = ['root' => $root, 'feed' => $root . 'feed', 'archives' => $root . 'archives', 'search' => $root . 'search', 'assets' => $root . 'assets']; foreach ($urls as $key => $value) { App::instance("url.{$key}", $value); } }
/** * Cap a string with a single instance of a given value. * * @param string $value * @param string $cap * @return string */ function str_finish($value, $cap) { return Str::finish($value, $cap); }
public static function formatDir($path) { return Str::finish($path, DS); }
public static function rootURL() { if (is_null(static::$rootURL)) { $protocol = strtolower(array_get(static::$server, "SERVER_PROTOCOL", "http")); $protocol = substr($protocol, 0, strpos($protocol, "/")) . (static::isSecure() ? "s" : ""); $port = array_get(static::$server, "SERVER_PORT", "80"); $port = $port == "80" ? "" : ":" . $port; if (static::isPreview() && $port == ":8080") { $port = ""; } $uri = static::fullURI(); $pathInfo = static::pathInfo(); if ($pathInfo != "/") { $uri = substr($uri, 0, strpos($uri, $pathInfo)); } $uri = explode("?", $uri); $uri = $uri[0]; static::$rootURL = Str::finish($protocol . "://" . array_get(static::$server, "SERVER_NAME", "localhost") . $port . $uri, "/"); } return static::$rootURL; }