777 Posted August 1, 2010 Report Share Posted August 1, 2010 Sveicinaati vecie un jaunie koderi, sen nebiju te radijies :) Laikam jautaajums buus vecajiem guru. Kadam varbuut ir aizmetaajies PDO klasse darbam ar mysql? Atradu interneta shito, bet nebiju lidz shim nemies ar PDO, biju lietojis savu pierasto Mysql db klassi, tachu tagad grasos nemties ar vienu milzigo projektu, un lai nezaudeetu performance, domaju izmantot PDO. Paldies jau ieprieksh, par Jusu komentariem, priekshlikumiem un iebildumiem. class sdb { static private $PDOInstance; public function __construct($dsn, $username=false, $password=false, $driver_options=false) { if(!self::$PDOInstance) { try { self::$PDOInstance = new PDO($dsn, $username, $password, $driver_options); } catch(PDOException $e) { die("PDO CONNECTION ERROR: " . $e->getMessage() . "<br/>"); } } return self::$PDOInstance; } public function beginTransaction() { return self::$PDOInstance->beginTransaction(); } public function commit() { return self::$PDOInstance->commit(); } public function errorCode() { return self::$PDOInstance->errorCode(); } public function errorInfo() { return self::$PDOInstance->errorInfo(); } public function exec($statement) { return self::$PDOInstance->exec($statement); } public function getAttribute($attribute) { return self::$PDOInstance->getAttribute($attribute); } public function getAvailableDrivers() { return Self::$PDOInstance->getAvailableDrivers(); } public function lastInsertId($name) { return self::$PDOInstance->lastInsertId($name); } public function prepare ($statement, $driver_options=false) { if(!$driver_options) $driver_options=array(); return self::$PDOInstance->prepare($statement, $driver_options); } public function query($statement) { return self::$PDOInstance->query($statement); } public function queryFetchAllAssoc($statement) { return self::$PDOInstance->query($statement)->fetchAll(PDO::FETCH_ASSOC); } public function queryFetchRowAssoc($statement) { return self::$PDOInstance->query($statement)->fetch(PDO::FETCH_ASSOC); } public function queryFetchColAssoc($statement) { return self::$PDOInstance->query($statement)->fetchColumn(); } public function quote ($input, $parameter_type=0) { return self::$PDOInstance->quote($input, $parameter_type); } public function rollBack() { return self::$PDOInstance->rollBack(); } public function setAttribute($attribute, $value) { return self::$PDOInstance->setAttribute($attribute, $value); } } Quote Link to comment Share on other sites More sharing options...
Klez Posted August 2, 2010 Report Share Posted August 2, 2010 vienaa sadalaa http://php.lv/f/topic/16942-veicu-gabaldarbus/ tu raksti ka tev ir 5 gadu pieredze un seit jau tu raksti ka nezini par taadu PDO eksistenci. cmoon. http://lv.php.net/pdo Quote Link to comment Share on other sites More sharing options...
777 Posted August 2, 2010 Author Report Share Posted August 2, 2010 Hei, es neteicu ka nezinu!!!!! Es teicu kad nebiju lietojis to, un varbuut kadam ir kaut kaads labs skeletons :) Lasi uzmaniigaak!!! Quote Link to comment Share on other sites More sharing options...
krikulis Posted August 2, 2010 Report Share Posted August 2, 2010 Kāds registry ? Ja izmantojam ietvaru, izmantojam ietvaru DB abstrakcijas klasi, a tā neredzu jēgu wrappot PDO - pie inicializācijas iebāžam konteinerī (aļa registry pattern) ar visu DSN un tālāk strādājam ar tiešu. Var uztaisīt delegāta / singleton miksējumu un rullēt tā. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.