Author Topic: how do I return the rows for a new user?  (Read 4449 times)

Offline desertadmin

  • Jr. Member
  • **
  • Posts: 36
how do I return the rows for a new user?
« on: December 09, 2006, 05:35:44 PM »
I would like to see the return results for how many rows are in the table identities. Here is my snippet:

$num_id_row = $DB->query("select count(*) from ".get_table_name('identities'));

Is this correct? If so why do I only get the number 4..?

I need this because some thing has gone wrong with the new user code to where all new webmail users are nto incrementing and so they are nto displaying their proper identities. It seems to not be properly auto-incrementing the identity_id count.

Please any help would be appreciated.

Here is the rest of the code below with our changes in BOLD in the file main.inc.

-Sincerely,
DesertAdmin



// create new entry in users and identities table
function rcmail_create_user($user, $host)
 {
 global $DB, $CONFIG, $IMAP;

 $user_email = '';

 // try to resolve user in virtusertable
 if (!empty($CONFIG['virtuser_file']) && strstr($user, '@')==FALSE)
  $user_email = rcmail_user2email($user);

 $DB->query("INSERT INTO ".get_table_name('users')."
       (created, last_login, username, mail_host, alias, language)
       VALUES (".$DB->now().", ".$DB->now().", ?, ?, ?, ?)",
       $user,
       $host,
       $user_email,
         $_SESSION['user_lang']);

 if ($user_id = $DB->insert_id(get_sequence_name('users')))
  {
  $mail_domain = rcmail_mail_domain($host);
 
  if ($user_email=='')
   $user_email = strstr($user, '@') ? $user : sprintf('%s@%s', $user, $mail_domain);

  $user_name = $user!=$user_email ? $user : '';

  // try to resolve the e-mail address from the virtuser table
   if (!empty($CONFIG['virtuser_query']) &&
    ($sql_result = $DB->query(preg_replace('/%u/', $user, $CONFIG['virtuser_query']))) &&
    ($DB->num_rows()>0))
   while ($sql_arr = $DB->fetch_array($sql_result))
    {
    $DB->query("INSERT INTO ".get_table_name('identities')."
          (user_id, del, standard, name, email)
          VALUES (?, 0, 1, ?, ?)",
          $user_id,
          $user_name,
          preg_replace('/^@/', $user . '@', $sql_arr[0]));
    }
  else
   {
  // also create new identity records

   //omnicron and B-rad
   //  $num_id_row = mysql_query("select count(*) AS numrows from identities", DB);
   //  $num_id = mysql_fetch_array($num_id_row, MYSQL_ASSOC);
   // $num_id_row = $DB->query("select count(*) AS numrows from ".get_table_name('identities'));
   // $num_id = mysql_num_rows($num_id_rows);
   $num_id_row = $DB->query("select count(*) from ".get_table_name('identities'));


   //end omnicron and B-RAD

  $DB->query("INSERT INTO ".get_table_name('identities')."
         (identity_id, user_id, del, standard, name, email)
         VALUES (?,?, 0, 1, ?, ?)",
         //$num_id['numrows'],
         $num_id_row,
         $user_id,
         $user_name,
         $user_email);
   }
           
  // get existing mailboxes
  $a_mailboxes = $IMAP->list_mailboxes();
  }
 else
  {
  raise_error(array('code' => 500,
           'type' => 'php',
           'line' => __LINE__,
           'file' => __FILE__,
           'message' => "Failed to create new user"), TRUE, FALSE);
  }
 
 return $user_id;
 }

Offline desertadmin

  • Jr. Member
  • **
  • Posts: 36
Re: how do I return the rows for a new user?
« Reply #1 on: December 12, 2006, 07:12:20 PM »
Does any one have a clue? Or how about a different approach maybe I am misisng soemthign in the DB when it was all converted from the older version to the newer beta awhile back. I think ti was about a month or two ago when I did a SVN update and then after that I noctied some problems. I think the problem is just the contact id is not getting linked to the user_id. Can anyone help me on this.

Thanks in advance.

-Sincerely,
DesertAdmin

Offline daashag

  • Full Member
  • ***
  • Posts: 198
Re: how do I return the rows for a new user?
« Reply #2 on: December 13, 2006, 06:43:45 AM »
Have you tried to create a new database then import your data from the old one?

Offline desertadmin

  • Jr. Member
  • **
  • Posts: 36
Re: how do I return the rows for a new user?
« Reply #3 on: December 13, 2006, 01:41:48 PM »
No I haven't I wasn't sure if that was the route to go or if there was some fancy mysql statement. I.m using mysql5 and so I didn't want to mess anything up.

I guess I will have to do that. thanks for your response. If there is any other ideas I really do welcome them as well. I unfortunately am not a mysql expert and so I.m afraid of losing 400 entries.

-Sincerely,
DesertAdmin

Offline daashag

  • Full Member
  • ***
  • Posts: 198
Re: how do I return the rows for a new user?
« Reply #4 on: December 13, 2006, 01:44:19 PM »
Do you have phpmyadmin?