MySQL::RowCount PHP Method

RowCount() public method

Returns the last query row count
public RowCount ( ) : integer
return integer Row count or FALSE on error
    public function RowCount()
    {
        $this->ResetError();
        if (!$this->IsConnected()) {
            $this->SetError("No connection", -1);
            return false;
        } elseif (!$this->last_result) {
            $this->SetError("No query results exist", -1);
            return false;
        } else {
            $result = @mysqli_affected_rows($this->mysql_link);
            if (!$result) {
                $this->SetError();
                return false;
            } else {
                return $result;
            }
        }
    }

Usage Example

Example #1
11
/** Lấy đường dẫn nhóm media */
function get_media_group_part($id = 0, $i = 1, $deepest = FALSE)
{
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    if (!is_numeric($id)) {
        $tableName = DB_PREFIX . 'media_groups';
        $whereArray = array('folder' => MySQL::SQLValue($id));
        $hmdb->SelectRows($tableName, $whereArray);
        $row = $hmdb->Row();
        $id = $row->id;
    }
    $bre = array();
    $sub_bre = FALSE;
    if ($deepest == FALSE) {
        $deepest = $id;
    }
    $tableName = DB_PREFIX . 'media_groups';
    $whereArray = array('id' => MySQL::SQLValue($id));
    $hmdb->SelectRows($tableName, $whereArray);
    $row = $hmdb->Row();
    $num_rows = $hmdb->RowCount();
    if ($num_rows != 0) {
        $this_id = $row->id;
        $folder = $row->folder;
        $parent = $row->parent;
        $bre['level_' . $i] = $folder;
        if ($parent != '0') {
            $inew = $i + 1;
            $sub_bre = get_media_group_part($parent, $inew, $deepest);
        }
    }
    if (is_array($sub_bre)) {
        $bre = array_merge($bre, $sub_bre);
    }
    krsort($bre);
    $part = implode("/", $bre);
    if ($deepest == $id) {
        return $part;
    } else {
        return $bre;
    }
}
All Usage Examples Of MySQL::RowCount