Wife Posted May 9, 2017 Share 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. Quote Link to comment Share on other sites More sharing options...
Deceiver Posted May 9, 2017 Share Posted May 9, 2017 u ask boss? :0 Quote Link to comment Share on other sites More sharing options...
Wife Posted May 9, 2017 Author Share Posted May 9, 2017 5 minutes ago, raijin said: u ask boss? :0 boss tell bad class structure i tell i fuck boss wife Quote Link to comment Share on other sites More sharing options...
fstyle Posted May 9, 2017 Share Posted May 9, 2017 was expecting meme Quote Link to comment Share on other sites More sharing options...
duck daffy Posted May 9, 2017 Share Posted May 9, 2017 n o clue what u mean Quote Link to comment Share on other sites More sharing options...
IamBot Posted May 9, 2017 Share Posted May 9, 2017 1 hour ago, fstyle said: was expecting meme Me too Quote Link to comment Share on other sites More sharing options...
Wife Posted May 9, 2017 Author Share 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 Quote Link to comment Share on other sites More sharing options...
Deceiver Posted May 9, 2017 Share Posted May 9, 2017 7 hours ago, Facial said: boss tell bad class structure i tell i fuck boss wife good brother,, Quote Link to comment Share on other sites More sharing options...