Welcome Guest, Not a member yet? Register   Sign In
[Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition)

[eluser]OverZealous[/eluser]
Thank you!

I'm currently working on replacing all of the example code with properly formatted and styled code. It wrote a little utility that automatically colors PHP functions, DMZ functions, DMZ methods, and extension methods. It works really well so far, and makes the examples much easier.

[eluser]bEz[/eluser]
@phil

Code:
A PHP Error was encountered

Severity: Warning

Message: htmlspecialchars() expects parameter 1 to be string, array given

Filename: datamapper/htmlform.php

Line Number: 715

This error is produced as a result of:

Code:
$form_fields = array('id',
      'zone' => array(
        'type' => 'hidden',
        'value' => '1'
      ),
      'pool_team' => array(
        'type' => 'hidden',
        'value' => '106'
      ),
      'position'=> array(
        'list' => $pos // limit the positions to the list above
      ),
      'depth',
      'numb' => array ('size' => '2','maxlength' => '2'),
      'name_f' => array ('size' => '10','maxlength' => '15'),
      'name_l' => array ('size' => '10','maxlength' => '25')
    );
which I determined to be caused by the "hidden" type definition. I was receiving only 1 error, but when I added a 2nd hidden field, it duplicated on the output, however, the form still processes.
What is the resolution?

Below is the validation definition from the model.
Code:
var $validation = array(
        'zone' => array(
      'label' => 'Zone',
            'rules' => array('required'),
            'type' => 'dropdown',
        ),
        'pool_team' => array(
      'label' => 'Team',
            'rules' => array('required'),
            'type' => 'dropdown',
        ),
        'position' => array(
      'label' => 'POS',
            'rules' => array('required'),
            'type' => 'dropdown',
        ),
        'depth' => array(
      'label' => 'Depth',
            'rules' => array('required', 'min_size'=>1, 'max_size'=>10),
      'type' => 'dropdown',
            'options' => array(
                '1' => '1',
                '2' => '2',
                '3' => '3',
                '4' => '4',
                '5' => '5',
                '6' => '6',
                '7' => '7',
                '8' => '8',
                '9' => '9',
                '10' => '10'
      ),
        ),
        'numb' => array(
      'label' => 'Numb',
            'rules' => array('required', 'trim', 'integer', 'min_size'=>0, 'max_size'=>99)
        ),
        'name_f' => array(
      'label' => 'First',
            'rules' => array('required', 'trim', 'alpha_dash_dot')
        ),
        'name_l' => array(
      'label' => 'Last',
            'rules' => array('required', 'trim', 'alpha_dash_dot')
        ),
    );

[eluser]Ninja[/eluser]
Thanx OverZealous

Wow you really great with this, lol Can i get you on speed dial? (just kidding)

Got it working but just took out the 'IS NULL' because it was throwing a database error. Like it didnt recognize IS NULL (Im using postgreSQL)
But this is how i got it working and didnt need to instantiate client:
Code:
$comp = new Company();
                
    $comp->where_related('client_company', 'id')->get();
    foreach($comp->all as $entry)
    {
        $data['comp'][$entry->id] = $entry->companyname;
    }

Thanx again been stuck with this problem for a week now. Glad its finally sorted and it was so simple. Silly on my part trying the long way around.

[eluser]OverZealous[/eluser]
Are 'zone' and 'pool_team' related items? (As opposed to being stored on the model directly.)

If so, then that's the issue. The hidden input type isn't really designed to handle relationships. Just normal, single values.

Only inputs that can have an array of possible values (dropdown, checkbox, and radio) can be used with relationship fields.

Why would you pass a related value in a hidden field, anyway?

If you have a good reason to pass that kind of information, then you can create your own input method helper. Instructions are in the docs.

[eluser]OverZealous[/eluser]
Officially Released:
Quote:Version 1.4.0: The Big Update!
This is my biggest set of updates to date. This version of DMZ will hopefully be a welcome improvement.

