2015-06-30 15 views
0

我需要存儲特殊chanraters在我的模型保存, 我$model->attributes就像下面要存儲特殊字符,例如撇號等。在警予模型 - >保存()

Array 
(
    [name] => Indian Identity 
    [description] => Description from 'Ranjit Hoskote’s The Complicit Observer provides an art-historical account of Sudhir Patwardhan’s career, which spans over three decades and ranges across painting, drawing, township. 
    [clsfication] => this is classification 
    ) 

如何存儲的特殊model->save()

+0

試試這個http://stackoverflow.com/questions/23248473/how-to-allow-apostrophe-and-space-for驗證 – yetanotherse

+1

您應該編輯問題併發布您的真實代碼以及您面臨的特定問題。 –

回答

0
Array 
(
    [name] => Indian Identity 
    [description] => Description from 'Ranjit Hoskote\'s The Complicit Observer provides an art-historical account of Sudhir Patwardhan\'s career, which spans over three decades and ranges across painting, drawing, township.' 
    [clsfication] => this is classification 
    ) 

試試這個。並讓我知道它是否工作。

+0

描述是動態的,從客戶端 –

2

您可以使用PHP的本地函數addslashes

代碼:

$model->setAttributes([ 
    'name' => addslashes('name'), 
    'description' => addslashes('description'), 
    'clsfication' => addslashes('clsfication'), 
]); 
$model->save(); 
+0

得到有動態添加'addslashes'到表單中的所有字段 –