[pLog-svn] db vs pdb confusion...

Oscar Renalias oscar at renalias.net
Sun Jan 28 03:28:11 EST 2007


I wouldn't use those buildXXXQuery() methods, I've been meaning to  
remove them for a while because I don't like them either (they  
weren't added by me in the first place)

I've always thought it's easier to build queries manually...

On 28 Jan 2007, at 03:22, Jon Daley wrote:

> I am not sure how to convert this to a buildSelectQuery()
>
>          $query = "SELECT address ".
>              "FROM {$prefix}subscribe ".
>              "WHERE active=1 AND ".
>              "type=".$type." AND (";
>          foreach($ids as $id)
>              $query .= "objid=$id OR ";
>          $query .= "objid=0)";
>
> The WHERE condition has a nested OR, inside an AND.
> Is that possible to do?  Is there documentation or some place to  
> look for
> these sorts of examples?
>
> On Sat, 27 Jan 2007, Jon Daley wrote:
>
>> 	Yes, I just figured that out - I don't know what I was thinking.
>> It does look like there is too much code in db.class.php - ie. why  
>> do the
>> buildWhereCondition, buildUpdateQuery, etc. exist in that class?
>> Shouldn't the pdb classes only be used?  Maybe that is just for  
>> backward
>> compatibility?
>>
>>  On Sun, 28 Jan 2007, Oscar Renalias wrote:
>>
>>> Db::getDb() returns a reference to the right database driver,
>>> currently PDbMySQLDriver only so you can call the
>>> PDbDriverBase::Affected_Rows() in that object to get what you're
>>> looking for.
>>>
>>> On 28 Jan 2007, at 01:57, Jon Daley wrote:
>>>
>>>> I haven't ever quite understood how all the database stuff works.
>>>>
>>>> I have a function that I was typing the mysql directly, and I
>>>> thought that
>>>> perhaps I should use the Db::buildUpdateQuery instead.  Is that the
>>>> right
>>>> thing to do?
>>>>
>>>> What I am missing is I don't know how to get to the Affected_Rows()
>>>> function, that exists in mysqldriver, but not mysqlrecordset.
>>>>
>>>>
>>>>
>>>>      function confirmSubscription($confirmation){
>>>>          include_once( PLOG_CLASS_PATH."class/database/
>>>> db.class.php" );
>>>> //        $prefix = Db::getPrefix();
>>>> //        $query = "UPDATE {$prefix}subscribe ".
>>>> //            "SET active=1, confirm=NULL ".
>>>> //            "WHERE confirm='$confirmation'";
>>>>          $db =& Db::getDb();
>>>>          $query = Db::buildUpdateQuery("subscribe",
>>>>                                        array("active" => 1,
>>>>                                              "confirm" => NULL),
>>>>                                        array("confirm" =>
>>>> $confirmation));
>>>>          if(!$db->Execute($query))
>>>>              return false;
>>>>
>>>>              // TODO: check affected_rows, and make sure
>>>>              // that it is at least 1.
>>>>          return true;
>>>>      }
>>>>
>>>>
>>>> --
>>>> Jon Daley
>>>> http://jon.limedaley.com/
>>>>
>>>> To be upset over what you don't have is to waste what you do have.
>>>> -- Unknown
>>>> _______________________________________________
>>>> pLog-svn mailing list
>>>> pLog-svn at devel.lifetype.net
>>>> http://limedaley.com/mailman/listinfo/plog-svn
>>>>
>>>
>>> _______________________________________________
>>> pLog-svn mailing list
>>> pLog-svn at devel.lifetype.net
>>> http://limedaley.com/mailman/listinfo/plog-svn
>>>
>>
>> -- 
>> Jon Daley
>> http://jon.limedaley.com/
>>
>> There are really only two bases: 2 and e.
>> -- Michael Brian McElroy
>> _______________________________________________
>> pLog-svn mailing list
>> pLog-svn at devel.lifetype.net
>> http://limedaley.com/mailman/listinfo/plog-svn
>>
>
> -- 
> Jon Daley
> http://jon.limedaley.com/
>
> Any time you get a mouthful of hot soup,
>    the next thing you do will be wrong.
> -- Zall's First Law
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://limedaley.com/mailman/listinfo/plog-svn
>



More information about the pLog-svn mailing list