2010年4月22日木曜日

onCreatetって?

Activity starts
        v
    onCreate()
        v
    onStart()
        v
    onResume()
        v
Activity running
        v
    onFreeze()
        v
    onPause()
        v
    onStop()
        v
    onDestroy()
        v
Activity is shut down
::::::::::
Called when the activity is starting. This is where most initialization 
should go: calling setContentView(int) to inflate the activity's UI, 
using findViewById(int) to programmatically interact with widgets in the 
UI, calling managedQuery(ContentURI, String[], String, String[], String) 
to retrieve cursors for data being displayed, etc. 

You can call finish() from within this function, in which case onDestroy() 
will be immediately called without any of the rest of the activity 
lifecycle (onStart(), onResume(), onPause(), etc) executing. 

Derived classes must call through to the super class's implementation of 
this method. If they do not, an exception will be thrown.

Parameters:
  icicle  If the activity is being re-initialized after previous being 
    shut down then this Bundle contains the data it most recently 
    supplied in onFreeze(). Note: Otherwise it is null.
 

豊富な学校情報で

あなたのなりたいに

応えます☆

なるにはサイト

Android ボタン表示アプリ

package jp.allabout.android;

import android.app.Activity;
import android.os.Bundle;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.view.ViewGroup.LayoutParams;

public class MyAndy extends Activity
{
    /** Called with the activity is first created. */
    @Override
    public void onCreate(Bundle icicle)
    {
        super.onCreate(icicle);

        Button button = new Button(this);
        button.setText("Button");
        setContentView(button, new LayoutParams(LayoutParams.WRAP_CONTENT,
          LayoutParams.WRAP_CONTENT));
    }
}


Java superって?

http://www.javaroad.jp/java_class11.htmらしいよ

2010年3月28日日曜日

http://php.hushlog.com/130/

http://php.hushlog.com/130/

formのチェック項目

27         /*
28         'sample' => array(
29             'name'          => 'サンプル',      // 表示名
30             'required'      => true,            // 必須オプション(true/false)
31             'min'           => null,            // 最小値
32             'max'           => null,            // 最大値
33             'regexp'        => null,            // 文字種指定(正規表現)
34             'custom'        => null,            // メソッドによるチェック
35             'filter'        => null,            // 入力値変換フィルタオプション
36             'form_type'     => FORM_TYPE_TEXT   // フォーム型
37             'type'          => VAR_TYPE_INT,    // 入力値型
38         ),
39         */


