Wife Posted May 9, 2017 Posted May 9, 2017 protected function generateCode($num) { return base_convert($num, 10, 36); } public function createCode($url) { $url = trim($url); if(!filter_var($url, FILTER_VALIDATE_URL)) { return ''; } $sth = $this->dbh->prepare('SELECT code FROM links WHERE url = :url'); $sth->bindParam(":url", $url); $sth->execute(); if(!$sth->rowCount() == 0) { return $sth->fetchColumn(); } else { $sth = $this->dbh->prepare('INSERT INTO links (url, created) values (:url, NOW())'); $sth->bindParam(":url", $url); $sth->execute(); //Generate code $code = $this->generateCode($this->dbh->lastInsertId()); $sth = $this->dbh->prepare('UPDATE links SET code = :code WHERE url = :url'); $sth->bindParam(":code", $code); $sth->bindParam(":url", $url); $sth->execute(); return $code; } } public function getCode($code) { $sth = $this->dbh->prepare('SELECT url FROM links WHERE code = :code'); $sth->bindParam(":code", $code); $sth->execute(); if(!$sth->rowCount() == 0) { return $sth->fetchColumn(); } return ''; } Feel free to use this. It's for URL shortening.
Wife Posted May 9, 2017 Author Posted May 9, 2017 5 minutes ago, raijin said: u ask boss? :0 boss tell bad class structure i tell i fuck boss wife
Wife Posted May 9, 2017 Author Posted May 9, 2017 public function forceAutism($makesense) { $sth = $this->dbhandler->prepare('SELECT * FROM facial WHERE question = :makesense); $sth->bindParam(":makesense", $makesense); $sth->execute if($sth->rowCount() == 1) { return $autism; } return $autism; } this is meme
Deceiver Posted May 9, 2017 Posted May 9, 2017 7 hours ago, Facial said: boss tell bad class structure i tell i fuck boss wife good brother,,