コード例 #1
0
 public function persist()
 {
     $db = new Database();
     if ($this->id == null) {
         $db->execute('INSERT INTO followers (user, follower) VALUES (?, ?)', array($this->user, $this->follower));
         $this->id = $db->lastInsertId();
     } else {
         $req = 'UPDATE followers SET user = ?, follower = ? WHERE id = ?';
         $db->execute($req, array($this->user, $this->follower, $this->id));
     }
 }
コード例 #2
0
 public function persist()
 {
     $db = new Database();
     if ($this->id == null) {
         $req = 'INSERT INTO article (title, content, articleDate, streamType, url, stream_id) VALUES (?, ?, ?, ?, ?, ?)';
         $db->execute($req, array($this->title, $this->content, $this->articleDate, $this->streamType, $this->url, $this->stream_id));
         $this->id = $db->lastInsertId();
     } else {
         $req = 'UPDATE article SET title = ?, content = ?, articleDate = ?, streamType = ?, url = ?, stream_id = ? WHERE id = ?';
         $db->execute($req, array($this->title, $this->content, $this->articleDate, $this->streamType, $this->url, $this->stream_id, $this->id));
     }
 }
コード例 #3
0
 public function persist()
 {
     $db = new Database();
     if ($this->id == null) {
         $req = 'INSERT INTO stream_email (server, account, password, port, firstUpdate) VALUES (?, ?, ?, ?, ?)';
         $db->execute($req, array($this->server, $this->account, $this->password, $this->port, $this->firstUpdate));
         $this->id = $db->lastInsertId();
     } else {
         $req = 'UPDATE stream_email SET server = ?, account = ?, password = ?, port = ?, firstUpdate = ? WHERE id = ?';
         $db->execute($req, array($this->server, $this->account, $this->password, $this->port, $this->firstUpdate, $this->id));
     }
 }
コード例 #4
0
 public function persist()
 {
     $db = new Database();
     if ($this->id == null) {
         $req = 'INSERT INTO blog (account, article) VALUES (?, ?)';
         $db->execute($req, array($this->account, $this->article));
         $this->id = $db->lastInsertId();
     } else {
         $req = 'UPDATE blog SET account = ?, article = ? WHERE id = ?';
         $db->execute($req, array($this->account, $this->article, $this->id));
     }
 }
コード例 #5
0
 /**
  * @covers Database::execute
  * @covers Database::rowCount
  */
 public function testExecute()
 {
     $this->assertEquals(1, $this->db->execute('INSERT INTO test (name) VALUES (?)', 'Value 4'), LoggerApp::getLastError());
     $this->assertEquals(1, $this->db->execute("INSERT INTO test (name) VALUES (?)", array('teste')), LoggerApp::getLastError());
     $this->assertEquals(1, $this->db->rowCount(), 'Erro no numero de linhas inseridas');
     $this->assertEquals(5, $this->db->execute("UPDATE test SET name = name || ?", '_teste'), LoggerApp::getLastError());
     $this->assertEquals(5, $this->db->rowCount(), 'Erro no numero de linhas alteradas');
     $this->assertFalse(LoggerApp::hasError(), LoggerApp::getLastError());
     $this->assertEquals(0, $this->db->execute("DELETE INVALIDTest SET name = ?", 'teste 2'), 'Comando inválido');
     $this->assertTrue(LoggerApp::hasError(), 'Erro inválido');
     $this->assertEquals(0, $this->db->rowCount(), 'Nenhuma linha afetada');
 }
コード例 #6
0
 public function persist()
 {
     $db = new Database();
     if ($this->id == null) {
         $req = 'INSERT INTO accounts (authentification, username, email, userKey, active, accountLevel, picture) VALUES (?, ?, ?, ?, ?, ?, ?)';
         $db->execute($req, array($this->authentification, $this->username, $this->email, $this->userKey, $this->active, $this->accountLevel, $this->picture));
         $this->id = $db->lastInsertId();
     } else {
         $req = 'UPDATE accounts SET authentification = ?, username = ?, email = ?, userKey = ?, active = ?, accountLevel = ?, picture = ? WHERE id = ?';
         $db->execute($req, array($this->authentification, $this->username, $this->email, $this->userKey, $this->active, $this->accountLevel, $this->picture, $this->id));
     }
 }
