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

[eluser]PoetaWD[/eluser]
Great !!!

Thanks !!!

That will help a lot !

[eluser]NachoF[/eluser]
[quote author="OverZealous" date="1251873145"]@NachoF
I use Aptana Studio. Built in support for PHP, many JavaScript frameworks (including dojo, prototype, and jquery).

However, it is basically Eclipse, so it may not work for you. The DataMapper class is too big to edit directly, at any rate. You might have noticed I include a "src" directory. I've broken DMZ into several, well-grouped parts. I can edit these independently, and then I run build.php to convert them into datamapper.php.

I work on a Mac Pro, and the last time I used VS was about Windows 98. Smile[/quote]

So its impossible to get like a dropdown where you can just pick which method/attribute you want to access??...javascript support isnt as important for me cause I only do some simple stuff with jquery and be done with it.... but I find myself always going to codeigniter user guide cause I forget the order of the parameters for the html helpers (I sometimes wonder if itd just be easier to manually code the html instead of helpers) or going to my database UI to get the name of the columns to use in the datamapper query (get_by_somecolumn) ...

With Visual Studio you do get this help when you use ORMs like LinqtoSql or the Entity Framework or NHibernate....

you still have Boot Camp right?. asp.net mvc is actually pretty cool but thats another topic entirely... I was just looking for a way to have my php editor to support Datamapper Sad

[eluser]PoetaWD[/eluser]
I am verynew with php... I was just a webdesigner before...

I am still using dreamweaver... I like it, mostly because I do know how to use it...

Is Aptana better ?

[eluser]OverZealous[/eluser]
@NachoF
Oh, that's what you meant. I misunderstood. I thought you were referring to editing DMZ itself! :lol:

Aptana does provide Control/CMD+Space drop-downs as you type, and for just about anything it can figure out. This includes constants, classes, etc. Works great for normal classes, and most of CodeIgniter. Just make sure the classes are visible in your project.

However, it still can be an issue, if you are dealing with dynamic classes, such as the way CodeIgniter loads Libraries, or DMZ loads Extensions, or if you are creating a class from a variable. (PHP is so dynamic that sometimes, nothing can predict what a variable will contain!)

Also, I never use the HTML Helper. I think it makes it significantly harder to read code. I have a different opinion on form fields, but those have a lot of boilerplate.

It is a bit of work to get started with Aptana. I find the best way to start with an existing project is to browse to it in the File view, right-click on the folder and choose Promote to Project. It doesn't change anything, but it does add a .project file, and .settings folder. Also, if you want to know how to set up synchronization between two local folders (e.g.: my server is mounted as a shared drive), PM me and I'll write it out for you.

@Poetawd
Better is totally relative. Smile I would never go back to using DreamWeaver for editing code. It has too many quirks, and doesn't do much as an IDE. Aptana (and similar editors) are extremely powerful, but they come from the world of Software IDEs. This means that they can be very confusing, with tons of options.

[eluser]NachoF[/eluser]
Ok, I just tried my install of Eclipse with ( I think ) some PHP plugin...

I have this Datamapper Class Student which just has id, name

the dropdown has a bunch of methods I can choose from when I do this

Code:
Student $student=new Student();
$student->ctrl+space
but the only one that resembles what Im looking is something like
Code:
_get_by($field,$value);
also, say I already have the object instantiated, like so:
Code:
Student $student=new Student();
$student->get_by_id(1);
I would like to be able to do
Code:
$student->ctrl+space
and have the option to get the name or the id... but its not working.... I also noticed that if I do it manually then the other objects WILL provide me the option... but its obviously because I did it before and not because its getting it from the class itself......
correction: This is for methods.. attributes like Name, or id are NEVER provided in the dropdown
are you sure Aptana does provide you with the correct options>?

Maybe you are right that since php is dynamic its got no way of knowing.

[eluser]OverZealous[/eluser]
@NachoF
Aptana does a better job than most things. However, there is just no way for any IDE to fill in virtual methods or properties such as:
• get_by_XXX
• where_related_XXX
• like_join_field
• save_related_XXX
• related objects
• etc.

The reason is that these are created at run-time, and so a static parser will never find them.

That's the drawback of highly dynamic code! (Well, that and debugging is a PITA.)

[eluser]PoetaWD[/eluser]
I just downloaded Aptana and.... I will stay with DW ... at least for now... Tongue

My head is already fried with PHP... I cant imagine myself learning how to use a editor + the language

I have a question... not really a question... just want to know the better way to do this:

Update a Advanced Relationship:

I did:

Pass the ID of the related object with post:
Code:
echo form_hidden('idCpf', $objeto->cpf_id);
                echo form_hidden('idRg', $objeto->rg_id);

Controller:

Load the object and update it:

Code:
if($this->input->post('stCPF') != '')
            {
                $cpf = new Documento();
                $cpf->where('id', $this->input->post('idCpf'))->get();    
                $cpf->stNumero = $this->input->post('stRG');    
                $cpf->save();                
                $obj->save($cpf, 'cpf');                                            
            }
            
            if($this->input->post('stRG') != '')
            {
                $rg = new Documento();
                $rg->where('id', $this->input->post('idRg'))->get();    
                $rg->stNumero = $this->input->post('stRG');                
                $rg->save();                
                $obj->save($rg, 'rg');                
            }

This is the first module of my program... I want to use the best techniques to have a good code !

Thanks again,

See ya

[eluser]OverZealous[/eluser]
@Poetawd
Well, that might be correct (I'll get to the 'might be' in a second). Alternatively, you might want to accumulate all of the objects that need to be saved into an associative array, and save it all at once:
Code:
$profile = new Profile();
$profile->name = ... // set up profile, if necessary, or load in the existing one

$save_objects = array();

if($this->input->post('stCPF') != '')
{
    ...
    $save_objects['cpf'] = $cpf;
}

...

$profile->save($save_objects);

This will save your ITFKs at the same time as saving your $profile, eliminating one step.

But before saying it is OK, you have to ask yourself, can this be used to subvert my application?

Basically, you cannot trust any information that comes from the browser. I can easily modify the content dynamically and send a different idRg and idCpf than you sent. So, if your system allows for different users, and these users have different access rights, you need to validate every single piece of information you get from them.

For example, my application has multiple Company Accounts, and each company has multiple users. I have to make sure that not only each object belongs to the company of the logged in user, but that the logged in user has access rights to each object.

Again, this is different for every application, but you need to be aware of it. It makes me nervous when I see code that takes IDs directly from a POST and assumes they are safe. I'm always going to harp on this when I see this kind of code ;-)

---

As for Aptana, like I said, it's a complete IDE, so it can be overwhelming if you aren't used to it. I developed for about 5 months using DreamWeaver. I switched to a real IDE and my productivity had to have doubled.

[eluser]NachoF[/eluser]
I think you can just do:
Code:
if($this->input->post('stCPF'))
no need to compare.. it returns false if it has no value...

also... instead of using where.... its easier to do
Code:
$cpd->get_by_id($this->input->post('idCpf'));
dont you think?

One last thing... when is $obj being created?

[eluser]macigniter[/eluser]
forgive me if this has been asked before, but i didn't find it in the user guide.

is it possible to query a field that is NULL? like:

Code:
$e = new Example();
$e->where('some_field', NULL);
$e->get();

looks like that doesn't work. but is there a way to make it work? or is the only solution to set a default value in the table and query for that?




Theme © iAndrew 2016 - Forum software by © MyBB