Author Topic

Alex Jones

Tuesday 15 June 2004 6:53:35 pm

Comment40874

Well I am obviously doing something really wrong as I still can't get this working. Grrrr. Below is my current version of the script. Can anyone see what I may be doing wrong?

<?php

include_once( 'kernel/classes/ezcontentobjecttreenode.php' );
include_once( 'kernel/classes/ezcontentobject.php' );
include_once( 'lib/ezutils/classes/ezcli.php' );
include_once( 'kernel/classes/eznodeassignment.php' );

$parentNodeID = 186;
$newParentNodeID = 650;
// Set up the command line interface.
//
// This allows eZ to set up the PHP session correctly.

$cli =& eZCLI::instance();

$link = mysql_connect('localhost', 'Exponential', '4es6zH3Ay');
if (!$link) {
   die('Could not connect: ' . mysql_error());
}
mysql_select_db("ez_cuttingedge") or die("Could not select database");
$query = "SELECT * FROM `ezcontentobject_attribute` WHERE `contentclassattribute_id` = 215 AND data_text <> ''";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
echo '[ ' . $query . ' ]' . "\n";
$rollover = '60';
$today = date("Y m d");

while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
  $datestring1 = $line["data_text"];
  $date1 = explode(" ",$datestring1);
  $date2 = explode(" ",$today);
  sprintf($datestring1, "%s%s%s", $date1[0], $date1[1], $date1[2]);
  sprintf($today, "%s%s%s", $date2[0], $date2[2], $date2[2]);
  $dateDiff = mktime(11,0,0,$date2[1],$date2[2],$date2[0]) - mktime(12,0,0,$date1[1],$date1[2],$date1[0]);
  $difference = floor($dateDiff/60/60/24);

  if ($rollover > $difference){
    
  } else {
    $query2 = 'SELECT * FROM ezcontentobject_tree WHERE contentobject_id = ' . $line["contentobject_id"];
    $result2 = mysql_query($query2) or die("Query failed : " . mysql_error());
    while ($line2 = mysql_fetch_array($result2, MYSQL_ASSOC)) {
      $movingNode = $line2["node_id"];
      $node =& eZContentObjectTreeNode::fetch($movingNode);
      $node->move($newParentNodeID);
    }
  }
}

/* Free resultset */
mysql_free_result($result);
mysql_close($link);
?>

I keep getting the error <i>
PHP Fatal error: Call to a member function on a non-object in /x/local/www/cuttingedge.data/ez_upgraded/auto_archive3.php on line 56</i> when I try to run the script. The line in question is <i>$node->move($newParentNodeID);</i>.

Any thoughts?

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>