在php与mysql中如何实现conn.execute(asp+access)功能.这是asp中的语句:
TotalUserCount=conn.execute("Select count(id) from [WebUser]")(0)
MySQLPHPselect
TotalUserCount=conn.execute("Select count(id) from [WebUser]")(0)
MySQLPHPselect
有没有通过一句代码,就可以获取到值的方法,就像asp里那种简洁.
$result=$conn->query("select count(id) from from MyUser");
$row=$result->fetch_array();
echo $row[0];
像这样都要三步才能获取到值.我觉得比较麻烦.
有没有类似于asp中conn.execute一样的功能.
$row=$result->fetch_array();
echo $row[0];
你只要使用 php5.3及以上,就可写作echo $conn->query("select count(id) from from MyUser")->fetch_array()[0];
麻烦xuzuning帮我再分析下.我用的是PHP5.3.8,但按这样写会出语法错误:Parse error: syntax error, unexpected '[',
echo $Stmt->FetchAsScalar()->getValue();