- Moderated by:
- Support Team
-
- rank:
-
Freshman
- registered:
- June 2006
- Status:
- offline
- last visit:
- 30.10.06
- Posts:
- 28
Hello!
I come here for ask something that have me in a trouble.
I started to code a module. I read many manuals and study the whole Example mod. When I finished the pntables and pninit files, I tried to initialize it but nothing happens. The PostNuke 0.762 installation is correct (other mods. start correctly)
The mod folder's name is revist.
Here you are the content of both files. What I done wrong?
pntables.php
Code
pninit.php
Code
<?php
function revist_init()
{
$dbconn =& pnDBGetConn(true);
$pntable =& pnDBGetTables();
$revtable = &$pntable['revista'];
$revcolumn = &$pntable['revista_column'];
$dict = &NewDataDictionary($dbconn);
$taboptarray =& pnDBGetTableOptions();
$flds = "
$revcolumn[rid] I NOTNULL AUTOINCREMENT PRIMARY,
$revcolumn[rurl] C NOTNULL DEFAULT '',
$revcolumn[rfecha] D NOTNULL DEFDATE,
$revcolumn[rimagen] C NOTNULL DEFAULT ''
";
$sqlarray = $dict->CreateTableSQL($revtable, $flds, $taboptarray);
if ($dict->ExecuteSQLArray($sqlarray) != 2) {
pnSessionSetVar('errormsg', _EXAMPLECREATETABLEFAILED);
return false;
}
return true;
}
function revist_delete()
{
$dbconn = pnDBGetConn(true);
$pntable = pnDBGetTables();
$revtable = $pntable['revista'];
$dict = &NewDataDictionary($dbconn);
$sqlarray = $dict->DropTableSQL($revtable);
if ($dict->ExecuteSQLArray($sqlarray) != 2) {
pnSessionSetVar('errormsg', _EXAMPLEDROPTABLEFAILED);
return false;
}
return true;
}
function revist_update()
{
return true;
}
?>
Please help!! THANKS!
edited by: SiCk949, Jun 28, 2006 - 02:50 PM -
- rank:
-
Moderator
- registered:
- March 2002
- Status:
- offline
- last visit:
- 26.08.08
- Posts:
- 7720
Looks ok from a quick glance - although it's easy to miss things on screen. What diagnositics have you done so far? I'd recommend
1) checking there are no sytax errors in the file by calling it directly in the browser i.e. http://www.example.com/modules/yourmod/pninit.php (make sure display errors are on in your PHP install first). If there's a syntax error you'll see it here
2) Add a die statement to the first line of init function to check that your init function is being reached - remove after this check....
3) print out the sqlarray variable and then paste the generated SQL into phpMyAdmin get some better feedback on why your SQL might not be working ok.
-Mark -
- rank:
-
Freshman
- registered:
- June 2006
- Status:
- offline
- last visit:
- 30.10.06
- Posts:
- 28
Hello!
First of all, thanks for ur help!
1) I check the pninit.php on browser and no errors result (Blank Page).
2) I can't understand this step.
3) Cause the use of ADODB I don't know how to from the SQL command.
I tried:
CREATE TABLE `pn_revista` (
`pn_rid` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`pn_rurl` CHAR NOT NULL DEFAULT '',
`pn_rfecha` DATE NOT NULL DEFAULT '0000-00-00',
`pn_rimagen` CHAR NOT NULL DEFAULT '');
And works correctly (don't know if it correspond with my code, but its that i wanna create)
Thanks again
EDIT
finally i edited the SQL string to
Code
$revcolumn[rid] I NOTNULL AUTOINCREMENT PRIMARY,
$revcolumn[rurl] C(255) NOTNULL default '',
$revcolumn[rfecha] D NOTNULL DEFDATE,
$revcolumn[rimagen] C(255) NOTNULL default ''
and works!!!
thanks markwest!
edited by: SiCk949, Jun 28, 2006 - 02:55 PM -
- rank:
-
Moderator
- registered:
- March 2002
- Status:
- offline
- last visit:
- 26.08.08
- Posts:
- 7720
The idea of step 3 was to add the following code just after the call to the CreateTableSQL method. This gets you to the SQL generated for your DB - this can be pasted into phpMyAdmin for a better look at what mysql is returning.
Anyway looks like you've got there - a missing default date.
-Mark
