Creating a page Programmatically

Permalink
I'm trying to create a page but i end up with an error message.
Could a good soul help me ?

here's my code from the controller.php

<?php
defined('C5_EXECUTE') or die(_("Access Denied."));
class TestPackage extends Package {
protected $pkgHandle = 'test';
protected $appVersionRequired = '5.2.2';
protected $pkgVersion = '0.5.5';
public function getPackageDescription() {
return t("Installs the test package.");
}
public function getPackageName() {
return t("Test Package");
}
public function install() {
$pkg = parent::install();

// install Page
Loader::model('collection_types');
$path = "/";
$pr = Page::getByPath($path);
$data = array('cName'=>'Test Page', 'cDescription'=>'The test page', 'cHandle'=>'test');
$ct = CollectionType::getByHandle('default');
$pr->add($ct, $data);
}
}

here's the error message i get:

mysql error: [1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 1] in EXECUTE("select max(cDisplayOrder) from Pages where cParentID = LIMIT 1")

I would appreciate any help.
Thanks...

michelallard