本文整理汇总了PHP中SQLQBuilder::countFromMultipleTables方法的典型用法代码示例。如果您正苦于以下问题:PHP SQLQBuilder::countFromMultipleTables方法的具体用法?PHP SQLQBuilder::countFromMultipleTables怎么用?PHP SQLQBuilder::countFromMultipleTables使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLQBuilder
的用法示例。
在下文中一共展示了SQLQBuilder::countFromMultipleTables方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkEmpJobTitle
/**
* Check if given employees job title matches the given title name.
*
* @param int $empNum Employee number
* @param String $jobTitleName The job title name to check
* @return boolean True if employee has given job title, false otherwise
*/
public function checkEmpJobTitle($empNumber, $jobTitleName)
{
$titleMatches = false;
$tables[0] = '`hs_hr_employee` a';
$tables[1] = '`hs_hr_job_title` b';
$joinConditions[1] = 'a.`job_title_code` = b.`jobtit_code`';
$selectConditions[] = "a.`emp_number` = " . $empNumber;
$selectConditions[] = "b.`jobtit_name` = '" . $jobTitleName . "'";
$sqlBuilder = new SQLQBuilder();
$sql = $sqlBuilder->countFromMultipleTables($tables, $joinConditions, $selectConditions);
$conn = new DMLFunctions();
$result = $conn->executeQuery($sql);
if ($result) {
$row = mysql_fetch_array($result, MYSQL_NUM);
$count = $row[0];
if ($count == 1) {
$titleMatches = true;
}
}
return $titleMatches;
}
示例2: getCount
/**
* Count job vacancys with given search conditions
* @param string $searchStr Search string
* @param string $searchFieldNo Integer giving which field to search on
*/
public static function getCount($searchStr = '', $searchFieldNo = self::SORT_FIELD_NONE)
{
$count = 0;
$fields[0] = "a." . self::DB_FIELD_VACANCY_ID;
$fields[1] = "c.jobtit_name";
$fields[2] = "CONCAT(b.`emp_firstname`, ' ', b.`emp_lastname`)";
$fields[3] = "a." . self::DB_FIELD_ACTIVE;
$fields[4] = "a." . self::DB_FIELD_DESCRIPTION;
$tables[0] = self::TABLE_NAME . ' a';
$tables[1] = 'hs_hr_employee b';
$tables[2] = 'hs_hr_job_title c';
$joinConditions[1] = 'a.' . self::DB_FIELD_MANAGER_ID . ' = b.emp_number';
$joinConditions[2] = 'a.jobtit_code = c.jobtit_code';
$selectConditions = null;
if ($searchFieldNo >= 0 && $searchFieldNo < count($fields) && trim($searchStr) != '') {
if ($searchFieldNo == self::SORT_FIELD_ACTIVE) {
$active = $searchStr ? self::STATUS_ACTIVE : self::STATUS_INACTIVE;
$selectConditions[] = "{$fields[$searchFieldNo]} = " . $active;
} else {
$filteredSearch = mysql_real_escape_string($searchStr);
$selectConditions[] = "{$fields[$searchFieldNo]} LIKE '" . $filteredSearch . "%'";
}
}
$sqlBuilder = new SQLQBuilder();
$sql = $sqlBuilder->countFromMultipleTables($tables, $joinConditions, $selectConditions);
$dbConnection = new DMLFunctions();
$result = $dbConnection->executeQuery($sql);
if ($result) {
$line = mysql_fetch_array($result, MYSQL_NUM);
$count = $line[0];
}
return $count;
}