-
Notifications
You must be signed in to change notification settings - Fork 4
Home
Jacky Jiang edited this page Jul 31, 2014
·
1 revision
Welcome to the ActiveFrame wiki!
This is a simple document covers all basics you need to know to get started.
The name of the controller class must start with 'C_'.
$s=new CSearcher($table);//--Create object of the CSeacher class. $table is a string of the name of the table which you want to search on.
$s['name']='tom'; //-- search records which 'name' data field is equal to 'tom';
$s->setFetchDataSet('id, name'); // fetch only these fields
$records=$s->fetchResult();//--fetch all records matching the conditions
$records=$s->fetchPlainArray(); //--fetch all records matching the conditions as a plain array such as mysql_fetch_assoc returns
$records[0]['name']='Jim'; //--change the 'name' data field of the first record to 'Jim'
unset($records); //--- Optional step. changes will be sent to database when object is about to be removed from memory or end of the program
$s=new CSearcher($table);//--Create object of the CSeacher class.
$s['name']='tom'; //-- search records which 'name' data field is equal to 'tom';
$records=$s->fetchResult();//--fetch all records matching the conditions
$records[0]->delete(); // delete the first record of these
unset($records); //-- changes will be sent to database when object is about to be removed from memory
2.1.4 Create Record
$record=new CActiveRecord($table); //---$table is a string of the name of the table which you want to create record on.
$record['name']='Jim'; //--set the 'name' data field of the new record to 'Jim'
unset($record); //-- record will be created when object is about to be removed from memory
OR
$record->insert_id(); // record will be automatically committed to database when try to get the ID of inserted row
global $APP_ENV;
$db=$APP_ENV['db'];
$records=$db->fetchResultBySQL($sql); //---$sql is the sql statement you want to execute. UPDATE, INSERT ... will return an empty array
{template PATH_TO_SUB_TEMPLATE} //--PATH_TO_SUB_TEMPLATE is the a path to the sub template file
$a //--- output variable $a
<!--{loop $records $record_id $record_value}-->
HTML content
<!--{/loop}-->
This produces a similar outcome to php code:
foreach($array as $key=>$value)
or simpler
<!--{loop $records $record}-->
HTML content
<!--{/loop}-->
{lang xxx}
suppose
$v=’xxx’;
{lang $v}
This is equal to
{lang xxx}
<!--{loadFormatter xxxx}-->