var $form = array(      
'mailaddress' => array(
          'name'          => 'メールアドレス',
          'required'      => true,
          'type'          => VAR_TYPE_STRING,
      ),
 ~省略~

$form = $this->action_form->get('mailaddress');//ここでformに
渡す事が味噌です

if($form){
$this->af->setApp($form);
return 'login';
}
~login。tpl~
<p>{$app.foo}</p>で表示されます
~login。tpl~
$this->action_form->get('mailaddress');で'mailaddress' => array(を取得できます。
配列変数は取得できまん

if ($this->af->validate() > 0) {

      if ($this->af->validate() > 0) {
では$formの入力値が無かったり、チェック項目に当てはまらなかったら条件分が実効されます


$from チェック

fromの文字列指定
$form = array(
'name' =>array(
  'regexp' => '/^[a-zA-Z]+$/',   //文字の英字
  ),
);

$form = array(
'name' =>array(

  'regexp' => '/^[ぁ-んー]+$/',   //あ~んの文字列
  ),
);
Smarty関数のmessage関数を使いエラーメッセージを表示
<input type="text" name="mailadd" value="$form.mailadd">
{message name="mailadd"}

2010年3月19日金曜日

ようするに、prepare()メソッドでフォーム値の検証を行うこと、perform()メソッドでは全てのデータはサニタイズされているという 前提で処理を行うことが出来る、安全且つ簡潔なコードが書けるというわけです(やっぱりStrutsの真似)。
なお、フォーム値の自動検証詳細については以下をご覧下さい。

2010年3月18日木曜日

Controllerにアクション定義を追加します。具体的には、
app/Sample_Controller.phpを以下のように編集します。 
/**
  *  @var    array   forward定義
  */
 var $forward = array(
      /*
       *  TODO: ここにforward先を記述してください
       *
       *  記述例:
       *
       *  'index'         => array(
       *      'view_name' => 'Sample_View_Index',
       *  ),
       */
+    'login' => array(
+        'view_name' => 'Sample_View_Login',
+        'forward_path' => 'login.tpl'
    ),
 );
***********************
ですので、ここでは'login'というアクションに対応するファイル
を作成するので、app/action/Login.phpというファイルを以下の
ように作成すればよいことになります。
Ethna_ActionClassを継承した
perform() にメソッドの戻り値として遷移先の名前(後述)を返します 
 
<?php
class Sample_Action_Login extends Ethna_ActionClass
{
    function perform()
    {
        return 'login';
    }
}
?> 
************************
ですので、ここでは'login'という遷移名に対応するファイル
を作成するので、app/view/Login.phpというファイルを以下のように作
成します。 
<?php
class Sample_View_Login extends Ethna_ViewClass
{
    function preforward()
    {
        $this->af->setApp('now', strftime('%Y/%m/%d'));
    }
}
?> 
**********************
次に、テンプレートファイルを作成します。テンプレート
ディレクトリはtemplate/jaディレクトリで、(6)で'login.tpl'をテンプ
レートファイルに指定しているので、template/ja/login.tplを作成します。 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head></head>
<body>
Login View<br />
current time: {$app.now}
</body>
</html> 
******************
http://some.host/~foo/?action_login=trueにアクセスすると
 



2010年3月11日木曜日

MYSQL 記事を取ってくる

$qstring = "selectd.topicid,DATE_FORMAT( d.dt,'%Y/%m/%d') as postdatef,DATE_FORMAT( d.dt,'%H:%i') as posttimef,d.lastupdate,d.fdelete," .
 "d.catid,b.category,d.title,d.body,d.image_g,YEAR(d.dt) as yyyy,MONTH(d.dt) as mm " .
 " from b_webdiary d left join b_categories b " .
 " on d.catid = b.catid order by d.dt desc



******************************************************
b_webdiary
topicid  lastupdate      dt           fdelete catid title body
1      2010-03-11 18:06:28 2010-03-11 18:06:28 0     1    ddd ddddd
b_categories

catid category
 1    General
2   友人
*****************************************************








2010年3月10日水曜日

一人のお買い上げ金額

一人のお買い上げ金額
SELECT person, sum(num) from ec_master
group by person

2010年3月9日火曜日

標準偏差とは

http://www.hinkai.com/qc/hensa.htmlに分かりやすくあります。
合計の平均を出し、
(点数)ー(平均)二乗=和
(点数)ー(平均)二乗=和
(点数)ー(平均)二乗=和
(点数)ー(平均)二乗=和
(点数)ー(平均)二乗=和
ーーーーーーーーーーーーー
合計

ルート(合計÷5)= 平方根=標準偏差

*商品の品質管理の時などに使います。

MYSQL 合計を求める

SELECT Subject, StudentID, SUM( TestScore )
FROM tbl_Test
GROUP BY Subject


********************************* 
SELECT カラム名,カラム名,SUM(カラム名)//合計を求めるカラム名
FROM テーブル名
GROUP BY カラム名//合計をまとめるカラム名

Mysql AVGで平均を求める

SELECT stor, nam, AVG( pric )
FROM ec_product
GROUP BY stor;


*********************** 
SELECT カラム名 ,カラム名, AVG(カラム名 )//平均を出すカラム
FROM ec_product テーブル名
GROUP BY stor; 平均を求めるグループ

Mysql 抽出条件を設定

SELECT PREF_CD,PREF_NAME,T01Prefecture.AREA_CD,AREA_NAME
FROM T01Prefecture, T00Area
WHERE T01Prefecture.AREA_CD = T00Area.AREA_CD
AND PREF_CD BETWEEN 1 AND 7;

********************************************

SELECT カラム名,カラム名,テーブル名①.カラム名,カラム名
FROM テーブル名①, テーブル名②
WHERE テーブル名①.カラム名 = テーブル名②.カラム名
AND カラム名 BETWEEN 1 AND 7;

解説 ①②のテーブルを結合し、ANDの後のカラム名の1~7に当てはまるレコードだけを抽出

テーブルの結合表示

SELECT topicid,title,b_webdiary.catid,category
FROM b_webdiary INNER JOIN b_categories
ON b_webdiary.catid = b_categories.catid;

**********************************
SELECT カラム名,カラム名,テーブル名.カラム名,カラム名
FROM テーブル名 INNER JOIN テーブル名
ON テーブル名.カラム名 = テーブル名.カラム名;



2010年3月7日日曜日

imgタグ 置き換え 正規表現

<?php
$text_x = "あああああ<img src="yyyjjj.jpg">いいいいい";

$rcd = mbereg_replace("<img src=\".+?\">", "", $text_x);

print_r($rcd."●");
?>

対象の文字列に”’などのクオートがある場合は¥で文字列とする

2010年3月5日金曜日

画像test

<?php
$str = 'てすと<img src="test.jpg">テスト';

$test = strip_tags($str);

print_r($test."<br>");


$content = 'てすと <img src="7-pictures-of-pretty-elene-gedevanishvili04.jpg"> テスト';

$pattern = "/\<img ([^\>]+)\>/i";
//$pattern = "/<img.*?\/>/";

preg_match_all($pattern, $content, $images);
foreach($images as $data){
    foreach($data as $data2){
        print_r($data2."★<br>");
    }
print_r($data."●<br>");
}
print_r(count($images)."<br>");

?>

smarty文字数制限

{$topics[tloop].bodyf|truncate:31}