function init() { $this->db = NyaaDB::factory(sprintf('sqlite:localhost:/%s/data/twitter.db', $this->Ctrl->getConf('root.dir'))); $this->uid = $this->Ctrl->getSession()->get('user.id'); $this->con_key = $this->Ctrl->getConf('twitter.key'); $this->con_secret = $this->Ctrl->getConf('twitter.secret'); }
function init() { $this->db = $this->Ctrl->get('db.system'); $this->db = NyaaDB::factory('sqlite:localhost/' . $this->Ctrl->getConf('root.dir') . '/data/profile.photo.db'); /* $this->db->query('drop table photo;'); $this->db->query('create table photo (id integer primary key, userid int, name varchar(128), type varchar(128), size int(16), bin blob);'); */ $this->type = "photo"; $this->uid = $this->Ctrl->getSession()->get('user.id'); $this->imageDir = $this->Ctrl->getConf('root.dir') . '/data/user/' . $this->uid; /* mkdir($this->imageDir); chmod($this->imageDir,0777); mkdir($this->imageDir.'/img'); mkdir($this->imageDir.'/img/300x300'); mkdir($this->imageDir.'/img/200x200'); mkdir($this->imageDir.'/img/150x150'); mkdir($this->imageDir.'/img/100x100'); mkdir($this->imageDir.'/img/75x75'); mkdir($this->imageDir.'/img/50x50'); mkdir($this->imageDir.'/img/25x25'); */ }
<?php require_once 'db/db.class.php'; $dir = dirname(__FILE__); $handler = NyaaDB::factory("sqlite:localhost/{$dir}/sample.db"); $hadnler->query('CREATE TABLE sample (id integer,name varchar(128))'); $sth = $hadnler->prepare('INSERT INTO sample (id,name) VALUES (:id,:name)'); $sth->bindParam('id', 1, 'int'); $sth->bindParam('name', "hajime", 'str'); $sth->execute(); $id = $sth->getLastId(); $sth = $hadnler->prepare('SELECT * FROM sample WHERE id=:id;'); $sth->bindParam('id', 1, 'int'); $sth->execute(); $row = $sth->fetch(); echo $row['name'];
function dbFactory($con) { require_once 'db/db.class.php'; $handler = NyaaDB::factory($con); return $handler; }
<?php set_include_path('../lib'); require_once 'controller/controller.class.php'; require_once 'log/log.class.php'; // Logger Setup $_NYAA_LOG = array(); $logger = new NyaaLog(); $handler = $logger->createHandler('capture'); $handler->bind($_NYAA_LOG); $logger->addHandler(NyaaLog::ALL, $handler); NyaaLog::addStack($logger); $Ctrl = NyaaController::factory('web', '../site/root.conf', array('root.dir' => realpath(dirname(__FILE__) . '/../site'))); $Ctrl->request(isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : "", $_POST, $_GET, $_FILES); // Connect Database require_once 'db/db.class.php'; $db = NyaaDB::factory($Ctrl->getConf('db.system')); $Ctrl->set("db.system", $db); $Ctrl->init(); $Ctrl->run(); foreach ($_NYAA_LOG as $log) { echo '<li>' . $log . '</li>'; }