コード例 #7
0
 public function persist()
 {
     $db = new Database();
     if ($this->id == null) {
         $req = 'INSERT INTO stream_category (stream, category, streamType) VALUES (?, ?, ?)';
         $db->execute($req, array($this->stream, $this->category, $this->streamType));
         $this->id = $db->lastInsertId();
     } else {
         $req = 'UPDATE stream_category SET stream = ?, category = ?, streamType = ? WHERE id = ?';
         $db->execute($req, array($this->stream, $this->category, $this->streamType, $this->id));
     }
 }
コード例 #8
0
 public function ListDistrictProcess($param)
 {
     parent::query('SELECT * FROM dy_location_district WHERE ds_city_id = :city_id ORDER BY ds_id ASC');
     parent::bind(':city_id', $param['city_id']);
     parent::execute();
     return parent::resultset();
 }
コード例 #9
0
 public function SearchLogCountProcess()
 {
     parent::query('SELECT COUNT(lo_id) FROM log_search');
     parent::execute();
     $data = parent::single();
     return $data['COUNT(lo_id)'];
 }
コード例 #10
0
ファイル: Query.php プロジェクト: snowfire/database
 /**
  * @param array $options single_column
  */
 public function execute(array $options = null)
 {
     $data = $this->_compile();
     if (isset($this->select)) {
         if (isset($this->limit) && $this->_parameter_first('limit') == 1) {
             $return = $this->_database->one($data['sql'], $data['values'], $options);
         } else {
             $return = $this->_database->many($data['sql'], $data['values'], $options);
         }
     } else {
         $this->_database->execute($data['sql'], $data['values']);
         $return = $this->_database->last_insert_id();
     }
     $this->clear();
     return $return;
 }
コード例 #11
0
 public function persist()
 {
     $db = new Database();
     $firstUpdate = date(Database::DATE_FORMAT, strtotime($this->firstUpdate));
     $lastUpdate = date(Database::DATE_FORMAT, strtotime($this->lastUpdate));
     if ($this->id == null) {
         $req = 'INSERT INTO stream_twitter (channel, firstUpdate, lastUpdate) VALUES (?, ?, ?)';
         $data = array($this->channel, $firstUpdate, $lastUpdate);
         $db->execute($req, $data);
         $this->id = $db->lastInsertId();
     } else {
         $req = 'UPDATE stream_twitter SET channel = ?, firstUpdate = ?, lastUpdate = ? WHERE id = ?';
         $data = array($this->channel, $firstUpdate, $lastUpdate, $this->id);
         $db->execute($req, $data);
     }
 }
コード例 #12
0
ファイル: menuItem.php プロジェクト: xenonoize/DeViersprong
 public function DeleteItem($id = 0)
 {
     $db = new Database();
     $db->query("DELETE FROM menuitem  WHERE `Id`=:id");
     $db->bind(':id', $id);
     $db->execute();
     header("Location: index.php");
 }
コード例 #13
0
 public function EditItemsInOrderProcess($param)
 {
     parent::query('UPDATE dd_order_detail SET odt_amount = :amount WHERE odt_order_id = :order_id AND odt_product_id = :product_id');
     parent::bind(':amount', $param['amount']);
     parent::bind(':order_id', $param['order_id']);
     parent::bind(':product_id', $param['product_id']);
     parent::execute();
 }
コード例 #14
0
ファイル: photo.model.php プロジェクト: jimmy18dev/dailypoint
 public function DeletePhotoProcess($param)
 {
     parent::query('DELETE FROM dy_image WHERE (im_id = :image_id AND im_member_id = :member_id AND im_post_id = :post_id)');
     parent::bind(':member_id', $param['member_id']);
     parent::bind(':image_id', $param['image_id']);
     parent::bind(':post_id', $param['post_id']);
     parent::execute();
 }
コード例 #15
0
 public function EditProductProcess($param)
 {
     parent::query('SELECT * FROM dd_product');
     parent::execute();
     parent::execute();
     $dataset = parent::resultset();
     return $dataset;
 }
