Re: DataObjects

From: Date: Fri, 23 Feb 2007 10:03:06 +0000
Subject: Re: DataObjects
References: 1  Groups: php.pear.general php.pear.general 
Request: Send a blank email to pear-general+get-26654@lists.php.net to get a copy of this message
eak - that's a query and a half.... You dont need to call find() after query() - query will run the query for you. PS. PLEASE always escape $_GET[] vars when generating a query - $sql->escape($_GET[.....]) Regards Alan Ian Warner wrote: > utilising query: > > I thought this looked right - when I use it I only get the data from the > TBL_SMS_CENTER_CHAT_DETAILS table - this makes sense I have used $sql > throughout. How do I go about acheiving what I want in DataObjects? Or > should I go straight through MDB2? > > // Query to get the users details and messages sent. > DB_DataObject::debugLevel(0); > $sql = DB_DataObject::factory(TBL_SMS_CENTER_CHAT_DETAILS); > $sql1 = DB_DataObject::factory(TBL_SMS_CENTER_SERVICES); > $sql2 = DB_DataObject::factory(TBL_SMS_CENTER_IN); > $sql3 = DB_DataObject::factory(TBL_SMS_CENTER_PREMIUM); > > $_GET['cid'] = 2; > > $sql->query("(SELECT A.name, > A.cli, A.location, > A.dob, A.age, > A.starsign, > A.sex, A.partner, > A.mstatus, > A.notes, > C.message, > C.creation_date AS date, 'IN', > C.action AS status > FROM " . $sql->__table . " A, > " . $sql1->__table . " > B, " . $sql2->__table . " C > WHERE A.detail_id = '" . > $_GET['cid'] . "' > AND A.cli = > C.cli > AND B.service_id = > C.service_id > AND B.type = 'Chat') > UNION > (SELECT A.name, > A.cli, A.location, > A.dob, A.age, > A.starsign, > A.sex, A.partner, > A.mstatus, > A.notes, > C.message, > C.creation_date AS date, 'OUT', > C.status > FROM " . $sql->__table . " A, > " . $sql1->__table . " > B, " . $sql3->__table . " C > WHERE A.detail_id = '" . > $_GET['cid'] . "' > AND A.cli = > C.cli > AND B.service_id = > C.service_id > AND B.type = 'Chat') > ORDER BY date DESC"); > > $total = $sql->find(); > $sql->fetch(); > > Cheers > > Ian

« previous php.pear.general (#26654) next »