tomz
Thu 17 May 2007, 12:50 pm GMT +0200
sorry Tom, I can't follow you, please provide clear questions and code examples here
I would like to understand the concept of how the user and the user row is identified. It seems to me that all this vars (id, users_id, session id, ident) are responsible for that but I have'nt got it until now.
Here is some code:
function save_profile_date(
$ident = "", $lang = "", ...) {
if (!empty($ident)) { $sql = sprintf("UPDATE ... $this->ins_string($ident, "int"), $_SESSION['user_id']);
} else {
$sql = sprintf("INSERT INTO %s (id, users_id, language, ..., NOW())",
..., $_SESSION['user_id'], $this->ins_string($lang), ...));
}
if (mysql_query($sql) or die (mysql_error())) {
$this->profile_id = (empty($_SESSION['is_rec'])) ? mysql_insert_id() : $ident;...
}
}
function get_profile_data() {
$this->get_user_info();
$sql = sprintf("SELECT id, language, ... FROM %s WHERE users_id = %d", ... PROFILE_TABLE, $this->id);
$result = mysql_query($sql) or die (mysql_error());
if (mysql_num_rows($result) == 0) {
$this->the_msg = $this->extra_text(1);
return false;
} else {
$_SESSION['is_rec'] = true;
while ($obj = mysql_fetch_object($result)) {
$this->profile_id = $obj->id;The var $ident seems to decide if an update or an insert record is processed, right?
But how is the user and the responsible table row identified?