Welcome Guest, Not a member yet? Register   Sign In
Importing .sql files
#1

Hi guys,
I have a sql file exported from phpMyAdmin. Is there a way to import this file via the CI database classes? I tried reading the contents and then running it via simpleQuery() but it threw an exception.
Reply
#2

See https://forum.codeigniter.com/showthread.php?tid=63410

The code is for CI3, but it can be ported to CI4 easily.
Reply
#3

Thanks, it looks rather messy, so I found a library that can restore a sql file. If someone else reads this in the future, try https://github.com/ifsnop/mysqldump-php
Reply
#4

It seems the package does not provide feature to import.
But there is a sample code to import:
https://github.com/ifsnop/mysqldump-php/...p-from-php
Reply
#5

(02-05-2024, 05:06 PM)kenjis Wrote: It seems the package does not provide feature to import.
But there is a sample code to import:
https://github.com/ifsnop/mysqldump-php/...p-from-php

There's no documented example but there is a "restore" function in the class which looks to use to incorporate that same code. The readme says one of the features is:
Code:
can restore a dump from a file, when no mysql executable is available.

I was able to use it to restore a dump.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB