Пример #1
0
 public static function Logging(User $user, Package $pkg, mfwUserAgent $ua, $con = null)
 {
     $now = date('Y-m-d H:i:s');
     $sql = 'INSERT INTO install_log' . ' (app_id,package_id,mail,user_agent,installed)' . ' VALUES (:app_id,:package_id,:mail,:user_agent,:installed)';
     $bind = array(':app_id' => $pkg->getAppId(), ':package_id' => $pkg->getId(), ':mail' => $user->getMail(), ':user_agent' => $ua->getString(), ':installed' => $now);
     mfwDBIBase::query($sql, $bind, $con);
     $sql = 'INSERT INTO app_install_user (app_id,mail,last_installed) VALUES (:app_id,:mail,:last_installed) ON DUPLICATE KEY UPDATE last_installed=:last_installed';
     $bind = array(':app_id' => $pkg->getAppId(), ':mail' => $user->getMail(), ':last_installed' => $now);
     mfwDBIBase::query($sql, $bind, $con);
 }
Пример #2
0
 public static function updateCursor($repo_id, $cursor, $con = null)
 {
     $cursor_table = 'repository_cursor';
     $sql = "SELECT * FROM {$cursor_table} WHERE repo_id=?";
     $row = mfwDBIBase::getRow($sql, array($repo_id), $con);
     if (empty($row)) {
         $sql = "INSERT INTO {$cursor_table} (repo_id,number) VALUES (:repo_id,:number) ON DUPLICATE KEY UPDATE number=:number";
     } else {
         $sql = "UPDATE {$cursor_table} SET number=:number WHERE repo_id=:repo_id";
     }
     $bind = array(':repo_id' => $repo_id, ':number' => $cursor);
     return mfwDBIBase::query($sql, $bind, $con);
 }
Пример #3
0
 public function delete()
 {
     $sql = 'DELETE FROM app_install_user WHERE app_id = :app_id AND mail = :mail';
     $bind = array(':app_id' => $this->getAppId(), ':mail' => $this->getMail());
     return mfwDBIBase::query($sql, $bind, $con);
 }
Пример #4
0
 public static function insertNewApp($owner, $title, $image, $description, $repository)
 {
     $now = date('Y-m-d H:i:s');
     // insert new application
     $row = array('title' => $title, 'api_key' => static::makeApiKey(), 'description' => $description, 'repository' => $repository, 'date_to_sort' => $now, 'created' => $now);
     $app = new Application($row);
     $app->insert();
     // upload icon to S3
     $icon_key = static::uploadIcon($image, $app->getId());
     $table = static::TABLE_NAME;
     mfwDBIBase::query("UPDATE {$table} SET icon_key = :icon_key WHERE id= :id", array(':id' => $app->getId(), ':icon_key' => $icon_key));
     // insert owner
     $row = array('app_id' => $app->getId(), 'owner_mail' => $owner->getMail());
     $owner = new ApplicationOwner($row);
     $owner->insert();
     return $app;
 }
Пример #5
0
 public static function addOwner($app_id, $owners, $con = null)
 {
     $bind = array(':app_id' => $app_id);
     $values = array();
     foreach ($owners as $k => $v) {
         $key = ":mail_{$k}";
         $values[] = "(:app_id,{$key})";
         $bind[$key] = $v;
     }
     $sql = 'INSERT INTO application_owner (app_id,owner_mail) VALUES ' . implode(',', $values);
     return mfwDBIBase::query($sql, $bind, $con);
 }
Пример #6
0
 public static function removeFromPackage(Package $pkg, $con = null)
 {
     $sql = 'DELETE FROM package_tag WHERE package_id = ?';
     mfwDBIBase::query($sql, array($pkg->getId()), $con);
 }
Пример #7
0
 /**
  * オブジェクトのレコードを削除.
  */
 public static function delete(mfwObject $obj, $con = null)
 {
     $table = static::TABLE_NAME;
     $sql = "DELETE FROM `{$table}` WHERE `id` = ?";
     return mfwDBIBase::query($sql, array($obj->getId()), $con);
 }