I received the following error whil trying to read a CSV file in from my www folder. I am perplexed. It is there and permissions are wide open 777.
Ubuntu Linux LTS12.04 / NGINX / Yii 1.12
CDbException Object ( [errorInfo] => Array ( [0] => HY000 [1] => 29 [2] =>[b] File '/usr/share/nginx/www/q1media/june1.csv' [/b]not found (Errcode: 13) ) [message:protected] => CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 29 File '/usr/share/nginx/www/q1media/june1.csv' not found (Errcode: 13) [string:Exception:private] => [code:protected] => 0 [file:protected] => /usr/share/nginx/www/q1media/framework/db/CDbCommand.php [line:protected] => 357 [trace:Exception:private] => Array ( [0] => Array ( [file] => /usr/share/nginx/www/q1media/protected/controllers/AppnexusNetworkAnalyticsController.php [line] => 133 [function] => execute [class] => CDbCommand [type] => -> [args] => Array ( ) ) [1] => Array ( [file] => /usr/share/nginx/www/q1media/framework/web/actions/CInlineAction.php [line] => 49 [function] => actionImportCSV [class] => AppnexusNetworkAnalyticsController [type] => -> [args] => Array ( ) ) [2] => Array ( [file] => /usr/share/nginx/www/q1media/framework/web/CController.php [line] => 308 [function] => runWithParams [class] => CInlineAction [type] => -> [args] => Array ( [0] => Array ( [r] => appnexusNetworkAnalytics/importCSV ) ) ) [3] => Array ( [file] => /usr/share/nginx/www/q1media/framework/web/CController.php [line] => 286 [function] => runAction [class] => CController [type] => -> [args] => Array ( [0] => CInlineAction Object ( [_id:CAction:private] => importCSV [_controller:CAction:private] => AppnexusNetworkAnalyticsController Object ( [layout] => //layouts/fullwidth [menu] => Array ( ) [breadcrumbs] => Array ( ) [defaultAction] => index [_id:CController:private] => appnexusNetworkAnalytics [_action:CController:private] => CInlineAction Object *RECURSION* [_pageTitle:CController:private] => [_cachingStack:CController:private] => [_clips:CController:private] => [_dynamicOutput:CController:private] => [_pageStates:CController:private] => [_module:CController:private] => [_widgetStack:CBaseController:private] => Array ( ) [_e:CComponent:private] => [_m:CComponent:private] => ) [_e:CComponent:private] => [_m:CComponent:private] => ) ) ) [4] => Array ( [file] => /usr/share/nginx/www/q1media/framework/web/CController.php [line] => 265 [function] => runActionWithFilters [class] => CController [type] => -> [args] => Array ( [0] => CInlineAction Object ( [_id:CAction:private] => importCSV [_controller:CAction:private] => AppnexusNetworkAnalyticsController Object ( [layout] => //layouts/fullwidth [menu] => Array ( ) [breadcrumbs] => Array ( ) [defaultAction] => index [_id:CController:private] => appnexusNetworkAnalytics [_action:CController:private] => CInlineAction Object *RECURSION* [_pageTitle:CController:private] => [_cachingStack:CController:private] => [_clips:CController:private] => [_dynamicOutput:CController:private] => [_pageStates:CController:private] => [_module:CController:private] => [_widgetStack:CBaseController:private] => Array ( ) [_e:CComponent:private] => [_m:CComponent:private] => ) [_e:CComponent:private] => [_m:CComponent:private] => ) [1] => Array ( ) ) ) [5] => Array ( [file] => /usr/share/nginx/www/q1media/framework/web/CWebApplication.php [line] => 282 [function] => run [class] => CController [type] => -> [args] => Array ( [0] => importCSV ) ) [6] => Array ( [file] => /usr/share/nginx/www/q1media/framework/web/CWebApplication.php [line] => 141 [function] => runController [class] => CWebApplication [type] => -> [args] => Array ( [0] => appnexusNetworkAnalytics/importCSV ) ) [7] => Array ( [file] => /usr/share/nginx/www/q1media/framework/base/CApplication.php [line] => 169 [function] => processRequest [class] => CWebApplication [type] => -> [args] => Array ( ) ) [8] => Array ( [file] => /usr/share/nginx/www/q1media/index.php [line] => 13 [function] => run [class] => CApplication [type] => -> [args] => Array ( ) ) ) [previous:Exception:private] => )
I am trying to read this using the MySQL LOAD DATA command.
My controller:
public function actionImportCSV() {
$filepath = Yii::getPathOfAlias('webroot').'/';
$filename = 'june1.csv'
$sql="LOAD DATA INFILE '".$filepath.$filename."'
INTO TABLE `network_analytics`
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\n'
IGNORE 0 LINES
(`publisher_id`, `site_id`, `placement_id`, `imp_date`, `imps`, `imps_resold`, `imps_kept`, `revenue`, `media_cost`, `revenue_rpm` ) ";
$connection=Yii::app()->db;
$transaction=$connection->beginTransaction();
try
{
$connection->createCommand($sql)->execute();
$transaction->commit();
}
catch(Exception $e) // an exception is raised if a query fails
{
print_r($e);
exit;
$transaction->rollBack();
}
$this->redirect(array("index"));
}
What am I doing wrong?
There was a bug with LOAD DATA LOCAL INFILE …but I modified my config/main and it seems to have gotten around the error.
Just won’t open the file now.
Thanks for any advice!