Get XOOPS XOOPSXOOPS FAQFAQ ForumsForums NewsNews ThemesThemes ModulesModules
New Posts New Topics All Posts All Forums Index General Modules Themes Development International XOOPS.org

Search

Donat-O-Meter

Make donations with PayPal!
Stats
Goal: $100.00
Due Date: Jun 30
Gross Amount: $25.00
Net Balance: $23.57
Left to go: $76.43

Donations
Anonymous ($15)Jun-14
Anonymous ($10)Jun-10

Learn XOOPS Core

Local Support

Advertisement

XOOPS Code hosted on SourceForge

Cumulus Tag Cloud

2 2.5 2.6 3.0 87 2013 Abuse admin Amazon AntiHarvesting AntiMalUser AntiSpam API bags Beats billige black Blocks blue Bootstrap Captcha cell Christmas chronolabs content Conversion demo docek download Dresses editor evden eve facebook floor free herre Honeypot Human IP jQuery kantor lamps Language log logger Lucire mobile module modules Monster mulberry MyAlbum-p newbb news online PageRank pandora Password Permissions pink Plugin portal preloader Prevention profile project propose Protector publisher Rights rmcommon Room Rotor sale security Server site SmartClone Smarty Songlist Spam stem Studio tag tags tdmcreate template Theme themes TinyMCE User userlog website Whitepaper Wishcraft XIPS xoops Xortify ZendFramework

New Users

Registering user

# 136106

g_capobianco

Welcome to XOOPS!




Bottom   Previous Topic   Next Topic  Register To Post



#1 Posted on: 2012/4/23 5:37 xoops classes
Hi everyone.I am using xoops classes for the 1st time and it seems like I am not getting it right. I am creating a simple program to insert data into a table called capture_information. This is my code:


//for index.php
<?php

require('../../mainfile.php');

global 
$xoopsOption;

$xoopsOption['template_main']= 'main.html';

require(
XOOPS_ROOT_PATH.'/header.php');

//////

$op '';

if(isset(
$_POST['save'])){

$op 'save';

}



if(isset(
$_POST['delete'])){

$op 'delete';

}

 

switch(
$op){



case 
'delete':


echo 
'why u wana delete?';



case 
'save':

 



$record_handler =& xoops_getModuleHandler('records','record');

$record_id $_POST['record_id'];

        if(
$record_id == 0){

            
//

            
$recordObj $record_handler->create();

        }

        else{

            
//

        
$recordObj $record_handler->get($record_id);

}

{

        
$recordobj->setVar("name",$_POST['name']);

        
$recordobj->setVar("email"$_POST['email']);

        
$recordobj->setVar("telephone"$_POST['telephone']);

        
$recordobj->setVar("address"$_POST['address']);

        
$recordobj->setVar("areacode"$_POST['areacode']);

        
$recordobj->setVar("time"time()); 

        
$recordobj->setVar("user_id"$GLOBALS['xoopsUser']->getVar("uid"));

}



if(!(
$record_handler->insert($recordObj)))

{

            
redirect_header(XOOPS_URL,2,'Error saving record');}

break;

}

require(
XOOPS_ROOT_PATH.'/footer.php');

?>


//for the class called record under a module called record

<?php
if (!defined("XOOPS_ROOT_PATH")) {
    die(
"XOOPS root path not defined");
}

class 
RecordRecord extends XoopsObject {

    function 
RecordRecord() {
        
$this->__construct();
    }

    function 
__construct() {
                
$this->initVar("record_id"XOBJ_DTYPE_INTnullfalse);
                
$this->initVar('name'XOBJ_DTYPE_TXTBOXnullfalse);
                
$this->initVar('email'XOBJ_DTYPE_TXTBOXnullfalse);
                
$this->initVar("telephone",  XOBJ_DTYPE_TXTBOXnullfalse255);
                
$this->initVar('address'XOBJ_DTYPE_TXTBOXnullfalse);
                
$this->initVar("areacode"XOBJ_DTYPE_TXTBOX0false);
                
$this->initVar("time"XOBJ_DTYPE_INT0false);
                
$this->initVar("user_id"XOBJ_DTYPE_INTnullfalse15);
    }    
}

class 
RecordRecordsHandler extends XoopsPersistableObjectHandler {

var 
$recordList;


    function 
RecordRecordsHandler(&$db
{
        
$this->__construct($db);
    }

    function 
__construct(&$db) {
        
parent::__construct($db'capture_information''RecordRecord''record_id');
}
?>

when i click the save button it shows me a blank page.plz help

Top

cyree
Just popping in
Just popping in
Joined:
2012/3/26 4:30
From Sandton South Africa
Group:
Registered Users
Posts: 2
(Show More) (Show Less)


#2 Posted on: 2012/4/23 12:07 Re: xoops classes
cyree,

Please see http://xoops.org/modules/newbb/viewto ... id=345955#forumpost345955 for an example. Your code above has some of the same issues as the code in that post.

Make sure you put your classes in the right folder/file too. In some places you use 'records' for your class name and in others it's 'record'. That will need to be corrected too...

Top

zyspec
Module Developer
Module Developer
Joined:
2004/9/21 8:28
From USA
Group:
Registered Users
Posts: 850
(Show More) (Show Less)


#3 Posted on: 2012/4/24 9:20 Re: xoops classes
Thanx,I managed to fix those errors. The problem was with calling the functions from class in index.

Top

cyree
Just popping in
Just popping in
Joined:
2012/3/26 4:30
From Sandton South Africa
Group:
Registered Users
Posts: 2
(Show More) (Show Less)







You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You can vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.

[Advanced Search]