ㄚ凱隨手紀 | 我就是在碎碎念~

Archive for 九月 2006

九月/06

13

CakePHP 的 HasMany 自動存檔…

剛剛跟 thegiive 聊天的時候,他問了我一個CakePHP的問題。

CakePHP 的 model 能自動 save hasMany 的 entry 嗎?

經過測試後發現似乎沒有辦法。

不過還是可以經由修改 model  做到類似的功能。

在所建立的 model 中加入一個 function , afterSave ,afterSave 是 Model 的 CallBack Function …

在save後會自動被呼叫。

寫入類似下列的 內容,假設我是 hasmany 一個 Post 的 model …

    function afterSave(){
        if ($user_id = $this->getLastInsertID()){
            foreach ($this->data['Post'] as $val){
                $this->Post->create();
                $data['Post'] = $val;
                $data['Post']['user_id'] = $user_id;
                $this->Post->save($data);
                unset($data);
            }
        }
    }

這樣子在存檔的時候,只要輸入的資料是類似這樣…

date => Array(    [User] => Array        (            [name] => Darkhero            [email] => darkhero@gmail.com        )

    [Post] => Array        (            [0] => Array                (                    [title] => test1                    [content] => content1                )

            [1] => Array                (                    [title] => test2                    [content] => content2                )

            [2] => Array                (                    [title] => test3                    [content] => content3                )        ))
--
去 cakephp 的 irc 問了才知道有 model::create 初始化一個物件,所以重新改一下程式碼... 

[@more@]

No tags

美女要是還撒嬌的話 ,大概沒幾個男生能受得了吧….

http://blog.yam.com/h9856/archives/2132781.html

[@more@]

No tags

九月/06

13

require_recursion

在TWPUG中有朋友問可以不可以require 一整個目錄。

但是PHP的 require 本身沒有這個功能,所以只好自己寫一個…

還沒有試過,但是應該是可以run的啦~

<?php

/**
* Recursion require file.
* If $target is directory then include all file in the directory.
*
* @param string $target
*/
function require_recursion($target){
    if(is_dir($target)){
        $d = dir($target);
        while (false !== ($entry = $d->read())) {
            if ($entry != '.' and $entry != '..') {
                if (is_dir($entry)) {
                    require_recursion($entry);
                }else{
                    require($entry);
                }
            }
        }
    }
}

?> 

[@more@]

No tags

九月/06

12

在 CakePHP 中用 Smarty!!

等了好久,終於有比較好的解決方案了!

http://projects.simpleteq.com/CakePHP/smarty.html

直接把 Smarty  繼承 View 作成了 SmartyView,也可以在 tpl 中直接用 {$html->url()}…

 

[@more@]

No tags

九月/06

8

CakePHP 的簡易使用者認證

剛剛在逛網站的時候看到的。

CakePHP 範例: 簡易使用者認證
http://987.tw/home/p2_articleid/18

很棒的一篇翻譯文章,清楚明白,若是想找簡單的使用者認證功能,可以參考這篇喔!~ 

[@more@]

No tags

九月/06

8

TinyMce for CakePHP

之前我在 CakePHP 中用的都是 FCKeditor ,最近則越看TinyMCE越順眼,所以找了一下有沒有 TinyMCE for TinyMCE 的文章…

http://cakephp.org/pastes/show/cf924a342aa55ba3cfe3aea6cb1ed29b 

實作方式如下:

  1. 先將 TinyMCE 下載後解開.
  2. 將 TinyMce中 jscript 目錄下的 tiny_mce 完整的考貝到 WEBROOT/js/ 下.
  3. 在你的layout中,修改 default.thtml (如果你有用其他的也跟著修改吧~) ,在 <head></head> 中間加入
    <?php
    if
    (isset($javascript)):
            echo $javascript->link('tiny_mce/tiny_mce.js');
    endif
    ;
    ?>
  4. 最後在你的有需要用到 tinymce的網頁,例如 add.thtml 跟 edit.thtml  加入下列javascript
    <?php
    <script language
    ="javascript" type="text/javascript">
    tinyMCE.init({
        theme : "advanced",
        mode : "textareas"
    }
    );
    </script>

    ?>
  5. 看看你的新增修改頁面是否已經自動把tinymce啟動了呢~

[@more@]

No tags

九月/06

4

哇! Gnome Boy ?!!?

今天女朋友傳給我一張照片,很有趣,我覺得好像是 Gnome Boy 阿!!

轉寄的email原文:

> 在兆豐農場看到一個弟弟,他ㄉ頭超酷的…
>
聽說是他爸剃ㄉ!哈哈哈…

很有趣的小朋友,不知道他爸爸剪完是不是很開心~這是背面~

[@more@]

No tags

九月/06

1

CakePHP 與 MySQL 4.1(以上到5.0)

