myswap / 1 / code / App / Lib / Action / TestAction.class.php

<?php
Class TestAction extends Action{
	protected $fields = array(
	"swap_id", 
	"user_id", 
	"alias", 
	"content", 
	"_pk"=>"swap_id",
	"_autoinc"=>true
	); 
    public function index()
    {
    	$data=array(
		"alias" => "aaa",
		"swap_id" => "aasssa",
		"content" => "asadasdaa",
		"user_id" => "asadasdaa"
		);
		echo dump($data);
		echo in_array("ss",$this->fields,true);
	    foreach ($data as $key=>$val){
	        if(!in_array($key,$this->fields,true)){
	        	// echo $key;
	            unset($data[$key]);
	        }elseif(C('DB_FIELDTYPE_CHECK') && is_scalar($val)) {
	            // 字段类型检查
	            $fieldType = strtolower($this->fields['_type'][$key]);
	            if(false !== strpos($fieldType,'int')) {
	                $data[$key]   =  intval($val);
	            }elseif(false !== strpos($fieldType,'float') || false !== strpos($fieldType,'double')){
	                $data[$key]   =  floatval($val);
	            }
	        }
	    }
		echo dump($data);
		echo dump(1==0);
    }
}
?>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.