I just got around to looking at this project as I need an light weight
CRUD feature set. I fixed a couple random niggles with my install
and can run the examples fine but when I got to running querys using
the DbTemplate GetInfo method I noticed the implementation doesn't
match the wiki/comments
at all.
Is this supposed to be this way? If I change this to be as its written
do you want me to check it in? Seems too deliberate to be a bug and is
in all versions of svn.
This L 169 of DbTemplate
// Figure out what to update on
if (count($conditions) > 0){
$extra = '';
foreach($conditions as $key)
$extra .= '`' . $key . '` =\'' . $this->GetValue($key) . '\' AND
';
$extra = substr($extra, 0, -4);
}else{
$extra = '`' . $this->primary . '` = '. $this->GetPrimary();
}
totally does not do this
$conditions = array('email' => (string)$_GET['email']);
What are you trying to do exactly? GetList() or GetInfo()?
If you are trying to GetInfo() of a record that matches an email
address you would need to do this:
$myObject = new Item;
$myObject->SetValue('email', (string)$_GET['email']);
$myObject->GetInfo(array('email'));
This would use the 'email' field in the "WHERE" clause instead of the
primary key for the table.
Thanks for the snappy reply. I'm trying to do GetInfo() with the
conditional flag.
I agree with what you wrote in your reply and that does indeed work
but the
wiki and comments seem to read that you can pass a conditional array
of
key/value pairs and it would then use that as parameters in the where
clause.
From this page - http://code.google.com/p/phpsimpl/wiki/DbTemplate_GetInfo
// Get the author information by email
$conditions = array('email' => (string)$_GET['email']);
// Try to get the information
if (!$myAuthor->GetInfo(NULL, $conditions)){
SetAlert('Invalid Author, please try again');
$myAuthor->ResetValues();
}
However the code only works as you described in your reply
and not like the above snippet. Am i missing something?