コード例 #16
0
ファイル: menu.php プロジェクト: adu89/RestFramework
 function __construct()
 {
     require_once $_SERVER['DOCUMENT_ROOT'] . '/restfulController/application/database.php';
     $database = new Database();
     $query = "SELECT * FROM Menu LEFT JOIN Content ON Menu.MenuContentKey = Content.ContentKey ORDER BY Menu.MenuID ASC";
     $this->Menu = $database->execute($query);
     $database->close();
 }
コード例 #17
0
 public function CommentAlreadyCheckingProcess($param)
 {
     parent::query('SELECT ac_id FROM dy_activity WHERE (ac_member_id = :member_id) AND (ac_action = "new_comment") AND (ac_to_post_id = :post_id)');
     parent::bind(':member_id', $param['member_id']);
     parent::bind(':post_id', $param['post_id']);
     parent::execute();
     return parent::single();
 }
コード例 #18
0
ファイル: model.inc.php プロジェクト: wst/spindash
 public static function createTable(Database &$db)
 {
     $sql = 'CREATE TABLE ' . self::pluralForm(get_called_class()) . ' (';
     foreach (self::getFields() as $k => $v) {
         echo "{$k} -> {$v}\n";
     }
     $sql .= ')';
     return $db->execute($sql);
 }
コード例 #19
0
 public function ListAmphurProcess($param)
 {
     echo 'province_id: ' . $param['province_id'];
     parent::query('SELECT * FROM th_amphur WHERE amphur_province_id = :province_id AND amphur_postcode != "00000"');
     parent::bind(':province_id', $param['province_id']);
     parent::execute();
     $dataset = parent::resultset();
     return $dataset;
 }
コード例 #20
0
ファイル: Post.php プロジェクト: GojkoC/Simple_Blog
 /**
  * Delete Comments
  *
  * @param int $id
  * @return bool
  */
 public function deleteComment($id)
 {
     $this->db->query("DELETE FROM comments \n\t\t\t\tWHERE id = :id");
     $this->db->bind(':id', $id);
     //Execute
     if ($this->db->execute()) {
         return true;
     } else {
         return false;
     }
 }
コード例 #21
0
ファイル: DatabaseTest.php プロジェクト: rasismeiro/cintient
 /**
  * Tests Database::execute($sql,$values), with two arguments, i.e., with
  * variable bindings
  *
  * @dataProvider provider
  */
 public function testExecuteParamsBinding($a, $b, $c)
 {
     $sql = 'INSERT INTO tests (id,fieldvarchar,fieldint) VALUES (?,?,?)';
     $values = array($a, $b, $c);
     $rs = Database::execute($sql, $values);
     $this->assertTrue($rs !== false, 'INSERT failed!');
     $sql = "SELECT id,fieldvarchar,fieldint FROM tests WHERE id=" . $a;
     $rs = Database::query($sql);
     $this->assertTrue($rs !== false && $rs->nextRow(), 'SELECT failed!');
     $this->assertEquals(array($a, $b, $c), array($rs->getId(), $rs->getFieldVarchar(), $rs->getFieldInt()), 'Database contents incorrect');
 }
コード例 #22
0
ファイル: site.model.php プロジェクト: jimmy18dev/dailypoint
 public function ListKeywordProcess($param)
 {
     parent::query('SELECT * FROM dy_keyword WHERE kw_total > 0 ORDER BY kw_total DESC LIMIT 100');
     parent::execute();
     $dataset = parent::resultset();
     foreach ($dataset as $k => $var) {
         $dataset[$k]['kw_create_time_facebook_format'] = parent::date_facebookformat($var['kw_create_time']);
         $dataset[$k]['kw_update_time_facebook_format'] = parent::date_facebookformat($var['kw_update_time']);
     }
     return $dataset;
 }
コード例 #23
0
 private function getAllId(Database $database)
 {
     $query = 'SELECT id FROM accounts';
     $result = $database->execute($query);
     $allId = array();
     $fetch = $result->fetch();
     while ($fetch) {
         array_push($allId, $fetch['id']);
         $fetch = $result->fetch();
     }
     return $allId;
 }
コード例 #24
0
 public function CheckingBankTransferProcess($param)
 {
     parent::query('SELECT mf_id FROM dd_money_transfer WHERE mf_to_bank = :bank_id');
     parent::bind(':bank_id', $param['bank_id']);
     parent::execute();
     $dataset = parent::single();
     if (empty($dataset['mf_id'])) {
         return true;
     } else {
         return false;
     }
 }
コード例 #25
0
 public function UpdateReadProcess($param)
 {
     parent::query('SELECT pd_read FROM dd_product WHERE pd_id = :product_id');
     parent::bind(':product_id', $param['product_id']);
     parent::execute();
     $data = parent::single();
     $read = $data['pd_read'] + 1;
     parent::query('UPDATE dd_product SET pd_read = :read,pd_visit_time = :visit_time WHERE pd_id = :product_id');
     parent::bind(':product_id', $param['product_id']);
     parent::bind(':read', $read);
     parent::bind(':visit_time', date('Y-m-d H:i:s'));
     parent::execute();
 }
コード例 #26
0
 public function getByUser(UserEntity $user)
 {
     $db = new Database();
     $result = $db->execute("SELECT * FROM passwords WHERE account = ?", array($user->getId()))->fetch();
     if ($result) {
         $password = new PasswordEntity();
         $password->setId($result['id']);
         $password->setUser($result['account']);
         $password->setPassword($result['password']);
         return $password;
     }
     return null;
 }
コード例 #27
0
ファイル: Auth.php プロジェクト: djatle/sergeyproject
 public function regi()
 {
     $database = new Database();
     $database->query("INSERT INTO users VALUES (Null,'" . $this->Login . "', '" . $this->Password . "', '" . $this->Email . "',  now(),now(),'unblock')");
     $database->bind(':Id', Null);
     $database->bind(':Login', $this->Login);
     $database->bind(':Password', $this->Password);
     $database->bind(':Email', $this->Email);
     $database->bind(':blockunblock', 'unblock');
     $database->execute();
     //$query = "INSERT INTO users VALUES (Null,'".$this->Login."', '".$this->Password."', '".$this->Email."',  now(),now(),'unblock')";
     return $query;
 }
コード例 #28
0
    public function CountNotificationProcess($param)
    {
        parent::query('SELECT COUNT(ac_id) 
			FROM dy_activity 
			LEFT JOIN dy_post ON ac_to_post_id = po_id 
			LEFT JOIN dy_member ON ac_member_id = me_id 
			LEFT JOIN dy_comment ON ac_to_comment_id = cm_id 
			WHERE (ac_action = "new_comment" OR ac_action = "thanks_post") AND (po_member_id = :member_id) AND (ac_member_id != :member_id) AND (ac_status = "unread")');
        parent::bind(':member_id', $param['member_id']);
        parent::execute();
        $data = parent::single();
        return $data['COUNT(ac_id)'];
    }
コード例 #29
0
ファイル: Log.php プロジェクト: windhamdavid/Lychee
 /**
  * @return boolean Returns true when successful.
  */
 private static function text($connection, $type, $function, $line, $text = '')
 {
     // Check dependencies
     Validator::required(isset($connection, $type, $function, $line, $text), __METHOD__);
     // Get time
     $sysstamp = time();
     // Save in database
     $query = Database::prepare($connection, "INSERT INTO ? (time, type, function, line, text) VALUES ('?', '?', '?', '?', '?')", array(LYCHEE_TABLE_LOG, $sysstamp, $type, $function, $line, $text));
     $result = Database::execute($connection, $query, null, null);
     if ($result === false) {
         return false;
     }
     return true;
 }
コード例 #30
0
ファイル: user.php プロジェクト: adu89/RestFramework
 static function findByUsername($username)
 {
     $database = new Database();
     $query = 'SELECT * FORM User WHERE UserName = :un';
     $varMap = array(':un' => $username);
     $result = $database->execute($query, $varMap);
     if (count($result) > 1) {
         throw new Exception("Multiple username: {$username} found!");
     } else {
         if (count($result) == 1) {
             return $result[0];
         }
     }
     return false;
 }