This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$pdo = new PDO('cubrid:dbname=demodb;host=localhost;port=33000', 'dba', ''); | |
$test = 'mystring'; | |
echo $pdo->quote($test) . "\n"; | |
$test = "my'string"; | |
echo $pdo->quote($test) . "\n"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php class A {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Example extends CActiveRecord | |
{ | |
// ... | |
public function rules() | |
{ | |
return array( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$a = new StdClass(); | |
$a->prop = 2; | |
$a->str = "hallo"; | |
$a->arr = array(1,2,3); | |
echo json_encode($a); // {"prop":2,"str":"hallo","arr":[1,2,3]} | |
echo json_encode((array)$a); // {"prop":2,"str":"hallo","arr":[1,2,3]} | |
echo json_encode(array(1,2,3)); // [1,2,3] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// loads an array of MyModel instances | |
$records = MyModel::model()->findAll(); | |
foreach($records as $record) { | |
// $record represents one row in the database | |
print_r($record->attributes); // attributes are the columns/values | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return array( | |
/* ... */ | |
'components' => array( | |
/* ... */ | |
'urlManager' => array( | |
'enablePrettyUrl' => true, | |
'rules' => require(__DIR__ . '/routes.php'), | |
), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @todo: add documentation! | |
* | |
* @property string|array $returnUrl | |
*/ | |
abstract class BaseRESTAction extends CAction | |
{ | |
const HTML = 'html'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Controller extends CController | |
{ | |
public function beforeAction($action) | |
{ | |
// register handler for the event | |
$this->attachEventHandler('onUserRegister', array(Yii::app()->myComponent, 'sendEMail')); | |
return parent::beforeAction($action); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// assuming we have a User model that has a relation to Profile model named 'profile' | |
/** @var User $user The user model */ | |
$this->widget('zii.widgets.grid.CGridView', array( | |
'id'=>'user-grid', | |
'dataProvider'=>$user->search(), | |
'filter'=>$user, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Allows to filter attributes before validation: trim,escape,re-format etc... | |
* | |
* List of implemented filters: | |
* - trim | |
* | |
* How to use: | |
* |