Why is the output of $ count 0 !! Publicfunctiontrain_insert () {$ pxda = M (& quot; pxda & quot;); $ data = array (); $ count = count ($ RYMC_ID ); print $ count why is output 0 !! Advice
Public function train_insert (){
$ Pxda = M ("pxda ");
$ Data = array ();
$ Count = count ($ RYMC_ID );
Print_r ($ count); exit;
$ Number = $ pxda-> query ('select max (to_number (ID) as ID from _ TABLE __');
Foreach ($ Number as $ key => $ val ){
$ MaxNumber = $ val ['id'];
}
$ Id = $ MaxNumber + 1;
$ Data ['id'] = $ ID;
$ Data ['swjg _ DM'] = $ _ POST ['swjg _ DM']; // enter the unit code
$ Data ['rymc _ id'] = $ _ POST ['rymc _ id2']; // personnel name ID
$ Data ['score '] = $ _ POST ['score']; // SCORE
$ Data ['remark'] = $ _ POST ['remark']; // remarks
$ Data ['Time'] = $ _ POST ['Time']; // add TIME
$ Data ['pxdd'] =_ _ POST ['pxdd']; // training location
$ Data ['class _ id'] = $ _ POST ['class _ id']; // Category ID
$ Data ['jcqk'] = $ _ POST ['jcqk']; // rewards and punishments
$ Data ['bzwh '] = $ _ POST ['bzwh']; // Document No.
$ Data ['zui_ id'] = $ _ POST ['zui_ id']; // topic ID
$ Data ['pxdw '] =_ _ POST ['pxdw']; // Training Unit
$ Data ['start _ time'] = $ _ POST ['start _ time']; // START TIME
$ Data ['end _ time'] = $ _ POST ['end _ time']; // END TIME
$ Data ['zzdw '] = $ _ POST ['zzdw']; // Organization Unit
$ Result = $ pxda-> add ($ data );
If ($ result! = False ){
$ This-> assign ("jumpUrl", "train ");
$ This-> success ();
$ This-> redirect ('honor/train ');
} Else {
$ This-> assign ("jumpUrl", "train ");
$ This-> error ();
}
}
------ Solution --------------------
I want to know where $ RYMC_ID came from.
------ Solution --------------------
Public function train_insert (){
$ Pxda = M ("pxda ");
$ Data = array ();
$ Count = count ($ RYMC_ID );
Print_r ($ count); exit;
The train_insert method does not define $ RYMC_ID. if the global GLOBALS or member variable $ this-> also requires you to declare and specify
Otherwise, 0 is output.
------ Solution --------------------
$ RYMC_ID where does this variable come from? Is the value assigned ???
------ Solution --------------------
$ RYMC_ID is not defined in the function. Unless it is a global variable.
------ Solution --------------------
Count-calculates the number of units in the array or the number of attributes in the object.
Description
Int count (mixed $ var [, int $ mode])
Returns the number of units in var, which is usually an array. Any other type has only one unit.
If SPL is installed on an object, you can call count () by implementing the Countable interface (). This interface has only one method count (), which returns the return value of the count () function.
If var is not an array type or an object that implements the Countable interface, 1 is returned, with an exception. If var is NULL, 0 is returned.
Note: the optional mode parameter is available in PHP 4.2.0.
If the optional mode parameter is set to COUNT_RECURSIVE (or 1), count () recursively counts the array. It is particularly useful for calculating all units of a multi-dimensional array. The default value of mode is 0. Count () cannot recognize infinite recursion.
Caution
Count () returns 0 for uninitialized variables, but returns 0 for empty arrays. Use isset () to test whether the variable has been initialized.
For more information about how to implement and use arrays in PHP, see the array section in the manual.
Example #1 count ()
$ A [0] = 1;
$ A [1] = 3;
$ A [2] = 5;
$ Result = count ($ );
// $ Result = 3
$ B [0] = 7;
$ B [5] = 9;
$ B [10] = 11;
$ Result = count ($ B );
// $ Result = 3;
$ Result = count (null );
// $ Result = 0
$ Result = count (false );
// $ Result = 1
?>
Example #2 recursive Example of count () (PHP> = 4.2.0)
$ Food = array ('Fruits '=> array ('Orange', 'banana ', 'apple '),
'Veggi' => array ('carrot', 'colard', 'pea '));
// Normal count
Echo count ($ food); // output 2
?>
See is_array (), isset (), and strlen ().
------ Solution --------------------
The problem has been solved just now. it is because the parameters you post are not accepted.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.