Adsense
Popular Posts
- Code update from PHP 7.4 to PHP 8.1 - PhpSpreadsheet
- MySQL workbench -"Could not decrypt password cache"
- Code update from PHP 7.4 to PHP 8.1 - Worksheet/Iterator.php
- Rendering HTML tags inside textarea
- axios handle blob type data
- Unix Utils and wget in Windows
- increase mysql query speed
- Setup vi syntax for PHP
- Get WAMP running on EC2
- add comment to table columns in phpMyAdmin
Monday, October 6, 2014
Loading external sql files in PHP
I have a large sql file. I preferred to separate it from PHP code.
I created a SQL directory to put these sql files. Using PHP function file_get_contents to laod
external sql files.
$db2 = new ConnectionDB2();
$sql = file_get_contents(SITE_SERVER_ROOT."/_models/SQL/CSRPTcourses_lut.sql");
$result = $db2->query($sql);
$data = array();
while ($row = $db2->getArray($result)) {
$data[] = $row;
}
$db2->close();
Labels:
php
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment