Is the DbTemplate_GetInfo wiki/api/code correct for conditionals?

4 views
Skip to first unread message

Mark Smith

unread,
Apr 15, 2010, 12:29:09 AM4/15/10
to PHPSimpl
http://code.google.com/p/phpsimpl/wiki/DbTemplate_GetInfo

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']);

Nick DeNardis

unread,
Apr 15, 2010, 7:51:17 AM4/15/10
to PHPSimpl
It is setup correct.

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.

Mark Smith

unread,
Apr 15, 2010, 2:50:24 PM4/15/10
to PHPSimpl
Hi -

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?

Nick DeNardis

unread,
Apr 24, 2010, 8:08:47 AM4/24/10
to phps...@googlegroups.com
You are not missing something. Unfortunately it looks like the
documentation on the wiki is out of date and needs to be updated.
> --
> You received this message because you are subscribed to the Google Groups "PHPSimpl" group.
> To post to this group, send email to phps...@googlegroups.com.
> To unsubscribe from this group, send email to phpsimpl+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/phpsimpl?hl=en.
>
>

--
You received this message because you are subscribed to the Google Groups "PHPSimpl" group.
To post to this group, send email to phps...@googlegroups.com.
To unsubscribe from this group, send email to phpsimpl+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/phpsimpl?hl=en.

Reply all
Reply to author
Forward
0 new messages