51
Antoine
XOBJ_DTYPE_ARRAY problems in Xoops 2.0.13 and suggested fix
  • 2005/8/4 8:31

  • Antoine

  • Friend of XOOPS

  • Posts: 112

  • Since: 2004/11/14


Hi,

If you have a XOBJ_DTYPE_ARRAY and first assign a value using $obj->setVar('myArray', $myArray) and retrieve it using $myArray = $obj->getVar('myArray') XoopsObject will attempt to unserialize the array while it hasn't been serialized to begin with, since this only happens upon cleaning the var or reading it from the db. Therefore I'd like to suggest changing the following:

/kernel/object.php lines 341-343
case XOBJ_DTYPE_ARRAY:
    
$ret =& unserialize($ret);
    break;


to

case XOBJ_DTYPE_ARRAY:
    if(!
is_array($ret)) {
        
$ret =& unserialize($ret);
    }
    break;


I am not sure wether this has been reported before (tried a seach but got no results) and has been fixed in 2.2 Hope this info helps in any way.

EDIT: Just checked the 2.2 source and see the problem has been resolved. This solution might still help for 2.0.13 users.



52
Antoine
Module pre-install pre-uninstall check
  • 2005/7/27 14:32

  • Antoine

  • Friend of XOOPS

  • Posts: 112

  • Since: 2004/11/14


Hi,

Does XOOPS 2.0.13 support some form of pre-install and/or pre-uninstall mechanism?
For example I have this module that is dependent on anther module and uses it's classes and depends on the prior module to have set up the database. I would like to check prior to installing this dependent module wether the module it depends on is installed.
Is this functionality present in the framework and does anyone know of a module using this functionality?

Thanks in advance.



53
Antoine
Scope problem?
  • 2005/7/11 13:52

  • Antoine

  • Friend of XOOPS

  • Posts: 112

  • Since: 2004/11/14


Hi,

I am using the following code in my module to render an error page if some data doesn't validate:

if($err_handler->has_errors()) {
    
$xoopsOption['main_template'] = 'survey_error.html';
    include(
XOOPS_ROOT_PATH.'/header.php');
    
$xoopsTpl->assign('errors'$err_handler->getErrors());
    
//$xoopsTpl->display('db:survey_error.html');
    
include(XOOPS_ROOT_PATH.'/footer.php');
    exit();
}


Strange enough this doesn't render the template. When I use $xoopsTpl->display('db:survey_error.html') it does display correctly, but that is a workaround.

edit: using $xoopsOption['template_main'] woulda helped.



54
Antoine
Re: XOOPS and MySQL database version
  • 2005/7/2 15:34

  • Antoine

  • Friend of XOOPS

  • Posts: 112

  • Since: 2004/11/14


/mini-bump

Since I'm on a rather strict deadline I have used a workaround like this:

SELECT DISTINCT (projects.project_id)
FROM projectsproject_images
WHERE projects
.project_id project_images.project_id
AND project_type='1'


Later getting the row count with:
$count $this->db->getRowsNum($result);
return 
$count;


Not the prettiest of solutions but it does the job. Still very much like to know if anyone know how to do it with a query.



55
Antoine
Re: XOOPS and MySQL database version
  • 2005/7/1 20:33

  • Antoine

  • Friend of XOOPS

  • Posts: 112

  • Since: 2004/11/14


SELECT count(*) FROM projectsproject_images WHERE projects.project_id project_images.project_id AND project_type=1


Unfortunaltely that doesn't work when more images belong to one project. In that case that query would effectively count the number of images belonging to all projects instead of all the projects that have at least one image belonging to them.
I have been able to solve this problem for the actual retrieval of the projects that have at least one image belong to them by doing this:

SELECT DISTINCT projects.project_id AS project_idproject_nameproject_descriptionproject_typeproject_locationproject_detailsproject_statusproject_salesinfoproject_rentinfoproject_enrollmentproject_areacode
FROM projects
project_images
WHERE projects
.project_id=project_images.project_id
AND project_type=1
ORDER BY project_name


This example works cause the image_id field is not included in the SELECT and therefore generates duplicate records for each image belonging to a project. DISTINCT will get rid of these.

But not when using something like:

SELECT DISTINCT count(projects.project_idFROM projectsproject_images WHERE projects.project_id project_images.project_id AND project_type=1


In this case MySQL first basically counts all the records when combining the two tables which generates a record for each image linked to a project. That results in a single record and last MySQL applies DISTICT which by then is naturally too late since there is but one record holding a field with an incorrect project count.

This problem is really nagging me. Tried all kinds of JOINS to solve it but haven't come up with any solution. Maybe I'm missing something.



56
Antoine
Re: XOOPS and MySQL database version
  • 2005/7/1 20:04

  • Antoine

  • Friend of XOOPS

  • Posts: 112

  • Since: 2004/11/14


Hmm unfortunately 4.0x still doesn't support subqueries? I know this is a bit off topic but does anyone know how to this without subqueries (like in latest MySQL 3.x release?):

SELECT count(*) FROM projects WHERE project_id IN
(SELECT (*) FROM project_images) AND project_type=1



57
Antoine
XOOPS and MySQL database version
  • 2005/7/1 18:11

  • Antoine

  • Friend of XOOPS

  • Posts: 112

  • Since: 2004/11/14


When I first started using XOOPS I was advised by someone to use the latest release of the 3.x series of MySQL.

Now howerver, a few months later I find myself writing modules myself and I find that there are tasks I simply cannot perform in a single query in MySQL 3.x, a big problem being the lack of subqueries. My question is:

What is the highest version of MySQL to work seamlessly with the latest 2.x XOOPS version?



58
Antoine
Re: code help- Custom Block with table
  • 2005/6/24 11:48

  • Antoine

  • Friend of XOOPS

  • Posts: 112

  • Since: 2004/11/14


Quote:

Jamescne wrote:
Well never mind. After playing around and compairing the code from built in blocks, it turns out that it has to be in one long string:

<table><tr><td>Center Block Center Left Side of Table </td> <td>Center Block Center Right side of Table </td></tr></table>


Typing your html with or without newlines is of no influence to the end result except human readability. Not setting the callspacing, and cellpadding to 0 DOES.



59
Antoine
Re: Custom Block - code help
  • 2005/6/24 11:43

  • Antoine

  • Friend of XOOPS

  • Posts: 112

  • Since: 2004/11/14


That is one one the things that need to be referenced. But your "somehow" suggests that you don't know how.

Unfortunately this forum is not meant to give online courses on PHP programming. You have to have a decent grasp of PHP to make custom modules (and blocks) and be able to read and understand a lot of the sourcecode. Both the kernel and other core class code as the modules so that you can see what the structure is and how the core functionalities can be used.

I think I'd better and by saying that custom block coding is beyond the scope of the Beginner's forum. Good luck though.



60
Antoine
Re: Custom Block - code help
  • 2005/6/23 17:51

  • Antoine

  • Friend of XOOPS

  • Posts: 112

  • Since: 2004/11/14


True if you want a block with semi-static content (though you can allways use the provided tags). The problem however is: where does the template get $blocks.new_messages assigned? If it isn't set Smarty will interpret it as false and therefore the link will never get rendered.




TopTop
« 1 ... 3 4 5 (6) 7 8 9 ... 11 »



Login

Who's Online

61 user(s) are online (45 user(s) are browsing Support Forums)


Members: 0


Guests: 61


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Sep 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits