PHP Classes

GetNextKey fails, returns NULL

Recommend this page to a friend!

      Metabase  >  All threads  >  GetNextKey fails, returns NULL  >  (Un) Subscribe thread alerts  
Subject:GetNextKey fails, returns NULL
Summary:The auto increment feature is failing for me. What's up?
Messages:4
Author:Shawn Koppenhoefer
Date:2014-12-29 16:16:08
 

  1. GetNextKey fails, returns NULL   Reply   Report abuse  
Picture of Shawn Koppenhoefer Shawn Koppenhoefer - 2014-12-29 16:16:08
I'm working through the tutorial included with the current distribution of Metabase.
My queries involving "Select" are working fine.
But when I try to use this: $db->GetNextKey("users", $id);
echo $id reveals a NULL value.

I have successfully inserted 3 values manually.. so I know that the auto incremental nature of id is working (in MySQL).

Any ideas?

  2. Re: GetNextKey fails, returns NULL   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-12-29 16:27:09 - In reply to message 1 from Shawn Koppenhoefer
What does the $db->Error() function returns?

  3. Re: GetNextKey fails, returns NULL   Reply   Report abuse  
Picture of Shawn Koppenhoefer Shawn Koppenhoefer - 2014-12-29 16:49:27 - In reply to message 2 from Manuel Lemos
Hello!.. Happy Christmas and almost New Year.

I found the error (but thanks for responding!).
Problem fixed.

My connection setup was failing because of a typo (error) in my setup code.
I was incorrectly using this:
$error=MetabaseSetupDatabase(array(
"Type"=>"mysql",
"User"=>"blah",
"Pass"=>"blee" <---- instead of 'Password'
), $db);

I didn't realise the connection was failing,
because the following connect-test failed to see the failed connection.

if($error!=""){ //WARNING: this is not triggered if your SetupDatabase fails because of Pass
echo "Database setup error: $error\n";
exit;
}

So I assumed that the connection was fine.
Once I corrected 'Pass' to 'Password'... aok.




  4. Re: GetNextKey fails, returns NULL   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-12-29 17:01:03 - In reply to message 3 from Shawn Koppenhoefer
Oh, I see. In reality the connection is only established on the first query.

 
For more information send a message to info at phpclasses dot org.