這幾周很忙,加上這兩天身體很不舒服,整天都是頭暈眼睛痛的狀態,根本無法做事情,所以寫點簡單的東西好了。

MySQL 4.1 以上由於有字元編碼設定的問題,所以所有的PHP程式都需要跑一下 set names xxx …(關於編碼的問題請看MySQL 中文編碼徹底研究

而CakePHP的編碼設定要放在哪呢?

根據網路一陣搜索,找到的比較好的方法是利用自建的 app_model.php 來完成.

[@more@]

在你的app目錄下,加上一個檔案,app_model.php(也可以從/cake/拷貝過來)

裡面應該有個空的物件

class AppModel extends Model
{}

這個檔案是用來讓自己建立額外的AppModel function 用的…

我們要加上自動送出 set names utf8 的話要這樣作…

class AppModel extends Model{
function __construct(){
parent::__construct();
$this->execute(‘set names utf8′);
}
}

當然,如果你用的是 big5 ,就要改用 set names big5 喔..~

No tags

Phentermine from canada
Get viagra drug online
Cheap cialis without prescription
Valium addiction signs
Cialis applied directly
Cialis injury attorney ohio
Ativan vs xanax
Cialis dosage information
Buy viagra canada
Online uk viagra sales
Viagra uit india
Xanax detox
Adipex 37.5 mg prices
Pfizer viagra 50 mg
Xanax pain relief
Phentermine side effects dangers
Does generic viagra work
Cialis 100mg
Uk online pharmacy no prescription
Cialis malaysia
Cialis brand
Free shipping viagra
Viagra liver damage
Free viagra without a perscription
Doxycycline hyclate
Accutane attorneys san diego
Female viagra pill
Generic cheap viagra
Carisoprodol phentermine yellow
Adipex for sale
Allergy to cialis
Cost levitra
Viagra to buy online
Generic viagra 100mg soft pills
Viagra england
Viagra pill for woman
Order levitra online no prescription
Online pharmacy propecia
Cheap cialis pills
Dissolve doxycycline hyclate for mouth
Cheap pill viagra
Buy viagra online uk
Doxycycline 100 mg
Celexa withdrawal
Adipex versus phentermine
Sales online viagra sale
Buy cialis online no prescription
Generic propecia effective
Viagra prices walmart
Xanax and caffeine
Tramadol saturday delivery cod
Cheap propecia order online
Buy cost low viagra
Cheap viagra generic
Generic pharmacy viagra
Chip cialis
How viagra works
Uk viagra
Soft viagra
Viagra drugs
Buy viagra china
Cialis without prescription overnight
Lowest prices on tramadol
How to get off xanax
Cialis ireland
Best prices on viagra
Cheap xanax
Cialis viagra
Cialis no perscription non generic
Ativan recommended dosage
Best medicine online viagra
Drug stores that sell xanax
Viagra lowest prices
Buy soma online
Cialis headaches
Viagra prices
Buy phentermine online
Levitra for sale online
Valium most common prescribed drugs
Buy propecia online
Generic propecia viagra
Levitra overnight
Free viagra in the uk
Buy 50 mg viagra
Truly free samples viagra
Cialis on sale
Cialis info
Is moon face with prednisone preventable
Valium and geriatric dogs
Order valium online
Viagra recommended stores in sweden
How to buy cialis
El cialis generico
Cialisis in canada
Levitra and dosage
Cheap generic india viagralevitra 20mg
Didrex adipex online
Cialis from india
Lyme disease doxycycline
Generic cialis pill
Viagra sale buy
Buy levitra low price
Viagra buy online in stock
Should i chew cialis
Canadian pharmacy soma
Adipex and weight loss
How much ativan is too much
Free trial cialis
Viagra injectable
Uk online pharmacies for viagra etc
Adipex side effects
Buy viagra overnight
Doctors prescribe phentermine
100mg tramadol
Generic viagra india
Side effects of doxycycline
Non prescription cialis
Cheap price viagra
Clomid success rates
Free online prescriptions
Cheap valium no prescription
Pharmacy phentermine
Prednisone titration
De levitra
Xanax addictive
Viagra danger
Uk propecia sales
Viagra cialis
Phentermine shipped to arkansas
Viagra info
Buy cheap viagra in uk
Phentermine 15mg
Cialis murah klang
Cialis costs
Canadian cialis pharmacy
No perscription viagra
Online levitra us
Results of accutane treatment
Phentermine with no prescription
Buy pfizer viagra
Cialis overnight
Canadian generic viagra
Cialis quick shipment
Cialis softabs
Prescription phentermine
Canada viagra
Buy cheap phentermine
Phentermine 37.5 without prescription
Cheapest prescription viagra
Xanax 10mg

Theme Design by devolux.nh2.me