#BEFORE
1 | window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || |
#NOW
1 | window.URL = window.URL || window.webkitURL; |
#SO
Just New Blob()…no more BlobBuilder()
#BEFORE
1 | window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || |
#NOW
1 | window.URL = window.URL || window.webkitURL; |
#SO
Just New Blob()…no more BlobBuilder()
two ways to use it
#1 use blade on controller
in controller, you need to assign a template for controller.
1 | protected $layout = 'layouts.master'; |
and then in each function action. assign whatever need to assign for show content on template. like in blade template. I have a content section. Therefore, i need to set a value or view to 「Content」
1 | $this->layout->content = something or View::make('something'); |
in blade template. there are 2 ways to define var.
@yield(『something』)
if use first method; then in view, it needs to create a section something. ex
1 | @section('content') |
for method 2. no need to create a section to contain page content.
From the VFP9 helpfile:
Specifies the amount of memory (address space) in pages that Visual FoxPro allocates at startup or a Visual FoxPro MTDLL COM Server allocates per thread for the internal program cache (memory used to run programs). Each page of memory is equal to 64K so the default setting equates to an allocation a little over 9MB. As the cache is filled, Visual FoxPro will try to flush it to remove unused items. It is possible that Visual FoxPro cannot free enough memory in which case an Error 1202 is generated (Program is too large). Adjusting the PROGCACHE setting can prevent this error from occurring.
Note: While this setting can be used for the Visual FoxPro development product or normal runtime applications, it is primarily intended for MTDLL COM Servers where many threads are often created for a single server. In Visual FoxPro 9.0, the default value for MTDLL COM Servers is -2.
When the value of nMemoryPages is greater than 0, Visual FoxPro allocates a fixed program cache. You can specify between 1 and 65000.
If you specify 0 for nMemoryPages, no program cache is used. Instead, Visual FoxPro uses dynamic memory allocation based on determinations made by the operating system.
If you pass a value for nMemoryPages that is less than 0, Visual FoxPro uses dynamic memory allocation but is limited to the specified memory (nMemoryPages * 64K). When the limit is reach, Visual FoxPro will flush allocated programs to free memory.
You can call SYS(3065) to determine the current PROGCACHE setting. CLEAR PROGRAM will attempt to clear unreferenced code regardless of this setting.
Note: The Visual FoxPro OLE DB Provider ignores this setting since it uses dynamic memory allocation (PROGCACHE=0).
Default: 144 (-2 for MTDLL)
「The setting is the number of pages of memory you want allocated. Each page is equivalent to 64K of memory. You can set the PROGCACHE from 1 to 65,000 (positive or negative) to designate how much memory is allocated. If you specify zero, no program cache is used and VFP uses dynamic memory allocation determined by the operating system. If you set the PROGCACHE to a negative number, VFP uses dynamic memory allocation, but is limited to the number of memory pages you specified. The default setting is 144 (over 9 megabytes) for single-threaded EXEs and the VFP IDE, and -2 (128 kilobytes) for a multi-threaded DLL. The VFP OLE DB Provider does not use this setting because it uses dynamic memory allocation.」
Controllers是用來處理商業邏輯及資料與view之間的介面(負責將資料input//output 給model,與資料庫的溝通就交給model去處理了)
controller需要配合route的設定才可被view呼叫使用。
例如: route::get(『something』,『someController@someaction』)
當使用者跑到 http://website/something時, 就會呼叫route內所對應的controller及action.
發現,這種指定的方式,當頁面很多的時候就會變得很麻煩。 所以laravel的route提供另外一種指定的方式
route::controller(『something』,『someController』)
此種設定的方式,適用於restFUL的controller, (get,post,put,delete)四種交換模式的相關動作。
一般而言,只是讀取一個頁面的時候,都是透過 get的method取得回應的。所以在controller內action的命名, 就是用getSomection()為命名的方式,網址就是http://website/something/someaction (小寫, Controller內的action name 是大寫). 如果action的名稱是SomeAction時,注意 是兩個大寫字母 網址就會變成 http://website/something/some-action (破折號作為連結的符號)
同理: 如果遇到form post時, 就是呼叫postSomeaction()
以上為controller的基本呼叫方式。
#database config path
/app/config/database.php
#star up path
serverName/laravel/public
#php artisan migrate 這裡migrate的觀念與EntityFramework 5 Code First的觀念相同。
安裝Migration table, 會在資料庫中創建一個migrateion table, 紀錄migration版本
建立新版的資料庫異動檔案
執行資料庫格式升級 --> function up()
執行資料庫格式降級 --> function down()
1 | function up(){ |
1 | function down(){ |
1 | $di->set('router', function () { |
Placeholder | Regular Expression | Usage |
---|---|---|
/:module | /([a-zA-Z0-9_-]+) | Matches a valid module name with alpha-numeric characters only |
/:controller | /([a-zA-Z0-9_-]+) | Matches a valid controller name with alpha-numeric characters only |
/:action | /([a-zA-Z0-9_]+) | Matches a valid action name with alpha-numeric characters only |
/:params | (/.) | Matches a list of optional words separated by slashes. Use only this placeholder at the end of a route |
/:namespace | /([a-zA-Z0-9_-]+) | Matches a single level namespace name |
/:int | /([0-9]+) | Matches an integer parameter |
/:params : 只能放在router的最後面
#controller內取得route裡面參數的方式
1 | $this->dispatcher->getParam(0); |
#如果是/?var=value
就用原本$_GET[『』]的方式取值就可以了
1 | git add . |
1 | git checkout master |
git pull origin master
1 | 檢查是否有conflict要修 |
git push origin master:[module name]
1 |
|
git add remote kyo /home/kyo/web/mc2
1 |
|
git pull remote kyo master
1 |
|
git fetch remote kyo master:kyo
1 |
|
git config --global user.name 「Your Name」
git config --global user.email [email protected]
###設定git環境
cd ~ #進入個人home目錄
ex./home/fish
vi .gitconfig
####編輯git環境檔,貼上以下環境設定變數
[color]
branch = auto
diff = auto
status = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
[color "status"]
added = green
changed = red
In Phalcon Model system. 是根據ORM的架構,讓資料表物件化,讓在資料讀取或是寫入的動作上,可以利用物件的特性去操作。
1 | /** |
上列的動作會開啟與資料庫中間的連線關係,$config會去讀取所指定的設定文件
Model文件預設的命名方式為table名稱,例如:
1 | class Rebots extends \Phalcon\Mvc\Model |
官方文件建議,要在Model文件中描述資料表的欄位,以減少使用伺服器的記憶體資源。
如果Model的名稱與資料庫資料表名稱不同時,可以透過以下的方式重新設定所關聯的資料表名稱
1 | public function initialize() |
ModelName::find(condition)
1 |
|
$result = ModelName::find(『id=1』); $result->fieldName = 「something something」; $result->save(); <=將資料回傳至資料庫中
1 |
|
$result = new ModelName(); $result->fieldName = 「something something」; $result->save();
1 |
|
$result = ModelName::find(condition);
if ($result != false) {
// 執行刪除
if ($result->delete() == false) {
echo 「Delete Failed」;
foreach ($result->getMessages() as $message) {
echo $message, 「\n」;
}
} else {
echo 「Deleted successfully!」;
}
}
#Hierarchical Rendering Phalcon當在使用View的時候,執行的順序是
依造這種順序,
在index.volt裡面的{{content()}},就會去呼叫app/views/layouts裡面的內容, 然後再app/views/layouts裡面的{{content()}}就是呼叫app/views/{{controllerName}}/xxx.volt的內容在Controller裡面所設定的變數,則上述三種xxx.volt都可以用
[1]: 如果要指定template時, 可以用下列的方式設定, 這樣子就會去讀取app/views/layouts/common.volt的內容了,
1 | public function initialize() |
#Using Partials
如果想要在view中間插入partials的方式很簡單
如果是使用volt語法的:
1 | {{ partial(view path) }} |
一般的語法
1 | <?php $this->partial(view path) ?> |