Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- global $DB;
- $code = rand(10, 100000);
- //$code = date("YmdHis");
- $data = array(
- 'code' => $code,
- 'data' => 'test data'
- );
- $count_insert = 0;
- $count_update = 0;
- for( $i=0; $i < 100; $i++ )
- {
- // Check of exists
- $q = $DB->query("SELECT * FROM `test_overload` WHERE `code`='{$code}'");
- if( $q->num_rows == 0 )
- {
- $DB->query($DB->insert_string('test_overload', $data));
- $count_insert++;
- }
- else
- {
- $DB->query($DB->update_string('test_overload', $data, array('id'=>$q->row['id'])));
- $count_update++;
- }
- }
- echo "<p>Inserts: $count_insert</p>";
- echo "<p>Updates: $count_update</p>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement