-
-
Save anonymous/6db54b4e6eb9d0e133c6 to your computer and use it in GitHub Desktop.
Created by gistup (http://anastrozol.wordpress.com/category/gistup/)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
DROP TABLE IF EXISTS `md5`; | |
CREATE TABLE `md5` ( | |
`id` int(11) NOT NULL, | |
`key` varchar(5) NOT NULL, | |
`bar` varchar(32) NOT NULL | |
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | |
*/ | |
require_once("idiorm.php"); | |
ORM::configure('mysql:host=localhost;dbname=test'); | |
ORM::configure('username', 'user'); | |
ORM::configure('password', 'user'); | |
$db = ORM::get_db(); | |
$data=array(); | |
for($i=0;$i<=1000;$i++){ | |
$key=base_convert($i, 10,36); | |
$data[]=array('key'=>$i,'bar'=>$i); | |
}; | |
echo "Preparing data done"; | |
$row=ORM::for_table('md5')->create()->save_multi($data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
DROP TABLE IF EXISTS `md5`; | |
CREATE TABLE `md5` ( | |
`id` int(11) NOT NULL, | |
`key` varchar(5) NOT NULL, | |
`bar` varchar(32) NOT NULL | |
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | |
*/ | |
require_once("idiorm.php"); | |
ORM::configure('mysql:host=localhost;dbname=test'); | |
ORM::configure('username', 'user'); | |
ORM::configure('password', 'user'); | |
$db = ORM::get_db(); | |
for($i=0;$i<=1000;$i++){ | |
$person=ORM::for_table('md5')->create(); | |
$person->key = base_convert($i,10,36); | |
$person->bar = $i; | |
$person->save(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Data being submitted is different. In line 19 of
query.php
perhaps you mean:There are probably a handful of ways to speed up the first one, if it were important. One that comes to mind first is doing the
for_table
outside the loop, then cloning it. Using Idiorm's pendingraw_execute()
method might be even faster than both of the methods shown here.