简单计数(*)命令在php中不起作用

时间:2017-04-20 20:29:40

标签: php

下面是我的php命令,$excount总是返回1

我命令的回声很好,但是count(*)没有返回正确的数字,请帮助



<?php 

error_reporting(0);
error_reporting(E_ALL); 
ini_set('display_errors', 1);

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type,x-prototype-version,x-requested-with');
header('Cache-Control: max-age=900');
header("Content-Type: application/json"); 

session_start();

$result = array("success" => FALSE, "message" => "Sorry, internal error!"); 

$authKey = 'A****9J';
if(!isset($_POST['auth_key']) || $_POST['auth_key'] != 'A****9J') {
	echo json_encode(array("success" => FALSE, "message" => "Authentication mismatch!"));
	exit(1);
}


define("DB_USR","******");
define("DB_PAS","*");
define("DB","*****");
$conn = oci_connect(DB_USR,DB_PAS,DB);

if (!$conn) {
	$e = oci_error();
	$result["message"] = $e['message'];
	echo json_encode($result);
	exit(1);
} 


date_default_timezone_set("Asia/Kolkata"); 



$emparray = array();


		 
$prs1='';
$row1='';

$emparray = array();

$SNO  =$_POST['TASKSNO'];
$TAGDTTM =$_POST['TAGDT'];
$TAGFROM =$_POST['TAGFROM'];
$TAGTO =$_POST['TAGTO'];
$TAG =$_POST['TAGNAME'];
$STATUS =$_POST['STATUS'];

$COMID=$_POST['COMID'];

$TAGTM = date("h:i:s",strtotime($TAGDTTM));

$originalDate =$TAGDTTM;
$TAGDT = date("d-M-Y", strtotime($originalDate));
$TAGDT = strtoupper($TAGDT);

$TAGDTTM1=$TAGDT." ".$TAGTM;
$TASK="";

$st1=" select ltrim(rtrim(TRANSLATE(CONVERT(T.TASKDESC,'US7ASCII') , '\n,\t',' ') )) TASKDESC  from admtask T WHERE SNO= '". $SNO."' ";
$prs1=oci_parse($conn,$st1);
$res1=oci_execute($prs1);
while ($row1=oci_fetch_assoc($prs1))
{
  $TASK = $row1["TASKDESC"];
}



$stcount = "select count(*) from tasktag where comid='$COMID' and  tag_from = '$TAGFROM' ";
$resultcount=oci_parse($conn,$stcount);
$excount=oci_execute($resultcount);
echo "excount=".$excount." ";

echo $stcount;



$st1="insert into tasktag(SNO ,  TASK, TAG_DT, TAG_FROM , TAG_TO , TAG , STATUS ,ENTRYFROM, ISREAD,COMID)
values('".$SNO."', '".$TASK."' , TO_DATE('".$TAGDTTM1."','DD-MON-YYYY HH24:MI:SS') , '".$TAGFROM."' 
, '".$TAGTO."' , '".$TAG."' , '".$STATUS."', 'PHP WEBSERVICE', 'N' , '".$COMID."')";

$prs1=oci_parse($conn,$st1);
$res1=oci_execute($prs1);
if (!$res1){
	echo json_encode($result1);
	exit(1);	
}





$mrowsno=0;




$stmt2 = "select t.rowsno , t.comid , t.sno , t.tag_from, a.LATEST_ACTIVITY_NO FROM tasktag t JOIN admtask a ON a.sno = t.sno where COMID='$COMID' and  TAG_FROM = '$TAGFROM'";




$result=oci_parse($conn,$stmt2);
$ex2=oci_execute($result);

while ($row2=oci_fetch_assoc($result))
	{
	  $emparray[] = $row2;
	}
	echo json_encode($emparray);






 oci_close($conn);

 ?>
&#13;
&#13;
&#13;

当我回复并使用postman-chrome检查我的服务时,我看到了这个 -

See my  image below, result should be 5 but result coming is 1, please help

1 个答案:

答案 0 :(得分:0)

我认为是我们的,你走了 -

&#13;
&#13;
$stcount = "select * from tasktag where comid='$COMID' and  tag_from = '$TAGFROM' ";
$sql_query = 'SELECT COUNT(*) AS NUMBER_OF_ROWS FROM (' . $stcount . ')';
$stmt3= oci_parse($conn, $sql_query);
oci_define_by_name($stmt3, 'NUMBER_OF_ROWS', $number_of_rows);
oci_execute($stmt3);
oci_fetch($stmt3);
echo $number_of_rows;
&#13;
&#13;
&#13;