$count为什么输出为0!!指教
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'];//录入单位代码
$data['RYMC_ID'] = $_POST['RYMC_ID2'];//人员名称id
$data['SCORE'] = $_POST['SCORE'];//成绩
$data['REMARK'] = $_POST['REMARK'];//备注
$data['TIME'] = $_POST['TIME'];//添加时间
$data['PXDD'] = $_POST['PXDD']; //培训地点
$data['CLASS_ID'] = $_POST['CLASS_ID'];//类别id
$data['JCQK'] = $_POST['JCQK'];//奖惩情况
$data['BZWH'] = $_POST['BZWH']; //文号
$data['ZUTI_ID'] = $_POST['ZUTI_ID'];//主题id
$data['PXDW'] = $_POST['PXDW'];//培训单位
$data['START_TIME'] = $_POST['START_TIME'];//开始时间
$data['END_TIME'] = $_POST['END_TIME'];//结束时间
$data['ZZDW'] = $_POST['ZZDW'];//组织单位
$result = $pxda->add($data);
if ($result !== false) {
$this->assign("jumpUrl","train");
$this->success();
$this->redirect('Honor/train');
} else {
$this->assign("jumpUrl","train");
$this->error();
}
}
------解决方案--------------------
我想知道 $RYMC_ID 是哪儿来的
------解决方案--------------------
public function train_insert(){
$pxda =M("pxda");
$data = array();
$count = count($RYMC_ID);
print_r($count);exit;
train_insert方法并未定义$RYMC_ID,如果全局GLOBALS或者成员变量$this->也需要你申明、指定
否则必然输出0
------解决方案--------------------
$RYMC_ID 这个变量哪里来的? 赋值了么???
------解决方案--------------------
$RYMC_ID在函数里没有出现过定义。除非是全局变量。
------解决方案--------------------
count ― 计算数组中的单元数目或对象中的属性个数
说明
int count ( mixed $var [, int $mode ] )
返回 var 中的单元数目,通常是一个 array,任何其它类型都只有一个单元。
对于对象,如果安装了 SPL,可以通过实现 Countable 接口来调用 count()。该接口只有一个方法 count(),此方法返回 count() 函数的返回值。
如果 var 不是数组类型或者实现了 Countable 接口的对象,将返回 1,有一个例外,如果 var 是 NULL 则结果是 0。
Note: 可选的 mode 参数自 PHP 4.2.0 起可用。
如果可选的 mode 参数设为 COUNT_RECURSIVE(或 1),count() 将递归地对数组计数。对计算多维数组的所有单元尤其有用。mode 的默认值是 0。count() 识别不了无限递归。
Caution
count() 对没有初始化的变量返回 0,但对于空的数组也会返回 0。用 isset() 来测试变量是否已经初始化。
请参考手册中数组一节中关于怎样在 PHP 中实现和使用数组的详细解释。
Example #1 count() 例子
$a[0] = 1;
$a[1] = 3;
$a[2] = 5;
$result = count($a);
// $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 count() 的递归例子(PHP >= 4.2.0)
$food = array('fruits' => array('orange', 'banana', 'apple'),
'veggie' => array('carrot', 'collard','pea'));
// recursive count
echo count($food, COUNT_RECURSIVE); // output 8
// normal count
echo count($food); // output 2
?>
参见 is_array(),isset() 和 strlen()。
------解决方案--------------------
刚才已经解决了,是你post过来的参数 没有接受到。

TooptimizePHPcodeforreducedmemoryusageandexecutiontime,followthesesteps:1)Usereferencesinsteadofcopyinglargedatastructurestoreducememoryconsumption.2)LeveragePHP'sbuilt-infunctionslikearray_mapforfasterexecution.3)Implementcachingmechanisms,suchasAPC

PHPisusedforsendingemailsduetoitsintegrationwithservermailservicesandexternalSMTPproviders,automatingnotificationsandmarketingcampaigns.1)SetupyourPHPenvironmentwithawebserverandPHP,ensuringthemailfunctionisenabled.2)UseabasicscriptwithPHP'smailfunct

The best way to send emails is to use the PHPMailer library. 1) Using the mail() function is simple but unreliable, which may cause emails to enter spam or cannot be delivered. 2) PHPMailer provides better control and reliability, and supports HTML mail, attachments and SMTP authentication. 3) Make sure SMTP settings are configured correctly and encryption (such as STARTTLS or SSL/TLS) is used to enhance security. 4) For large amounts of emails, consider using a mail queue system to optimize performance.

CustomheadersandadvancedfeaturesinPHPemailenhancefunctionalityandreliability.1)Customheadersaddmetadatafortrackingandcategorization.2)HTMLemailsallowformattingandinteractivity.3)AttachmentscanbesentusinglibrarieslikePHPMailer.4)SMTPauthenticationimpr

Sending mail using PHP and SMTP can be achieved through the PHPMailer library. 1) Install and configure PHPMailer, 2) Set SMTP server details, 3) Define the email content, 4) Send emails and handle errors. Use this method to ensure the reliability and security of emails.

ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

The reason for using Dependency Injection (DI) is that it promotes loose coupling, testability, and maintainability of the code. 1) Use constructor to inject dependencies, 2) Avoid using service locators, 3) Use dependency injection containers to manage dependencies, 4) Improve testability through injecting dependencies, 5) Avoid over-injection dependencies, 6) Consider the impact of DI on performance.

PHPperformancetuningiscrucialbecauseitenhancesspeedandefficiency,whicharevitalforwebapplications.1)CachingwithAPCureducesdatabaseloadandimprovesresponsetimes.2)Optimizingdatabasequeriesbyselectingnecessarycolumnsandusingindexingspeedsupdataretrieval.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version
Recommended: Win version, supports code prompts!