Core Changes:
• Load an object when it is created (new Model($model_id))
• The ability to save an existing object as new. (save_as_new)
• The ability to query and include columns from indirect (deep) relationships. (ex: $post->where_related('user/group', 'name', 'Administrators')->get()Wink
• Skip validation when saving. (skip_validation)
• Group your where statements (group_start and group_end)
• New case-insensitive LIKE querys. (ilike)
• The ability to specify a default order by.
• An extensive working example application, with login and form-based editing.

Extension Changes
• Convert DMZ objects to and from associative arrays (including $_POST). This even works with relationships! (arrayutils)
• Convert DMZ objects to and from CSV files! (csvutils)
• Instantly generate customizable HTML forms! The output works with arrayutils, so you can generate a form, edit, and save with extremely little code! (htmlform)
• Use the built-in CodeIgniter query caching to speed up frequently queried result sets! (simplecache)
• Updated the json extension to be able to convert the all array. (json)

Improvements
Smarter Saves: All in-table foreign keys will be saved at the same time as the object's update.
Plural Related Objects: you can now use the plural form for related objects in most cases, making the code easier to read.
• Several other performance-related updates.

Bug Fixes
• Fixed several minor bugs, some of which have been discussed here.

Other
• Significantly updated manual, including new and easier-to-read examples throughout.
• I'm now providing a "lite" download, if you don't want the manual and example application. (Cuts the download size by almost 90%.)
• There's more! See the manual!

For those who are interested:
• I have (I think) updated every single HTML file in the manual, with style changes, modifications, or all new content.
• I have made 156 commits (from rev 33 to rev 189 in my SVN repo) for this update.
• There are 8268 lines of PHP code in the distribution, with 1535 lines in extensions, and 1883 lines in the example app. (Simple line count, including blank lines.)
• I wrote a custom script to read chunks of PHP code, run it through highlight_string, and then heavily process it to auto-color DataMapper methods (and built-in PHP methods).

Quote:Download the Latest Version Here

View the change log and the upgrade process
Having issues? Please look through the Troubleshooting Guide & FAQs
View the Complete Manual

[eluser]bEz[/eluser]
[quote author="OverZealous.com" date="1248698923"]Are 'zone' and 'pool_team' related items? (As opposed to being stored on the model directly.)[/quote]
No, they are not "traditional" join table related. I will use "jt's" on a case-by-case basis.

[quote author="OverZealous.com" date="1248698923"]If so, then that's the issue. The hidden input type isn't really designed to handle relationships. Just normal, single values.
Only inputs that can have an array of possible values (dropdown, checkbox, and radio) can be used with relationship fields.[/quote]
Oh, well... In testing I disabled the "htmlspecialchars" function on line 715 and that resolved the error, but I will refrain from hacking the library.

[quote author="OverZealous.com" date="1248698923"]Why would you pass a related value in a hidden field, anyway?
If you have a good reason to pass that kind of information, then you can create your own input method helper. Instructions are in the docs.[/quote]
Basically, the two hidden are used because the id's are "PRE-DETERMINED" from a previous screen (via anchor tag) when CREATING A NEW ROW. A tiered managment page.
For EDITING, I will not be using it as a hidden value because at that point, I may want to change the zone and/or pool_team as needed. Say a collegiate player needs to become a free agent, pro player, etc.

BTW, I see dmz went GOLD!
maybe for the next release, you can add this tidbit about use of "hidden" to the docs (if not already updated).


p.s. :: DEEP RELATIONSHIPS, omg that feature is about to get abused. Better be ready for ways in which to optimize it if need be... :coolgrin:

[eluser]bEz[/eluser]
@phil
Was looking at the help page for the login_manager (which I only used via testing example app). Is there a typo with the $params vs $param variables used in the constructor?

Code:
function __construct($params = array())
    {
        
        $this->CI =& get_instance();
        $this->session =& $this->CI->session;
        
        if( ! isset($params['autologin']) || $params['autologin'] !== FALSE)
        {
            $required_group = -1;
            if(isset($param['required_group']))
            {
                $required_group = $param['required_group'];
            }
            $this->check_login($required_group);
        }
    }

[eluser]bEz[/eluser]
@phil

excerpt from dmz 1.4.0 manual.
Quote:Custom Types

HTML Form includes several types (listed below). You can also add any type by simply creating a helper function to render it.

The helper function must be named input_{$type}, and must take these arguments:

* $object: The DataMapper object being rendered.
* $field: The field, related field, or id to be rendered.
* $value: The current value for the field. This is updated automatically based on what was submitted.
* $options: An associative array of options for the field.

Example
Code:
// Render a JavaScript Calendar
function input_calendar($object, $field, $value, $options)
{
    return "<input type=\"text\" id=\"$field\" name=\"$field\" value=\"$value\">";
}

Then simply set the type of any object to calendar to use this input type.

In the example code, $object is being passed for what purpose?
Is it in case you need to use it? Don't see any magical way... 8-/

btw, I have created my custom type as input_hidepreset

[eluser]OverZealous[/eluser]
@bEz
Yes, that's a typo in the example app. The example app might be full of little mistakes like that :roll:

--

The input-generation functions all receive the $object. That is entirely on purpose. It allows the input function to modify what it generates based on the $object being worked on. If I didn't pass it, you couldn't read other fields on the object.

For example, maybe I want to generate an AJAX control that looked up items in an on-the-fly drop-down. I might need to send the ID and Model of the object back to the server for that.

--

I did make a note that the related items can only work with dropdown, checkbox, and radio in the lastest release. I might modify it for the next release, to allow hidden for single-input types. There might also be a bug, I don't know, I just haven't had time to look into that one.

Have fun breaking the new features. I might not be able to respond very quickly during the rest of this week.

[eluser]Dartmien[/eluser]
Hey guys, Im new to the datamapper and Im having problems to execute a simple query...

Here is my model

Code:
class Message extends DataMapper
{
    var $has_one = array(
        'sender' => array(
            'class' => 'users'
        ),
        'receiver' => array(
            'class' => 'users'
        )
    );

    # Returns a list of all the users who the user has messaged
    function users_messaged($currentUserId){
        return $this->distinct()->select("receiver_id")->get_by_sender_id($currentUserId)->all;
    }
}

I am calling that from my controller this way:

Code:
function test(){
        $var = $this->message->users_messaged(1);
        
        foreach ($var as $msg)
        {
            echo '<p>' . $msg->receiver_id . '</p>';
            
        }
    }

That should return 4 ids from my database but it returns only the id from the last row...

But if i remove the "select("receiver_id")" i get all rows i wanted...

What am I missing here?

Thanks in advance




Theme © iAndrew 2016 - Forum software by © MyBB