我有一个数据库nginx_1 | 2017/11/01 13:21:25 [error] 8#8: *1 FastCGI sent in stderr: "Access to the script '/web' has been denied (see security.limit_extensions)" while reading response header from upstream
,其中有多个表。现在我想计算整个数据库中crm_data
值等于column_name
的所有行。要计算数据库中的所有行,我正在使用此mysql查询。
我的SQL查询:
YES
由于
答案 0 :(得分:1)
我做了什么我回到基础并使用SHOW TABLES
然后我使用表查询SELECT * FROM $company WHERE rental_status = 'YES'
。我得到了结果。
答案 1 :(得分:0)
试试这个,我希望它适合你
// connect to Database.
$links = mysqli_connect($db_host, $db_username, $db_password, $db_name );
if($links === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
//get total
$n = 'YES';
$result = mysqli_query($links,"SELECT Count(*) As column_name FROM crm_data WHERE column_name='".$n."'");
$rows = mysqli_num_rows($result);
if($rows){
$gt = mysqli_fetch_assoc($result);
$total = $gt["column_name"];
}
echo $total;
按要求使用PDO。
// using PDO
$servername = "localhost";
$username = "user";
$password = "pass";
try {
$conn = new PDO("mysql:host=$servername;dbname=dbname", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//echo "Connected successfully";
// call for the row count here.
$w='YES';
$rs = $conn->prepare("SELECT Count(*) As column_name FROM crm_data WHERE column_name='".$w."'");
$rs->execute();
$count = $rs->rowCount();
echo '<p>Total:'.$count.'</p>';
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
答案 2 :(得分:-2)
您现在没有查询数据库中的数据,而是现在查询数据库的实际结构,这是有关的。
...尽管如此
{{1}}
您正在寻找的查询......