主要是因為之前用Yii 的 Widget 用的挺開心的( 除了他會每次都進一次Cycle 外) 因為用ZF沒找到有這方面相關的資訊 所以自已動手刻….. 1. 在application 下建 Titan/Base 的資料夾 ( Titan 是我想把自已寫的東西盡可能的都收在這 ) 2. vim Titan/Base/Widget.php [sourcecode language='php'] < ?php abstract class Titan_Base_Widget { protected $_basePath; protected $_viewBasePath; protected $_viewScriptPath; public function __construct( $array = null ) { //assign variables $this->_basePath = APPLICATION_PATH . DS . ‘widgets’; $this->_viewBasePath = APPLICATION_PATH . [...]
剛剛用Yii 的AR 寫的很開心, 下了這個 [sourcecode language='php'] $criteria=new CDbCriteria; $criteria->condition=’products.id=:ID AND products_info.language_id=:languageID’; $criteria->params=array(‘:ID’=>$_GET['id'], ‘:languageID’ => $this->_lang_id ); $criteria->order = ‘products_content.content_orders ASC’; $model = Products::model()->with( ‘products_info’, ‘products_content’ )->find( $criteria ); [/sourcecode] 一直出現 CDbCommand 無法執行 SQL 陳述: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘products.id’ in ‘where clause’ 想說怪了… 再看了一下 sql log [sourcecode language='text'] 543 Query SELECT `t`.`id` [...]
controller 部份 [sourcecode language='php'] $sort->attributes= array( ‘product.id’=>’productId’, ‘product.name’=>’productName’, ‘category.name’=>’categoryName’, ‘brand.name’ => ‘brandName’, ); /* $sort->attributes= array( ‘model中的alias.欄位’=>’網址顯示的Alias’, ); */ [/sourcecode] view 部份 [sourcecode language='php'] < ?php echo $sort->link(‘product.id’,’編號’); ?> //< ?php echo $sort->link(‘table.name’,’網頁顯示的名稱’); ?> [/sourcecode] model 部份 記得把 relations中的 alias 設好 如下 [sourcecode language='php'] /** * @return array relational rules. */ public function relations() { [...]
system() The system() call also tries to automatically flush the web server’s output buffer after each line of output if PHP is running as a server module. exec() 則不會flush 遇到的問題是 我的php 透過perl 去執行一些功能 然後perl 回傳 success or false 字串 在standard output 上 php再去get 這個字串 success 則print success 給 ajax 來判斷 結果 在前端的ajax 一直印出 successsuccess 的字眼 [...]
[sourcecode language='js'] var myEditor = new YAHOO.widget.Editor(‘editor’, config); myEditor.on(‘editorContentLoaded’, function() { myEditor.setEditorHTML(‘This is my new content’); }); myEditor.render(); [/sourcecode] 要 listening editorContentLoaded event 才行 沒在editorContentLoaded 裡下…………. myEditor.setEditorHTML(‘This is my new content’); 沒作用………
在<body> 這個tag 似乎一定要設 class=’yui-skin-sam’ 不然會有一些小問題 我之前是設在<div class=’yui-skin-sam’><textarea></textarea></div> 這樣來解 ..不過… 用了一陣子才發現….class=’yui-skin-sam’不是設在body 的話…. add link 的這個func 會破版…………..css 會整個走掉…. 本來是沒有很想加 class 在body 的.. 不過突然想到….drupal 的 plugin 中也有yui rte 我就去看了一下他是怎麼解的.. [sourcecode language='js'] if (Drupal.jsEnabled) { $(document).ready(function() { $(‘body’).addClass(‘yui-skin-sam’); } ); }; [/sourcecode] 然後看了一下skin裡面的css 應該是不至於加了這個class 造成新版的走位,所以就照著幹了…
因為有打算用YUI RTE 來做default 的editor 不過因為有想要在textarea 裡面加入content 的須求 用document.post_form.post_text.value 會沒辦法在”所見即所得模式”下有反應 只能在原始碼模式下有作用 翻了一下文件 要用cmd_inserthtml來做 如下 [sourcecode language='js'] myEditor = YAHOO.widget.EditorInfo.getEditorById(‘post_text’); myEditor.execCommand(‘inserthtml’, document.post_form.post_text.value); [/sourcecode] 這樣應該就搞定了…
這個問題在在Zend Framework 中 Zend/Db/Statement.php 裡面 [cc lang="php" tab_size="2" lines="40"] protected function _stripQuoted($sql) { // get the character for delimited id quotes, // this is usually ” but in MySQL is ` $d = $this->_adapter->quoteIdentifier(‘a’); $d = $d[0]; // get the value used as an escaped delimited id quote, // e.g. \” or “” or \` [...]
網路上找來找去…… 沒看到有人寫相關的解法…. 加上不想用mysql-proxy來解這部份… 所以打算從code 的部份下手 看到最後只能動Zend Framework 的code 了(還沒想到可以不動ZF 的code 而做到DB LB的方法) 我是先從function save 下手去找.. Zend/Table/Row/Abstract.php: public function save() [sourcecode language='php'] public function save() { /** * If the _cleanData array is empty, * this is an INSERT of a new row. * Otherwise it is an UPDATE. */ if (empty($this->_cleanData)) { return $this->_doInsert(); } [...]