$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过来的参数 没有接受到。

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi

PHPisusedforsendingemailsduetoitsbuilt-inmail()functionandsupportivelibrarieslikePHPMailerandSwiftMailer.1)Usethemail()functionforbasicemails,butithaslimitations.2)EmployPHPMailerforadvancedfeatureslikeHTMLemailsandattachments.3)Improvedeliverability

PHP performance bottlenecks can be solved through the following steps: 1) Use Xdebug or Blackfire for performance analysis to find out the problem; 2) Optimize database queries and use caches, such as APCu; 3) Use efficient functions such as array_filter to optimize array operations; 4) Configure OPcache for bytecode cache; 5) Optimize the front-end, such as reducing HTTP requests and optimizing pictures; 6) Continuously monitor and optimize performance. Through these methods, the performance of PHP applications can be significantly improved.

DependencyInjection(DI)inPHPisadesignpatternthatmanagesandreducesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itallowspassingdependencieslikedatabaseconnectionstoclassesasparameters,facilitatingeasiertestingandscalability.

CachingimprovesPHPperformancebystoringresultsofcomputationsorqueriesforquickretrieval,reducingserverloadandenhancingresponsetimes.Effectivestrategiesinclude:1)Opcodecaching,whichstorescompiledPHPscriptsinmemorytoskipcompilation;2)DatacachingusingMemc


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

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

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 Linux new version
SublimeText3 Linux latest version
