SQLExporter

Asked by De Toni Antoine

Hello guys,

First, congrats for your jobs, this project is amasing.

But i have a small problem. When i click on Export, i have the next error :

Parse error: syntax error, unexpected T_FUNCTION in /var/www/chive/protected/components/export/SqlExporter.php on line 296

I don't think the problem come from my server (ubuntu).
May be have you a solution ?

Thanks. and sorry for my english !

Kenny

Question information

Language:
English Edit question
Status:
Solved
For:
chive Edit question
Assignee:
No assignee Edit question
Solved by:
De Toni Antoine
Solved:
Last query:
Last reply:
Revision history for this message
David Roth (davrot) said :
#1

Hi Kenny,

please post the contents of the lines here ( 290-300) so that i can have a look at it.
I don't have any problems with exporting so maybe the file is broken (extract error etc.?)

david

Revision history for this message
De Toni Antoine (dt-antoine) said :
#2

Hi david,

Thanks for your fast response.

The code :

  // Find all tables
  $allTables = Table::model()->findAll('TABLE_SCHEMA = ' . Yii::app()->db->quoteValue($this->schema));

  if(count($tables) > 0)
  {
   $filteredTables = array_filter($allTables, function($table) use($tables) {

    return in_array($table->TABLE_NAME, $tables);

   });
  }
  else
  {
   $filteredTables = $allTables;
  }

Thanks for your help !

Revision history for this message
David Roth (davrot) said :
#3

The problem is the following closure which requireds PHP 5.3:

$filteredTables = array_filter($allTables, function($table) use($tables) {

    return in_array($table->TABLE_NAME, $tables);

   });

Chive 0.5 requires PHP 5.3, so you need to update your php installation.

Revision history for this message
David Roth (davrot) said :
#4

If you can't update your php version you can replace (296 - 300) with the following lines:

$filteredTables = array();
foreach($allTables as $table)
{
   if(in_array($table->TABLE_NAME, $tables))
   {
     $filteredTables[] = $table;
   }
}

Revision history for this message
De Toni Antoine (dt-antoine) said :
#5

I will test this tomorow.

Revision history for this message
De Toni Antoine (dt-antoine) said :
#6

Hi guys,

I have replace (296 - 300) with your second solution. It works perfectly.

A Last question : Many other parts of chive requires php 5.3 ?
it's perhaps better to update php than modify all files...

Kenny

Revision history for this message
David Roth (davrot) said :
#7

Checkout the newest 0.5.1 bugfix release, this includes this fix + some new translations and updated ones.

Revision history for this message
De Toni Antoine (dt-antoine) said :
#8

Thanks David !

I check this post on "Problem Solved"

Kenny