CodeIgniter Forums
Inserting the data - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Inserting the data (/showthread.php?tid=26950)



Inserting the data - El Forum - 01-27-2010

[eluser]piyush138[/eluser]
Hi, i am using doctrine (with codeigniter) in the following way to insert the data in the database everything is working fine but i am worried about these things
1. is this the right way to do that?
2. will it effect the server performance(page loadding)?
3. is there any other way to get the same functionality ?

here is the code

foreach($rows as $row){
$crd = new cma_records_data();
$crd->record_id = $cr_record_id;
$crd->user_id = 1;
$crd->address = $row['address'];
$crd->price = $row['price'];
$crd->recordListingID = $i;
$i++;
echo $row['address']." ".$row['price']."<br/>";
$crd->save();
unset($crd);
}


Thanks


Inserting the data - El Forum - 01-29-2010

[eluser]saidai jagan[/eluser]
I don't know more abt doctrine Big Grin but some fine tuning ll help
Code:
$crd = new cma_records_data();
foreach($rows as $row)
{
  $crd->record_id = $cr_record_id;
  $crd->user_id = 1;
  $crd->address = $row[‘address’];
  $crd->price = $row[‘price’];
  $crd->recordListingID = $i;
  echo $row[‘address’].” “.$row[‘price’].”<br>”;
  $crd->save();
  $i++;
}
unset($crd);
hope it helps Smile


Inserting the data - El Forum - 02-02-2010

[eluser]piyush138[/eluser]
By applying this technique it just inserts the last method ... what i want to know is can we create and destroy object like this in foreach Loop. doesn't it put effect on server performance.


Inserting the data - El Forum - 02-02-2010

[eluser]danmontgomery[/eluser]
[quote author="piyush138" date="1265151473"]By applying this technique it just inserts the last method ... what i want to know is can we create and destroy object like this in foreach Loop. doesn't it put effect on server performance.[/quote]

Everything you do has an effect on server performance.