はてなキーワード: Nameとは
去年から活動を始めたエロ同人誌作家「無糖紅茶」さんがめっちゃ好きなんだが、
https://twitter.com/mutoukoutya610
タイムラインにこのツイートが出てきて、子供の頃のことを思い出した。
https://twitter.com/scissors_nagasa/status/1091335900817063936
中学1年か2年のときの英語の授業で、「自分の名前の由来を親に聞いてきて、次の授業のときにで英語で説明しなさい」という宿題が出た。
私は親に虐待というほどのなにかを受けていたわけではないけれど、うまい関係は築けていなかった。
暗澹たる気持ちで一応母親に由来を聞いてみたところ、返って来た答えは「あるわけねぇだろ馬鹿野郎!!!!!」だった。
その直前まで何も怒っておらず落ち着いていたように見えたのに、突然激昂した。まあでもこれはいつものことだった。
私はこの激昂のスイッチがわからず、かといって息を潜めて生きるのもうまくできなくて、ずっと苦しかった覚えしかない。
翌日の英語の授業は宿題の答え合わせがないまま残り15分になった。
私は授業開始時点では当てられたらどうしようとかなり焦っていたが、このときにはもう完全に安心していた。
ところが突然先生が「では昨日の宿題の答え合わせをしましょう」と言い出して、あろうことか私をピンポイントで当ててきた。
「さあ、説明してください。あなたの名前の由来はなんですか?」
起立したけど何も言えなくて、でも何か言わなきゃいけなくて、喉の奥がひくつくのを感じながら一言「nothing」と言った。
先生は目をまんまるに見開いて(普段からやたら動作も表情も大げさな先生だった)、「ないってどういうこと?なにかあるでしょ?」と詰め寄ってきた。
教壇から降りてこちらまで歩いてくる先生。静まり返っている教室。コツコツという靴の音だけが響いていた。
なにか言わなきゃ、でも何も言えることなんていない。
「さあ、教えて。あなたの名前の由来は?」やたら顔を近づけて聞いてくる。近いのはやめてほしかった。
「I cannot hear anything」こんな感じのことを絞り出した気がする。
「じゃあいいわ。あなたの名前の漢字を説明して」先生は一応逃げ道をくれた。
しかし自分の名前は全部ひらがなだったので私はそれを使って逃げることはできなかった。
長い間うちのクラスを教えておきながらこの人は私の名前も知らないんだな、とぼんやり思った。
「早く答えて。みんなの迷惑になるでしょ?」先生がまた顔を近づけてくる。
「I don't have kanji characters in my name」とか言った気がする。クラスのみんなはまだ静まり返っている。
もともと授業中は静かなクラスだったけど、空気が緊張しきっていた。
「えええ??仕方ないわねえ。じゃあ由来を言って。早く。みんなの迷惑でしょ」迫る先生。
なにかいいたい。何も言えない。時計の針はまだあと10分以上残り時間があることを示している。
はやく、はやく、チャイム鳴って、はやく。
このあと私は学校でトイレに閉じこもって大泣きした。2時間ぐらい出てこれなかった気がする。
元のツイートに戻って、こんな思いをするような子供がいることがわからないならまだ仕方がない。教育者には知っていてほしいけど。
FY Creation LLC. built the CLX for Craigslist app as a Free app. This APP is provided by FY Creation LLC at no cost and is intended for use as is.
This page is used to inform app visitors regarding our policies with the collection, use, and disclosure of Personal Information if anyone decided to use our App.
If you choose to use our App, then you agree to the collection and use of information in relation to this policy.
Information Collection and Use
When using the APP, it only collects anonymous usage information to operate, improve and personalize the products. The APP does not collect any Personally Identifiable Information (PII) about you, nor does it match collected anonymous usage data with any 3rd party PII information.
We want to inform you that whenever you use our App, in a case of an error in the app we collect data and information (through third party products) on your phone called Log Data. This Log Data may include information such as your device Internet Protocol (“IP”) address, device name, operating system version, the configuration of the app when utilizing our App, the time and date of your use of the App, and other statistics. If you use our app to read or post information on our app, we don't collect any information about your identity. If you identify yourself by sending us an e-mail containing personal information, then the information collected will be solely used to respond to your message. In addition to other information described in this policy, we may collect and share precise location information including the presence of connected devices via bluetooth, through methods such as partner mobile “SDKs”. This information may be used by itself, aggregated, or combined with mobile identifiers (such as IDFAs and Android IDs), and shared with other parties, for purposes related to advertising, attribution (e.g., measuring ad performance), analytics and research. You can remove your consent to having your location data collected by changing the settings on your device (but certain services may lose functionality as a result). You can also control options through your device’s opt-out settings which will: (i) tell advertisers to not use your in-app information from that device to gather information about your interests to target interest-based ads and (ii) inform some partners to halt further data collection and sharing from that device.
Service Providers
We may employ third-party companies and individuals due to the following reasons:
To provide the App on our behalf;
To perform App-related services; or
To assist us in analyzing how our App is used.
We want to inform users of this App that these third parties have access to your Personal Information. The reason is to perform the tasks assigned to them on our behalf. However, they are obligated not to disclose or use the information for any other purpose.
Security
We value your trust in providing us your Personal Information, thus we are striving to use commercially acceptable means of protecting it. But remember that no method of transmission over the internet, or method of electronic storage is 100% secure and reliable, and we cannot guarantee its absolute security.
Links to Other Apps or Websites
This App may contain links to other Apps or Websites. If you click on a third-party link, you will be directed to that app or website. Note that these external apps or sites are not operated by us. Therefore, we strongly advise you to review the Privacy Policy of these apps or websites. We have no control over and assume no responsibility for the content, privacy policies, or practices of any third-party apps or websites or services.
Changes to This Privacy Policy
We may update our Privacy Policy from time to time. Thus, you are advised to review this page periodically for any changes. We will notify you of any changes by posting the new Privacy Policy on this page. These changes are effective immediately after they are posted on this page.
Contact Us
If you have any questions or suggestions about our Privacy Policy, do not hesitate to contact us
This app has no affiliation with Craigslist. Craigslist is a registered trademark of Craigslist, Inc. Please visit Craigslist's privacy policy to better understand their data collection practices and controls that they make available to you.
These Terms of Service ("Terms") are a legal agreement between we and you ("you"). By installing or using any application ("Service") you agree to be bound by these Terms. By accessing or using the Service, you agree that you have read, understood, and accept to be bound by the Terms. We reserve the right, in its sole discretion, to modify or revise these Terms at any time, and you agree to be bound by such modifications or revisions. If you do not agree to the Terms, do not use the Service.
Users are responsible for periodically viewing the Terms. Your continued use of the Service after a change or update has been made will constitute your acceptance to the revised Terms. If you do not agree to the Terms your only remedy is to discontinue your use of the Service and cancel any accounts you have made using the Service.
We reserve the right to refuse any user access to the Services without notice for any reason, including, but not limited to, a violation of the Terms.
You represent that you are 13 years old or older. If you are between the ages of 13 and 18, you represent that your legal guardian has reviewed and agrees to the Terms.
All materials that are part of the Service (including, but not limited to, designs, text, graphics, pictures, video, information, applications, software, music, sound and other files, and their selection and arrangement) are protected by law from unauthorized use.
We grant you a personal, non-exclusive, non-transferable, revocable, limited scope license to use the Service solely for the purpose of viewing and using the applicable Services and for no other purpose whatsoever. Your license to use the Services is limited by these Terms.
You agree that you are willingly publishing the content on the Service using technology and tools provided by us. You understand and agree that you may not distribute, sell, transfer or license this content and/or application in any manner, in any country, or on any social network or another medium without the explicit written permission of us. We reserve the right to remove and permanently delete any User Content from the Service with or without notice.
You agree that all your communications with the Communication Channels are public, and thus you have no expectation of privacy regarding your use of the Communication Channels. We is not responsible for information that you choose to share on the Communication Channels, or for the actions of other users.
By using the Service, you agree to the collection and use of your personal information as outlined in this Privacy Policy. We may amend the Privacy Policy from time to time, and we encourage you to consult the Privacy Policy regularly for changes.
A cookie is a small data file that we transfer to your computer’s hard disk, generally to quickly identify a user's computer and to "remember" things about the user's visit, such as your preferences or a user name and password. The Service sends cookies to your computer when you access or view the content of us. The information contained in a cookie may be linked to your personal information for purposes such as improving the quality of our service, tailoring recommendations to your interests, and making the Service easier to use. You can disable cookies at any time, although you may not be able to access or use features of the Service.
Third-Party Advertising Companies
We may use third-party advertising companies to serve ads on the Service. We do not provide any personal information to third-party advertising companies on a non-aggregate basis. Our system and the third-party advertising technology may use aggregate information, non-personal information, Our cookies on your hard drive and your use of the Service to target advertisements. In addition, advertisers may use other third-party advertising technology to target advertising on other sites. If advertisements are served to you, a unique third-party cookie or cookies may be placed on your computer. Similarly, third-party advertising companies may provide us with pixel tags (also called “clear gifs” or “beacons”) to help manage and optimize online advertising. Beacons enable us to recognize a browser’s cookie when a browser visits the site on which is a beacon is located, and to learn which banner ads bring users to a given site.
You may review, update, correct or delete any personal information by changing the applicable information in your profile page on Facebook and/or another social network (s). If you completely delete all this information, your account may become deactivated. If you would like us to delete your record in our system, please contact us and we will attempt to accommodate your request if we are not legally obligated to retain the record.
We have put in place reasonable technical and organizational measures designed to secure your personal information from accidental loss and from unauthorized access, use, alteration or disclosure. However, we cannot guarantee that unauthorized third parties will never be able to overcome those measures or use your personal information for improper purposes. Also please note that email and messaging systems are not considered secure, so we discourage you from sending us personal information through these mediums.
The Service is not geared toward children under the age of 13 and we do not knowingly collect personal information from children under the age of 13. If we learn that a child under 13 has provided us with personal information we will delete such information from our files as quickly as possible.
Disclaimer of Warranty; Limitation of Liability
You agree that your use of the Service shall be at your sole risk. To the fullest extent permitted by law, We, its officers, directors, employees, and agents disclaim all warranties, express or implies, in connection with the website and your use thereof including implied warranties of title, merchantability, fitness for a particular purpose or non-infringement, accuracy, authority, completeness, usefulness, and timeliness. We make no warranties or representations about the accuracy or completeness of the content of the Service and of the content of any sites linked to the Service; We assume no liability or responsibility for any (i) errors, mistakes, or inaccuracies of content, (ii) personal injury or property damage, of any nature whatsoever, resulting from your access to and use of the Service, (iii) any unauthorized access to or use of our secure servers and/or any and all personal information and/or financial information stored therein, (iv) any interruption or cessation of transmission to or from the Service, (v) any bugs, viruses, trojan horses, or the like which may be transmitted to or through the Service by any third party, and/or (vi) any errors or omissions in any content or for any loss or damage of any kind incurred as a result of the use of any content posted, emailed, transmitted, or otherwise made available via the Service.
In no event will We, its directors, officers, agents, contractors, partners and employees, be liable to you or any third person for any special, direct, indirect, incidental, special, punitive, or consequential damages whatsoever including any lost profits or lost data arising from your use of the Service or other materials on, accessed through or downloaded from the Service, whether based on warranty, contract, tort, or any other legal theory, and whether or not We have been advised of the possibility of these damages. The foregoing limitation of liability shall apply to the fullest extent permitted by law in the applicable jurisdiction. You specifically acknowledge that We shall not be liable for user submissions or the defamatory, offensive, or illegal conduct of any third party and that the risk of harm or damage from the foregoing rests entirely with you.
You agree to indemnify and hold We, and each of its directors, officers, agents, contractors, partners, and employees, harmless from and against any loss, liability, claim, demand, damages, costs and expenses, including reasonable attorney's fees, arising out of or in connection with (i) your use of and access to the Service; (ii) your violation of any term of these Terms of Service; (iii) your violation of any third party right, including without limitation any copyright, property, or privacy right; (iv) any claim that one of your User Submissions caused damage to a third party; or (v) any Content you post or share on or through the Service.
By visiting or using the Service, you agree that the laws of UK, without regard to principles of conflict of laws and regardless of your location, will govern these Terms of Service and any dispute of any sort that might arise between you and us.
If you have any questions about these Terms of Service, please contact us at otoco.contact@gmail.com
はてブのおもしろページ、ねこのら~とか言うのが3つもあって目障り。
Anti-アドブロッカーキラー関連ですでに入れている人も多いかも。
https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo?hl=ja
http://b.hatena.ne.jp/hotentry/funに対して、下記のスクリプトを追加する。
// ==UserScript== // @name New Userscript // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match http://b.hatena.ne.jp/hotentry/fun // @require http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js // @grant none // ==/UserScript== (function() { 'use strict'; $('.following-bookmarks-container[data-entry-url^="http://www.nekonora"]').parent().parent().remove(); })();
やった~
I always ran away from a childhood.
My parents taught me to say "Yoshie" to myself who are only looking at the neighboring children playing from where they are playing. It means that if you write in kanji "wanna be", I want you to put it in a group. At last I never said it.
I was just playing inside the house. I did not get bored because the books and games were given as such. Although I was only watching TV when I was doing animation or special effects, I did not get interested in dramas and song programs.
Kindergarten and elementary school were pitch dark jungle. There are lurid animals lurking around, and it gets bitten when it gets out of hand. They are laughed at by "friends" who do not know their faces and names, are faced with confusion, have remembered remembered.
Because I do not know what will come up in the classroom, I wandered around the school looking for a hiding place. I was afraid to blink because I do not know what to do if my eyes are closed.
When I went to public middle school as it is, I decided to pursue an advanced school at my parent's discretion that he must be killed. I did not know exactly what the school was going to do, but as a result of trying hard as I said, I caught somewhat over there.
I do not know whether public was a good because I do not know public. The classmate was still a flock of beasts, but there was no prominent bad group. There was a big library, so I arrived at the vacant time. The secondhand bookstore in the way back was also a favorite place. It took about an hour from the house by bus, but it was exactly good to read a book and sometimes got over it.
Although it is an advanced school that entered with great difficulty, I do not remember having worked hard on my studies. During the class we did nothing but graffiti in the textbooks and drew the accumulated delusions in secret notes. Although I had the opportunity to choose club activities after enrollment, I was told that my partner in the department I tried to join was left with a promise for the first time as it was. Since it was consistent in middle and high level, there was no break and only the number of the grade increased.
Although I heard that it seems that they will go to university after going out of high school, I did not understand the mechanism of the exam and so on, so I did not distinguish between the mock test and the center exam. Because I was not particularly conscious of which university I wanted to go to, I received the appropriate undergraduate properly for my grades.
I went to the national state of the neighboring prefecture and got a remittance and started living by my own apartment. It was quite a city compared to the mountain and the rural family of the rice fields, but the main use was Super, Hundred Hundred, and a secondhand bookstore old game store. I was thinking only how to live within a given amount of money without doing a part-time job.
Every lecture was interesting, and the library was big. I also touched on computers and the Internet for the first time. However, it was only in truics that gathered up, and I did not know what to aim for.
People around me were no longer beasts at this time, but I could not feel like approaching from myself. Some people call me out and I also tried circle activities, but eventually I did not last long for any relationship. It seemed to be crushed by a feeling of disgust for myself who flew in association with people and inferiority complex to a person advancing with dreams and goals.
The graffiti of the note was continued, but the more I wrote the more I could show my emptiness. The setting and design I thought was original was only imitation of someone. Both love and ideal were words alone, I did not believe anything.
While taking a stroller while taking a unit, I could not write a thesis. I can not think of any theme I want to study. I could not see anything I wanted to do, I should do, I could do nothing. I knew there was no head like I could go to the hospital and I could not do anything that could help society with what I learned.
I smuggled without meaning suddenly in my assigned laboratory, graduated after two years of retirement. I submitted a graduation thesis that just briefly gathered texts gathered with books and the net as it was given to the professor, and escaped to my parents house.
Because I can not just stay in bed at home, I started job hunting, but there is no reason to find a company that only has a college graduate title, there are companies that hire people who do not even know the jobs that I want to do but I do not know. I decided to work hourly as a food warehouse in the neighboring town according to the advice that it is good anywhere as it is supposed to work after trying it. It was supposed to be for the moment, but it has been ten years as it is.
Physical labor was painful but I got used to it for years. Basically it's not necessary to use your head as it just moves boxes according to written numbers. There are people in the surroundings, but there is no talk except a morning greeting and trouble report. Many boxes are shipped everyday, but the buyer knows only the name written on the label. I just keep carrying boxes.
The salary is also about that, as it is a job that also works for student part-time jobs. Thanks to my hometown my savings were somewhat sad, but if there is a big expenditure due to sickness etc. it will easily be erased. I should have searched for another job, but I could not move my mind if I thought that I could do other work for myself struggling even such an easy job.
There is no dissatisfaction with the daily life itself. I do not have to worry about eating and if I am playing games with candy at home if I have stress on work I can solve it. There is no reason to stick to clothes and grooming as I never see anyone outside the company. Especially there are no places to go and nobody wants to see. I do not drink it, do not hit it, do not buy it.
It turned 40 years old. Although I told you to be a fairy when I was alone after passing 40, this may actually be such a fairy town. Instead of struggling, new things do not happen. Like a light rainy afternoon, quietly just waiting for the night.
This week was a similar week as last week. It will be the same next week. Every day next month and next year, days that do not change will continue. In the meantime parents fall down. And then. There is only a big event left in life anymore.
I think that my life has already ended. I am not dead alone, I am not alive. You can set as many small targets as you want, but it will never lead to something else.
Even though I thought what I wanted to do, I did not understand it after all. I feel a little sad when I think that it is born empty and die empty.
だから英語が苦手と言われている日本人も中国人も、何言ってんのかわかんねーよとよく言われる東南アジアの国々の人も、訛りまくった英語を世界中の国際港で使ってます
そこで話題に出てくる「国際商船共通網」こと日本語で言うところの「国際(船舶)VHF」ですが、国際VHFの国際的な運用ルールに「チャンネル16(156.800MHz)を常に聴取しておかなければならない」ってのがあるんですね
まぁつまり軍人だろうが民間人だろうが船乗りならばチャンネル16で汚っく訛りまくった英語をいつも聴いているわけですよ
そんなんだから1回目の呼び出しじゃ気付かないことは確かにあるんです
でも2回目でたいてい誰かを呼び出しているのは気付くので、もしかしてウチかな?なんて思って「Now call me? I'm Vessel Name is HOGEHOGE MARU. H O G E H O G E M A R U. Over.」とか文法メッチャクチャで返答したりするんです
それが正解なら相手は「Yes HogeHoge Maru.Change to channel 13. Channel One Three Over.」とかアッチもテキトーな英語で返してくるんですね
3回目の呼び出しなんて相手はまず間違いなくAIS(船舶自動識別装置)で船のナンバープレートみたいなIMO番号ってのを調べたりして「IMO NUMBER! ONE! TWO! THREE! FOUR! SHIP COLOR WHITE! JAPANESE SHIP! HOW DO YOU READ!?YOUR OK!!?????」みたいにブチキレて通信してきます
ここまで来ると最寄り港のコーストガードも反応せざる得なくなり、入港時にコーストガードから叱られるハメになる
まぁ流石に訓練された軍人さんはブチキレて通信したりしないでしょうけど、こういう汚っく訛りまくった英語の怒声すら毎日聴いてるわけですよ
それが普通なのに「相手の英語が下手すぎてわからなかった」なんてのは海の世界じゃまず間違いなくあり得ないわけで意図的に無視したとしか思えないです
もっと言ってしまえば日本海は国際VHFの無法海域とすら言われており、夜間航行時とか海外の船乗りがよくわからんギターの弾き語りをチャンネル16に載せて放送したり、流行りのポップスやダンスミュージックすら流れてくることがあります
ていうか韓国沿岸では韓国地元漁師が街宣車の如く韓国音楽を大音量で流しながら操業しているなんてのは日常茶飯事で、国際VHFどころか船外からクッソうるさいノイズが入ってくるのに、そんな環境に慣れた韓国海軍が英語聴き取れないとかノイズがどうのとかあり得ないわけですよ
ハイライトできないがまぁまぁ見れるようになった。
・'<'と'>'と空白を数値文字参照に変換
・以下のように置換
行頭→<tt>
行末→</tt>
改行→<br>
#include <iostream>
template<int N> struct int_ {};
template<bool B> struct bool_ {};
struct continue_{};
struct end_{};
template <bool Cond>
auto is_end(bool_<Cond>)
-> typename std::conditional<Cond, end_, continue_>::type;
template <typename T, int N>
auto add_pointers_impl(T, int_<N>, continue_)
-> decltype(
add_pointers_impl(
std::declval<T*>(),
int_<N - 1>(),
std::declval<
decltype(
is_end(
bool_<N-1 == 0>()
)
)
>()
)
);
template <typename T, int N>
auto add_pointers_impl(T, int_<N>, end_)
-> T;
template <typename T, int N>
auto add_pointers(T, int_<N>)
-> decltype(
add_pointers_impl(
std::declval<T>(),
int_<N>(),
std::declval<
decltype(
is_end(
bool_<N == 0>()
)
)
>()
)
);
int main()
{
typedef decltype(add_pointers(std::declval<int>(), int_<3>())) result;
result pppi;
std::cout << typeid(pppi).name() << std::endl;
int*** pppi2;
std::cout << typeid(pppi2).name() << std::endl;
return 0;
}
VisualStudioでローカルで動作するアプリを作ろうと思ってるんだけど
本当に初歩的なことかもしれないことが分からない。
「class」というやつについてだ。
そいつの中には複数のclassさんが存在してもいいのか?SAVACLASSとLOADCLASSが存在しても良いのか?
public class Person { public string name { get; set; } public int age { get; set; } } public class Office { public string name; public ObservableCollection<Person> persons; } private Office office; private void init() { office = new Office(); office.name = "オフィス"; office.persons = new ObservableCollection<Person>(); office.persons.Add(new Person { name = "001", age = 11 }); office.persons.Add(new Person { name = "002", age = 22 }); office.persons.Add(new Person { name = "003", age = 33 }); }
OFFICEという属性にはPARSONというものが集まってて、そのPARSONの情報にはNAMEとAGEがありますよ!というのは分かるんだけど
シリアライズも、デシリアライズも、「圧縮⇔解凍」みたいなイメージしかないし
うーん。難しい。
クラスって何なんだ。VBA風に説明できる人いない?(VBAでもClassは使わずにFunctionとSUBだけ使い回してた)
IE11でファイルアップロード機能がいつの間にか動かなくなる事案が発生。
リーダーが履歴を丹念に追いながらこつこつ調べていったところ、フロントエンド側に入ったinputタグの修正が問題だと気づいた。
...なにこれと行き詰まりを見せた中で、無事だった別の画面の同様の処理で
```
<input type="hidden" name="dummy" value="dummy">
```
これはなんだ?と調べると下記のウェブサイトにヒット。
直し方も書いてあった。先ほどの呪文だ。name属性があるinputタグが最後にあればいいのだ。
ありがてぇありがてぇ。
https://stealthinu.hatenadiary.jp/entry/20141106/p1
https://qiita.com/marsa746079/items/a3c69465d605a0078a6b
みんな最初の先人は正直どうしたら気づくの?もしも回答がなかったらどうしてたんだろう。
話は変わるが、アンドロイドのインストール周りで、画面が無限に増えるバグを解決するために死ぬほど苦しんだことがあって
Activity→Intent→Flg値→6進数の値でググるで下記のエントリにあたって命と髪の毛を救われたことがあった。
ありがてぇありがてぇ。
http://d.hatena.ne.jp/kk_Ataka/20130804/1375624170
今日Javaの日本標準時が18:59ずれる問題にあたったブログを拝見したが、
あの時はこんな挙動になるけどなんで??という人のブログを最初に見つけて
自分もこの事象に遭遇した!!まず、安心したわ。そして解決方法もこっちにありましたよ。ありがとう。
ここ10年くらいずっと思ってたんだけど、商品名とかサービス名の頭文字に「i」つけるやつ多すぎて鬱陶しい。
なので、由来を調べてみた。
iMac、iPod、iPhone、iPad、iCloudなど。統一感があるといえばそうだけど、アイアイうるさい。
由来は、
The person to ‘blame’ for the massive i-trend is Ken Segall. After presenting the see-through drop-shaped monitor, Jobs was in desperate need for a name that would suit it, and its follow-ups. The key importance of the new product was that it would be easily used for internet work – that was the design. And they wanted to incorporate the Macintosh brand in the name. So Segall proposed iMac – an internet-Mac. The ‘i’ as a prefix could also incorporate other adjectives such as individual, innovative, imaginative etc, depending on the product.
(HIGHNAMESより)
ということらしい。「i」を頭文字に持つポジティブな英単語が多すぎるのが悪い。
ちなみに、Apple Watchが慣習に則ってiWatchと命名されなかった理由については、Why the Apple Watch isn't called the iWatchでは商標の問題だとかApple Watchは、なぜ「iWatch」ではなかったのかではコンセプトの問題だとかいろいろ憶測が流れている。
「iモード」の『i』は、インタラクティブ・インフォメーション・インターネットの頭文字の『i』、そして英語で「私」の意味の『i』であるとされる。
(Wikipediaより)
A prime example of a good product with a really bad name. Formerly Google Personalised Homepage, in a rare mistake by Google they chose to rename it using the faux Apple and now meaningless 'i' prefix, meaning 'Internet'.
(Urban Dictionaryより)
Urban Dictionaryなので信憑性はない。当初の名前が「Google Personalized Homepage」であったことを考えると、「私」の意味での「i」だと言われた方がしっくりくるけど、由来が何であれ、この名前はださい(愛用はしていた)。
Interactive Python。
Inline Frame。
これはちょっと毛色が違う。一括りにしてごめんな。
===
実際書き出してみたら、意外とそんなに思いつかなかった。もうこれ以上出てこないでほしい。
基本は、同じなので前回やった更新処理をちょっと変えれば削除もすぐできます。
投稿されたメッセージを削除する機能を、Webページに付けてみよう。
前々回作ったメッセージの一覧の中に、削除ページにジャンプするリンクも入れておいた。
<td><a href="welcome/delete/<?php echo $item['id']; ?>">削除</a></td>
ブラウザーでHTMLソースを見ると、ここが以下のようなHTMLに書き換わってる。
これは「メッセージID番号が2のメッセージ」を削除対象にして、削除ページにジャンプする。
ユーザーが「http://localhost/waf/welcome/delete/2」というURLで、削除ページにアクセスしたら、コントローラーで「2」を受け取って使いたい。
CodeIgniterでは、URLの文字列を解析して、使うことができる。
以下のようにコントローラーを改造してみよう。
// 削除画面
public function delete($id = '')
{
$this->load->view('chat_delete');
}
delete()メソッドの引数で、URL中の「2」の部分を受け取れる。
「$id = $this->uri->segment(3);」でも受け取れる。
ユーザーに「本当に削除しますか?」みたいな注意喚起をしておきたい。
<?php defined('BASEPATH') or exit('No direct script access allowed');?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<base href="<?php echo base_url(); ?>">
</head>
<body>
<form action="welcome/delete" method="post" accept-charset="utf-8">
<p style="background-color:lightpink"><?php echo $talk['message']; ?></p>
<input type="hidden" name="id" value="<?php echo $talk['id']; ?>">
<input type="hidden" name="action" value="delete">
<?php else: ?>
<p>※該当するメッセージがありません。(または削除済です。)</p>
<?php endif;?>
<button>削除する</button>
</form>
<p><a href="welcome/index">戻る</a></p>
</body>
</html>
<p style="background-color:lightpink"><?php echo $talk['message']; ?></p>
削除するメッセージを色付きで強調して、ユーザーに確認してもらう。
<input type="hidden" name="id" value="<?php echo $talk['id']; ?>">
コントローラーに削除対象のメッセージID番号を送るため、inputタグの「type="hidden"」でメッセージID番号を仕込んでおく。
// 削除画面
public function delete($id = '')
{
$id = $id ? $id : $this->input->post('id');
$action = $this->input->post('action');
$this->chat_model->delete_message($id);
}
$data['talk'] = $this->chat_model->read_message_by_id($id);
$this->load->view('chat_delete', $data);
}
で、モデルに用意したデータ削除用メソッドを呼び出しているだけ。
次は、モデルでdelete_message()メソッドを用意しよう。
// Delete
public function delete_message($id = 0)
{
$sql = "DELETE FROM talk WHERE id = ?";
$param = array($id);
$this->db->query($sql, $param);
return $this->db->affected_rows();
}
SQLの「DELETE」を使えば、指定したレコード(1件分のデータ)を削除できる。
「DELETE FROM talk WHERE id = ?」で、talkテーブルのmessageをidを指定して削除している。
データを削除した後の挙動は、メッセージID番号がなくなるので、削除ページに表示できるメッセージデータがなくなる。
(例)id=2のデータを削除したら、SQLで「SELECT * FROM talk WHERE id = 2」を取得しても、空のデータ=データがない状態。
その場合は、
<p>※該当するメッセージがありません。(または削除済です。)</p>
と表示させてる。
以上で、SQLの「DELETE」を使ったデータの削除ができた。
長々と説明したが、今回の大事な点は、SQLの「DELETE」の使い方だ。
以上で、MVCフレームワークを使ったOOPの使い方とSQLの使い方を見てきた。
(SQLはSQLだけで説明したほうが良かったね!MVCフレームワークの説明とSQLの説明が混在すると要点が分かりづらくなる?)
anond:20181015215004 未経験からのプログラマーなんだが全然分からない
anond:20181016015826 増田式プログラマー養成講座 その1 パソコンの用意
anond:20181016164341 増田式プログラマー養成講座 その2 プログラム=データ+処理、プログラム言語の種類
anond:20181016180059 増田式プログラマー養成講座 その3 構造化プログラミングの基本(順次、反復、分岐)
anond:20181016193144 増田式プログラマー養成講座 その4 子ども向け教材「Scratch」で構造化プログラミングの練習
anond:20181017161003 増田式プログラマー養成講座 その5 オブジェクトとは何か?
anond:20181017191404 増田式プログラマー養成講座 その6 OOPの種類、PHPの準備
anond:20181019181549 増田式プログラマー養成講座 その7 OOPの仕組み(前半)
anond:20181020230044 増田式プログラマー養成講座 その8 OOPの仕組み(後半)
anond:20181022232327 増田式プログラマー養成講座 その9 MVCフレームワークを使ってみよう
anond:20181023184616 増田式プログラマー養成講座 その10 OOPの参考書
anond:20181024214133 増田式プログラマー養成講座 その11 データベースを使ってみよう
anond:20181026145516 増田式プログラマー養成講座 その12 データベースの参考書
anond:20181028152656 増田式プログラマー養成講座 その13 SQLの文法
anond:20181031014212 増田式プログラマー養成講座 その14 Webアプリの試作品を作成
anond:20181101225335 増田式プログラマー養成講座 その15 Webアプリの完成見本
anond:20181101230220 増田式プログラマー養成講座 その16 Webアプリの完成見本(続き)
anond:20181104161900 増田式プログラマー養成講座 その17 Webアプリの骨組み
anond:20181104233013 増田式プログラマー養成講座 その18 SQLでデータの追加と取得
anond:20181110120715 増田式プログラマー養成講座 その19 SQLでデータの更新
anond:20181110182445 増田式プログラマー養成講座 その20 SQLでデータの削除 ←★今ここ★
anond:20181111205255 増田式プログラマー養成講座 その21 データベース設計 (1)要件定義
:
前回は、Webアプリの骨組み(スケルトン)に、SQLでデータの追加と取得をやりました。
前回作ったメッセージ一覧に、[編集]のリンクも入れておいた。
<td><a href="welcome/update/<?php echo $item['id']; ?>">編集</a></td>
という1行の部分。
ブラウザーでHTMLソースを見ると、以下のようなHTMLになってるはず。
これは「メッセージID番号が2」を対象にして、編集ページにジャンプすることを意味する。
「http://localhost/waf/welcome/update/2」というURLで編集ページにアクセスしたら、メッセージID番号の「2」を受け取れるようにしたい。
// 更新画面
public function update($id = '')
{
$this->load->view('chat_update');
}
CodeIgniterでは、URLから文字列を取り出す方法がいくつか用意されている。
// 更新画面
public function update()
{
$this->load->view('chat_update');
}
CodeIgniterで、URLの文字列から、特定部分の文字列を取り出す方法を見ておこう。
例えば、「http://localhost/waf/welcome/update/aaa/bbb/ccc」というURLにアクセスしたとき、CodeIgniterではURL中の「aaa」「bbb」「ccc」という部分は、以下のようにして取り出せる。
$seg1 = $this->uri->segment(1); // → 1番目のURL文字列:「welcome」=コントローラーのクラス名
$seg2 = $this->uri->segment(2); // → 2番目のURL文字列:「update」=クラスの中のメソッド名
$seg3 = $this->uri->segment(3); // → 3番目のURL文字列:「aaa」の部分
$seg4 = $this->uri->segment(4); // → 4番目のURL文字列:「bbb」の部分
$seg5 = $this->uri->segment(5); // → 5番目のURL文字列:「ccc」の部分
:
URLを「/」で区切って、base_url(http://localhost/waf/)の次から順番に、1番目のURL文字列、2番目のURL文字列、3番目のURL文字列、…とsegment()メソッドで順番を指定すれば取得できる。
データベースでメッセージIDを指定して、メッセージを取り出す機能を用意しよう。
public function read_message_by_id($id = 0)
{
$sql = "SELECT * FROM talk WHERE id = ?";
$param = array($id);
$query = $this->db->query($sql, $param);
return $query->row_array();
}
「WHERE id = 2」とすれば、メッセージID番号が2のメッセージのデータが「talk」テーブルから取り出せる。
もし該当するデータがなければ、返されるデータは空になる。(データが返ってこない。)
CodeIgniterの「row_array()」は、1件分のデータを配列の形にして返すメソッドだ。
<?php defined('BASEPATH') or exit('No direct script access allowed');?>
<!DOCTYPE html>
<html>
<head>
<base href="<?php echo base_url(); ?>">
</head>
<body>
<p>メッセージを変更して「更新する」ボタンを押してください。</p>
<form action="welcome/update" method="post" accept-charset="utf-8">
<label>メッセージ</label>
<input type="text" name="message" value="<?php echo $talk['message']; ?>">
<input type="hidden" name="id" value="<?php echo $talk['id']; ?>">
<input type="hidden" name="action" value="update">
<?php else: ?>
<p>※該当するメッセージがありません。</p>
<?php endif;?>
<button>更新する</button>
</form>
<p><a href="welcome/index">戻る</a></p>
</body>
</html>
データベースから取り出した1件分のメッセージを表示する部分を追加した。
<input type="text" name="message" value="<?php echo $talk['message']; ?>">
の「<?php echo $talk['message']; ?>」という部分だ。
これで変更したいメッセージの本文を表示できる。
あと、編集したメッセージをWebサーバーに送信できるように、Formタグや送信ボタン(「更新する」の部分)も追加した。
<input type="hidden" name="id" value="<?php echo $talk['id']; ?>">
という1行も仕込んである。
// 更新画面
public function update($id = '')
{
$id = $id ? $id : $this->input->post('id'); // id -> segment or post
$action = $this->input->post('action');
if ($action == 'update') {
$message = $this->input->post('message');
$this->chat_model->update_message($id, $message);
}
$data['talk'] = $this->chat_model->read_message_by_id($id);
$this->load->view('chat_update', $data);
}
メッセージID番号を指定して、データベースから取り出し、Viewに渡すデータを用意している。
ユーザーがメッセージの編集をしてWebサーバーに送信したら、データを更新する指示を出す部分も追加した。
$action = $this->input->post('action');
if ($action == 'update') {
$message = $this->input->post('message');
$this->chat_model->update_message($id, $message);
}
モデルにupdate_message()メソッドを用意して、$idと$messageを渡せば、該当データを更新するようにしたい。
次は、モデルでupdate_message()メソッドを用意しよう。
// Update
public function update_message($id = 0, $message = '')
{
$sql = "UPDATE talk SET message = ? WHERE id = ?";
$param = array($message, $id);
$this->db->query($sql, $param);
return $this->db->affected_rows();
}
SQLの「UPDATE」を使えば、指定したレコード(1件分のデータ)を更新できる。
「UPDATE talk SET message = ? WHERE id = ?」で、talkテーブルのmessageをidを指定して更新している。
CodeIgniterの「affected_rows()」メソッドは、更新した行数を返す。=成功なら1行、失敗なら0行となる。
コントローラーの「$id = $id ? $id : $this->input->post('id');」という行は、$idの受け取り方が2パターンあるので、それに対応している。
=編集ページの表示で、1回目の表示と、2回目以降の表示で、$idの受け渡し方が変わっている。
URLに埋め込む方法(上記の1回目のような方法)は、ユーザーが勝手に値をいじれるので、基本的には使わない方が良い。
以上で、SQLの「UPDATE」を使った、データの更新ができた。
長々と説明したが、今回の大事な点は、SQLの「UPDATE」の使い方だ。
CodeIgniterの使い方や、Webサイトの作り方(FormタグなどのHTMLの知識)は、オマケ程度に見ておいて欲しい。
次回は、データを削除するSQL「DELETE」の使い方を見てみよう。
anond:20181015215004 未経験からのプログラマーなんだが全然分からない
anond:20181016015826 増田式プログラマー養成講座 その1 パソコンの用意
anond:20181016164341 増田式プログラマー養成講座 その2 プログラム=データ+処理、プログラム言語の種類
anond:20181016180059 増田式プログラマー養成講座 その3 構造化プログラミングの基本(順次、反復、分岐)
anond:20181016193144 増田式プログラマー養成講座 その4 子ども向け教材「Scratch」で構造化プログラミングの練習
anond:20181017161003 増田式プログラマー養成講座 その5 オブジェクトとは何か?
anond:20181017191404 増田式プログラマー養成講座 その6 OOPの種類、PHPの準備
anond:20181019181549 増田式プログラマー養成講座 その7 OOPの仕組み(前半)
anond:20181020230044 増田式プログラマー養成講座 その8 OOPの仕組み(後半)
anond:20181022232327 増田式プログラマー養成講座 その9 MVCフレームワークを使ってみよう
anond:20181023184616 増田式プログラマー養成講座 その10 OOPの参考書
anond:20181024214133 増田式プログラマー養成講座 その11 データベースを使ってみよう
anond:20181026145516 増田式プログラマー養成講座 その12 データベースの参考書
anond:20181028152656 増田式プログラマー養成講座 その13 SQLの文法
anond:20181031014212 増田式プログラマー養成講座 その14 Webアプリの試作品を作成
anond:20181101225335 増田式プログラマー養成講座 その15 Webアプリの完成見本
anond:20181101230220 増田式プログラマー養成講座 その16 Webアプリの完成見本(続き)
anond:20181104161900 増田式プログラマー養成講座 その17 Webアプリの骨組み
anond:20181104233013 増田式プログラマー養成講座 その18 SQLでデータの追加と取得
anond:20181110120715 増田式プログラマー養成講座 その19 SQLでデータの更新 ←★今ここ★
anond:20181110182445 増田式プログラマー養成講座 その20 SQLでデータの削除
:
それはリンゴ・スターの本名から推測したんだろうけど、Wikipediaには芸名の由来がこう書かれている。
芸名の“リンゴ・スター”とは、ロリー・ストームとハリケーンズ時代にそれぞれが芸名を考えた時につけられたもの。指輪が好きで両手にいくつも付けていたので“Rings(リングズ)”と呼ばれていて自分がリンゴ・キッドに憧れているので「リンゴ」と命名。リンゴは「Ringo Starkeyでいくつもりだったけれど、しっくりこなかったのでStarkeyを半分にしてrをもうひとつ付けた」と発言している。
このリンゴ・キッドというのは西部開拓時代の有名なカウボーイで、本名はJohn Peters Ringo。
https://ja.wikipedia.org/wiki/%E3%83%AA%E3%83%B3%E3%82%B4%E3%83%BB%E3%82%AD%E3%83%83%E3%83%89
つまりアダ名とかではなく「リンゴ」という姓があることが分かる。
「ringo family name」で調べてみると、
https://www.houseofnames.com/ringo-family-crest
この一族は、1066年のノルマン・コンクェストのときにイギリスにやってきた人々が祖先で、ヨークシャーに住んでいた。
「Ringo」という姓は、この一族が保有していた「Ringborough」と「Roos」という二つの土地の名前を組み合わせたものと推測されている。
1300年頃には「Ringerose」だとか「Ringros」といった姓で登場する。
これが省略されて「Ringo」になったのだろう。
前回は、Webアプリの骨組み(スケルトン)までを作って、製作の過程を見てみました。
今回は、データベースのCRUD操作を行なって、チャットのメッセージを追加/取得/変更/削除する機能を実装してみましょう。
Webアプリを作るときに、「Visual Studio Code」というIDE(統合開発環境)を使ってみましょう。PHP用の各種プラグイン(「PHP IntelliSense」「PHP Debug」など)を入れておけば、便利に使える。
<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>
<!DOCTYPE html>
<html>
<head>
<base href="<?php echo base_url(); ?>">
</head>
<body>
<form action="welcome/index" method="post" accept-charset="utf-8">
<label>メッセージ</label>
<input type="text" name="message">
<input type="hidden" name="action" value="add">
<button>投稿する</button>
</form>
</body>
</html>
本当はセキュリティーを考慮して、入力値の検査(バリデーション)とか、もっといろいろな仕込みが必要だが、ここでは練習なので省略します。
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Welcome extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('chat_model');
$this->output->enable_profiler(true); // for debug
}
// 初期画面
public function index()
{
$action = $this->input->post('action');
$message = $this->input->post('message');
$this->chat_model->create_message($message);
}
$this->load->view('welcome_index');
}
// 更新画面
public function update()
{
$this->load->view('chat_update');
}
// 削除画面
public function delete()
{
$this->load->view('chat_delete');
}
}
SQLを説明したかったのに(SQLとは本質的に関係がない)Webアプリの説明が延々と続いた。(説明の方法を変えた方がいいねw)
データベースにデータを保存(追加)するSQLコマンド「INSERT」を使ってみよう!
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Chat_model extends CI_Model
{
public function __construct()
{
parent::__construct();
}
// Create
public function create_message($message = '')
{
$sql = "INSERT INTO talk SET create_at = ? , message = ?";
$param = array(date('Y-m-d H:i:s'), $message);
$this->db->query($sql, $param);
return $this->db->insert_id();
}
}
以上、メッセージの追加を実現するために、MVCの各パーツを用意した。これでメッセージの追加だけができるようになった。
これだけではメッセージの取得=表示がまだできないので、次はデータベースからメッセージのデータを取得して、Webページに表示できるように改造しよう。
SQLの「SELECT」を使えば、データベースからデータを取り出せる。
メッセージのデータを取り出して、Webページの表示で使おう。
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Chat_model extends CI_Model
{
public function __construct()
{
parent::__construct();
}
// Create
public function create_message($message = '')
{
$sql = "INSERT INTO talk SET create_at = ? , message = ?";
$param = array(date('Y-m-d H:i:s'), $message);
$this->db->query($sql, $param);
return $this->db->insert_id();
}
// Read All
public function read_message()
{
$query = $this->db->query($sql);
return $query->result_array();
}
}
これでデータベースからデータを取り出すSQL、メソッドがモデルに用意できた。
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Welcome extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('chat_model');
// $this->output->enable_profiler(true); // for debug
}
// 初期画面
public function index()
{
$action = $this->input->post('action');
$message = $this->input->post('message');
$this->chat_model->create_message($message);
}
$data['talk'] = $this->chat_model->read_message();
$this->load->view('welcome_index', $data);
}
// 更新画面
public function update()
{
$this->load->view('chat_update');
}
// 削除画面
public function delete()
{
$this->load->view('chat_delete');
}
}
これは全部CodeIgniterで用意されている機能なので、マニュアルを読めば使い方が分かるようになってます。
<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>
<!DOCTYPE html>
<html>
<head>
<base href="<?php echo base_url(); ?>">
</head>
<body>
<form action="welcome/index" method="post" accept-charset="utf-8">
<label>メッセージ</label>
<input type="text" name="message">
<input type="hidden" name="action" value="add">
<button>投稿する</button>
</form>
<table border="1" cellpadding="5" cellspacing="0" bordercolor="#CCCCFF">
<tr>
</tr>
<?php foreach($talk as $item): ?>
<tr>
<td><?php echo $item['id']; ?></td>
<td><?php echo $item['create_at']; ?></td>
<td><?php echo $item['message']; ?></td>
<td><a href="welcome/update/<?php echo $item['id']; ?>">編集</a></td>
<td><a href="welcome/delete/<?php echo $item['id']; ?>">削除</a></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</table>
</body>
</html>
(説明文が300行を超えてしまった!これ以上は増田で表示できない。)次回はメッセージの変更をやってみよう。
anond:20181104161900 増田式プログラマー養成講座 その17 Webアプリの骨組み
anond:20181104233013 増田式プログラマー養成講座 その18 SQLでデータの追加と取得 ←★今ここ★
anond:20181110120715 増田式プログラマー養成講座 その19 SQLでデータの更新
:
前回は、Webアプリのモックアップ(ハリボテ)を作るところまでやりました。
データベースを使ったWebアプリを作って、データベースの基本操作(CRUDの4つ)を練習してみよう!
ざっくりと、以下のような流れで作っていきます。
(参考 anond:20181017191404 増田式プログラマー養成講座 その6 OOPの種類、PHPの準備)
講座その6を参考にして、XAMPPを起動させて、ApacheとMySQLをスタートして下さい。
(参考 anond:20181022232327 増田式プログラマー養成講座 その9 MVCフレームワークを使ってみよう)
講座その9を参考にして、XAMPPの中にCodeIgniterをインストールしておきます。
(参考 anond:20181024214133 増田式プログラマー養成講座 その11 データベースを使ってみよう)
講座その11を参考にして、MySQLにWebアプリ用のデータベースとテーブルを作成しておきます。
講座その11で、データベースの練習で「chat」というデータベースを作ってみました。
そのとき「message」というテーブルを作りましたが、今回Webアプリで使うテーブルとして新たに「talk」というテーブルを作成します。
(補足:前に作ったテーブル「message」の中に、テーブル名と同じ「message」という名前のカラム(列)を作ってました。これでも問題ないんだけど、プログラムを書くとき、テーブル名とカラム名を混同しないようにしたいので、念のため作り変えときましょう。)
SQLで「talk」というテーブルを作る場合、以下のようなSQL文になります。
CREATE TABLE `talk` (
`create_at` datetime NOT NULL,
`update_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
このSQL文をphpMyAdminで実行すれば「talk」テーブルを作れます。
これでデータベースの準備ができました。
CodeIgniterで使う「URL」の表示方法をちょっと変更しておきたいので、Apache(Webサーバーソフト)の設定を変更しておきます。
(「URL」=情報がどこにあるのかを示すインターネット上の住所)
(Apacheの「mod_rewrite」という仕組みによって、URLの扱い方を変更します。)
(例)
変更前: http://localhost/waf/index.php/welcome/
↓
変更後: http://localhost/waf/welcome/
というように、URLの中にある「/index.php」という文字列を表示させない設定にします。
Apacheの設定は「.htaccess」という名前の設定ファイルを用意して変更します。
RewriteCond %{REQUEST_FILENAME} !-f
「.htaccess」の書き方を理解するには、「正規表現」という仕組みの知識が必要です。
まだ「正規表現」を勉強してない段階では、とりあえずコピペして使って下さい。
を行ないます。
「config.php」をIDEやエディターで開いて、以下のように変更する。
最初は、
$config['index_page'] = 'index.php';
になってるけど、「index.php」を削除して、「''」(空)にしておく。
「databese.php」をIDEやエディターで開いて、以下のように変更する。
'dsn' => '',
'password' => '',
'database' => 'chat',
(※上記のように、MySQLのusernameとpasswordは「root」(管理者)のデフォルト設定を使ってます。)
上記フォルダの中に「Welcome.php」というファイルを作って、内容を以下のようにします。
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Welcome extends CI_Controller
{
{
parent::__construct();
$this->load->model('chat_model');
// $this->output->enable_profiler(true); // for debug
}
// 初期画面
{
$action = $this->input->post('action');
$message = $this->input->post('message');
$this->chat_model->create_message($message);
}
$data['talk'] = $this->chat_model->read_message();
$this->load->view('welcome_index', $data);
}
// 更新画面
public function update($id = '')
{
$id = $id ? $id : $this->input->post('id'); // id -> segment or post
$action = $this->input->post('action');
$message = $this->input->post('message');
$this->chat_model->update_message($id, $message);
}
$data['talk'] = $this->chat_model->read_message_by_id($id);
$this->load->view('chat_update', $data);
}
// 削除画面
public function delete($id = '')
{
$id = $id ? $id : $this->input->post('id');
$action = $this->input->post('action');
$this->chat_model->delete_message($id);
}
$data['talk'] = $this->chat_model->read_message_by_id($id);
$this->load->view('chat_delete', $data);
}
}
上記フォルダの中に「welcome_index.php」「chat_update.php」「chat_delete.php」という3つのファイルを作って、内容を以下のようにします。
<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>
<!DOCTYPE html>
<html>
<head>
<base href="<?php echo base_url(); ?>">
</head>
<body>
<form action="welcome/index" method="post" accept-charset="utf-8">
<label>メッセージ</label>
<input type="text" name="message">
<input type="hidden" name="action" value="add">
</form>
<table border="1" cellpadding="5" cellspacing="0" bordercolor="#CCCCFF">
<tr>
</tr>
<?php foreach($talk as $item): ?>
<tr>
<td><?php echo $item['id']; ?></td>
<td><?php echo $item['create_at']; ?></td>
<td><?php echo $item['message']; ?></td>
<td><a href="welcome/update/<?php echo $item['id']; ?>">編集</a></td>
<td><a href="welcome/delete/<?php echo $item['id']; ?>">削除</a></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</table>
</body>
</html>
<?php defined('BASEPATH') or exit('No direct script access allowed');?>
<!DOCTYPE html>
<html>
<head>
<base href="<?php echo base_url(); ?>">
</head>
<body>
<p>メッセージを変更して「更新する」ボタンを押してください。</p>
<form action="welcome/update" method="post" accept-charset="utf-8">
<label>メッセージ</label>
<input type="text" name="message" value="<?php echo $talk['message']; ?>">
<input type="hidden" name="id" value="<?php echo $talk['id']; ?>">
<input type="hidden" name="action" value="update">
<?php else: ?>
<p>※該当するメッセージがありません。</p>
<?php endif;?>
</form>
<p><a href="welcome/index">戻る</a></p>
</body>
</html>
<?php defined('BASEPATH') or exit('No direct script access allowed');?>
<!DOCTYPE html>
<html>
<head>
<base href="<?php echo base_url(); ?>">
</head>
<body>
<form action="welcome/delete" method="post" accept-charset="utf-8">
<p style="background-color:lightpink"><?php echo $talk['message']; ?></p>
<input type="hidden" name="id" value="<?php echo $talk['id']; ?>">
<input type="hidden" name="action" value="delete">
<?php else: ?>
<p>※該当するメッセージがありません。(または削除済です。)</p>
<?php endif;?>
</form>
<p><a href="welcome/index">戻る</a></p>
</body>
</html>
上記フォルダの中に「Chat_model.php」というファイルを作って、内容を以下のようにします。
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Chat_model extends CI_Model
{
{
parent::__construct();
}
// Create
public function create_message($message = '')
{
$sql = "INSERT INTO talk SET create_at = ? , message = ?";
$param = array(date('Y-m-d H:i:s'), $message);
$this->db->query($sql, $param);
return $this->db->insert_id();
}
// Read All
public function read_message()
{
$query = $this->db->query($sql);
return $query->result_array();
}
public function read_message_by_id($id = 0)
{
$sql = "SELECT * FROM talk WHERE id = ?";
$param = array($id);
$query = $this->db->query($sql, $param);
return $query->row_array();
}
// Update
public function update_message($id = 0, $message = '')
{
$sql = "UPDATE talk SET message = ? WHERE id = ?";
$param = array($message, $id);
$this->db->query($sql, $param);
return $this->db->affected_rows();
}
// Delete
public function delete_message($id = 0)
{
$sql = "DELETE FROM talk WHERE id = ?";
$param = array($id);
$this->db->query($sql, $param);
return $this->db->affected_rows();
}
}
この続きは、
「anond:20181101230220 増田式プログラマー養成講座 その16 Webアプリの完成見本(続き)」
へ続きます。
今回は、データベースを使ったWebアプリの制作を通じて、SQLの使い方を確認してみましょう。
Webブラウザー(Google Chromeなど)で動作するアプリのこと。
ウェブアプリケーション(Web application)は、インターネット(もしくはイントラネット)などのネットワークを介して使用するアプリケーションソフトウェアである。
多くの場合、これらのアプリケーションは、Webブラウザ上で動作するプログラミング言語(たとえばJavaScript)によるプログラムとWebサーバ側のプログラムが協調することによって動作し、ユーザはそれをWebブラウザ上で使用する。
Windowsパソコンを使ってたら、「XAMPP」を使ってすぐにWebアプリを試作できる。
以前の講座(その6、その9)を参考にして、XAMPPとCodeIgniterを用意しておこう。
最近のアプリの作り方は、「デザインスプリント」と呼ばれる方法が流行ってます。本やネットの情報がたくさんあるので調べてみよう。
ざっくりと、以下のような流れです。
それでは順番にやってみよう。
以前にデータベースの練習をしたとき、「後で簡単なチャット(おしゃべり)ができるWebアプリを作ってみたいと思う。」と言ったので、今回のアイデアは「チャットを作る」にしよう。
Webページを作るには、HTMLやCSSの知識が必要だ。HTMLやCSSを使ったことがなければ、本やネットの情報で勉強してみよう。
今回はCSSを使わずに、HTMLだけでシンプルなWebページを作ってみよう。(練習だから余計なもの、無駄を省きたい。)
特にこだわりがなければ、Microsoftの「Visual Studio Code」という無料のIDE(統合開発環境)を使ってみよう。
インストール方法や使い方、メニューの日本語化のやり方は、検索して調べてみよう。
「mock」フォルダの中に
テキストエディターで保存するとき、文字コードを「UTF-8」にしておく。
「index.html」ファイルをエディターやIDEで開き、以下のような内容に編集して保存します。(コピペする場合、行頭の字下げ(インデント)の全角スペースを半角スペースに置換して下さい。)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<form>
<label>メッセージ</label>
<input type="text" name="message">
<button>投稿する</button>
</form>
<table border="1" cellpadding="5" cellspacing="0" bordercolor="#CCCCFF">
<tr>
</tr>
<tr>
<td><a href="edit.html">編集</a></td>
<td><a href="delete.html">削除</a></td>
</tr>
<tr>
</tr>
<tr>
</tr>
</table>
</body>
</html>
「edit.html」ファイルをエディターやIDEで開き、以下のような内容に編集して保存します。(コピペする場合、行頭の字下げ(インデント)の全角スペースを半角スペースに置換して下さい。)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<p>メッセージを変更して「更新する」ボタンを押してください。</p>
<form>
<label>メッセージ</label>
<input type="text" name="message" value="Webアプリを作ってみる!">
<button>更新する</button>
</form>
<p><a href="index.html">戻る</a></p>
</body>
</html>
「delete.html」ファイルをエディターやIDEで開き、以下のような内容に編集して保存します。(コピペする場合、行頭の字下げ(インデント)の全角スペースを半角スペースに置換して下さい。)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<form>
<p style="background-color:lightpink">Webアプリを作ってみる!</p>
<button>削除する</button>
</form>
<p><a href="index.html">戻る</a></p>
</body>
</html>
以上でモックのWebページ(HTMLファイル)ができました。
Webブラウザーで「index.html」を開いてください。「編集」や「削除」、「戻る」をクリックして、チャットの画面を確認してください。
実務では「仕様書」という書類を大量に作る場合もありますが、時間と労力の無駄になっている場合が多々あります。(紙の仕様書はあまり使われる機会がない)
紙の仕様書(アナログ)の代わりに、モックを仕様書(デジタル)として使うと、その後の段階がスムーズになります。
どうしても紙でなければ困る場合以外は、モックをそのまま仕様書として使ってみましょう。
モック(動くハリボテ)を作るための便利なツールがいろいろあります。
ちょっと長くなったので、モックを基に機能を実装(プログラミング)するのは次回にしましょう。
anond:20181015215004 未経験からのプログラマーなんだが全然分からない
anond:20181016015826 増田式プログラマー養成講座 その1 パソコンの用意
anond:20181016164341 増田式プログラマー養成講座 その2 プログラム=データ+処理、プログラム言語の種類
anond:20181016180059 増田式プログラマー養成講座 その3 構造化プログラミングの基本(順次、反復、分岐)
anond:20181016193144 増田式プログラマー養成講座 その4 子ども向け教材「Scratch」で構造化プログラミングの練習
anond:20181017161003 増田式プログラマー養成講座 その5 オブジェクトとは何か?
anond:20181017191404 増田式プログラマー養成講座 その6 OOPの種類、PHPの準備
anond:20181019181549 増田式プログラマー養成講座 その7 OOPの仕組み(前半)
anond:20181020230044 増田式プログラマー養成講座 その8 OOPの仕組み(後半)
anond:20181022232327 増田式プログラマー養成講座 その9 MVCフレームワークを使ってみよう
anond:20181023184616 増田式プログラマー養成講座 その10 OOPの参考書
anond:20181024214133 増田式プログラマー養成講座 その11 データベースを使ってみよう
anond:20181026145516 増田式プログラマー養成講座 その12 データベースの参考書
anond:20181028152656 増田式プログラマー養成講座 その13 SQLの文法
anond:20181031014212 増田式プログラマー養成講座 その14 Webアプリの試作品を作成 ←★今ここ★
anond:20181101225335 増田式プログラマー養成講座 その15 Webアプリの完成見本
: