MySQL::Row PHP Method

Row() public method

Reads the current row and returns contents as a PHP object or returns false on error
public Row ( integer $optional_row_number = null ) : object
$optional_row_number integer (Optional) Use to specify a row
return object PHP object or FALSE on error
    public function Row($optional_row_number = null)
    {
        $this->ResetError();
        if (!$this->last_result) {
            $this->SetError("No query results exist", -1);
            return false;
        } elseif ($optional_row_number === null) {
            if ($this->active_row > $this->RowCount()) {
                $this->SetError("Cannot read past the end of the records", -1);
                return false;
            } else {
                $this->active_row++;
            }
        } else {
            if ($optional_row_number >= $this->RowCount()) {
                $this->SetError("Row number is greater than the total number of rows", -1);
                return false;
            } else {
                $this->active_row = $optional_row_number;
                $this->Seek($optional_row_number);
            }
        }
        $row = mysqli_fetch_object($this->last_result);
        if (!$row) {
            $this->SetError();
            return false;
        } else {
            return $row;
        }
    }

Usage Example

/** 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::Row