Answer the question
In order to leave comments, you need to log in
What is the correct way to push a two-dimensional array of approximately [500][5] into the database?
Tell me how to correctly push a two-dimensional array of approximately [500][5] into the database?
How to bind everything in a loop in the example or is there a more elegant solution?
$post=new Post;
$post->title='тестовая запись';
$post->content='содержимое тестовой записи';
$post->create_time=time();
$post->save();
Answer the question
In order to leave comments, you need to log in
Understood. Yii 1.1.14 introduced this.
New method CDbCommandBuilder::createMultipleInsertCommand()
Using CDbCommandBuilder::createMultipleInsertCommand() it became possible to insert multiple records in one request:
$builder=Yii::app()->db->schema->commandBuilder;
$command=$builder->createMultipleInsertCommand('tbl_post', array(
array('title' => 'record 1', 'text' => 'text1'),
array('title' => 'record 2', 'text' => 'text2'),
));
$command->execute();
If you need a search in an array, then in any way in a loop. If not, then save either to a file, or serialize and write to the database.
"shove a two -dimensional array into the database? What prevents you from using the sirialize
& unserialize functions.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question