out of memory doing multiple inserts with DB_DataObject
| From: | todd | Date: | Fri, 13 Feb 2004 01:51:19 +0000 |
| Subject: | out of memory doing multiple inserts with DB_DataObject | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-25636@lists.php.net to get a copy of this message | ||
Hi,
I've just started using DB_DataObject, and I'm trying to populate a
table called "organization" with some dummy data. So I created a loop to
insert 10000 rows. However, it's exceeding the 8MB memory limit on our
server around the 4300th insert. Any idea why it's using so much memory?
AccountId is a unique key in my organization table, but it is not the
primary key. The primary key is auto incrementing (MySQL DB). Here is
the sample code:
DB_DataObject::DebugLevel(1);
$org = new DataObject_ENOrganization();
$orgCnt = $org->count();
echo( "$orgCnt orgs <br>");
for($i = 0; $i < 10000; $i++) {
$org->setId(null);
$org->setAccountId($orgCnt + $i);
$rslt = $org->insert();
}
I also tried doing the inserts directly using PEAR:DB and it stays below
the 8MB cap just fine.
for($i = 0; $i < 10000; $i++) {
$newAccountId = $orgCnt+$i;
$db->query("INSERT INTO organization(accountId)
VALUES($newAccountId)");
print_r("$i");
print_r("<BR>");
}
Thanks,
Todd Wallar