SitePoint Sponsor

User Tag List

Page 8 of 9 FirstFirst ... 456789 LastLast
Results 176 to 200 of 205
  1. #176
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DougBTX
    Perhaps theoretically, but PHP isn't statically typed in the first place. 1 is as good as a True, so just store a 1 or a zero in the DB and you don't need to worry about typing.
    You may not worry yourself but most developers worry with the space that each field takes. Most databases store integers by default as 64 bits. So each integer takes 8 bytes of space. This is why many developers use CHAR(1) to store booleans as Y/N or t/f on databases that do not provide a native boolean data type.

    So, if you pick an existing database that has boolean fields stored like this, it is going to be ambiguous and you cannot automatically guess with certainty whether CHAR(1) is a boolean or a text field limited to 1 character.


    Quote Originally Posted by DougBTX
    Considering a foreign key doesn't even need to be an integer, looks like you'll need a totally different method. Rails uses naming conventions, so a foreign key would look like other_table_id. How does Metabase gather this info? Is it all done manually?
    Metabase does not have to guess which are the foreign keys because it is just a database abstraction package. The scheme reverse engineer support is meant only to recover a schema definition. Whether an INTEGER is a foreign key or not is not relevant as it will always be mapped to an INTEGER.

    If the goes was to recover a data object class schema for Metastorage, which is a persistent object generator tool, that would be a problem yes, and the solution is to let the develop fix it any wrong guesses once. Obviously this would not be thing being done at runtime, but rather at development time.

    Quote Originally Posted by DougBTX
    When is data type mapping needed for PHP? PHP is dynamically typed... is it just for form generation?
    You need to know what is the type of data being stored in each field. A string '1' is not the same as an integer 1.
    Manuel Lemos

    Metastorage - Data object relational mapping layer generator
    PHP Classes - Free ready to use OOP components in PHP

  2. #177
    ********* Victim lastcraft's Avatar
    Join Date
    Apr 2003
    Location
    London
    Posts
    2,423
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi...

    Quote Originally Posted by DougBTX
    Perhaps theoretically, but PHP isn't statically typed in the first place. 1 is as good as a True, so just store a 1 or a zero in the DB and you don't need to worry about typing.
    It's even worse than this. Often you will find "Y"/"N" or "T"/"F" used for booleans. All of these evaluate to true and both set-ups require human intervention . SQL has a pretty lousy type system when it doesn't have booleans.

    yours, Marcus
    Marcus Baker
    Testing: SimpleTest, Cgreen, Fakemail
    Other: Phemto dependency injector
    Books: PHP in Action, 97 things

  3. #178
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lastcraft
    It's even worse than this. Often you will find "Y"/"N" or "T"/"F" used for booleans. All of these evaluate to true and both set-ups require human intervention . SQL has a pretty lousy type system when it doesn't have booleans.

    yours, Marcus
    And pitty the poor developer who comes into a shop with a "Y"/"N" convention who changes a particular indicator to "1" and "0" to make it easier to sum


    Not that I would be talking about anyone in particular...

  4. #179
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A lot of talk for only CHAR(1). Something as trivial as preg_match('/[YT1]/i', $obj->field) solves it. Any type stored in a database will have the same problems and require team communication (define() work well).

    But what other actual problems with types beyond the Y/N, T/F, 1/0 problem are there really. Dates? Foreign keys?

    If there are only a couple then you can build-in help for those. For example you could implement a system for installable types where you could pass it a translation object like:
    PHP Code:
    class TypeTranslator {
    var 
    $type;
    var 
    $table;

    function 
    TypeTranslator ($type$table) {
      
    $this->type $type;
      
    $this->table $table;
    }

    function 
    translate ($value) {
      return 
    $this->table[$value];
    }

    }

    $translator = new TypeTranslator ('CHAR(1)', array('Y'=>true'y'=>true'T'=>true't'=>true'1'=>true'N'=>false'n'=>false'F'=>false'f'=>false'0'=>false));

    // then within system
    foreach ($this->translators as $translator) {
      if (
    $field->type == $translator->type) {
        
    $field->value $translator->translate($field->value);
      }

    Christopher

  5. #180
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lastcraft
    It's even worse than this. Often you will find "Y"/"N" or "T"/"F" used for booleans. All of these evaluate to true and both set-ups require human intervention . SQL has a pretty lousy type system when it doesn't have booleans.
    OK, all we can assume is that there needs to be some translation on a per column basis. That's two problems:

    1) How do we store them?
    2) How do we apply them?

    1. Metabase looks like it stores them in an XML file. My problem with this is that it separates the definition of the translation from the translation itself. I'd much rather store the translation as PHP code. This is the format will do the work, and it means that we won't need to worry about it. What if someone stored data in the DB as using "Yes", "No", "Incomplete"?

    Using PHP will let the user do whatever they want, using XML will give them more to learn and more code to write if they want something non-standard (dates for example). The core of the DB layer would only need to understand what the DB can give it, which sould make life easier than trying to second guess the developer.

    2. From what I've read on Meta, the classes are generated from the XML files, then the user can extend them, is that right mlemos? Is the aim of this project still to create a system that can hibernate a class without taking over the parent of the said class? Has there been any consensus on how this should be done? (I don't remember any) I'm gussing some generation is going to have to happen, if so, how is the developer's code going to interact with this code?

    One possibility which I've not seen talked about would be code like this:

    PHP Code:
    class Person {
        var 
    $job "person";
        function 
    show_job() {
            echo 
    "Hi, I work as a {$this->job}.";
        }
    }


    class 
    Bartender { var $job "bartender"; function show_job() { echo "BARTENDER: "Person::show_job(); } } $b = new Bartender$b->show_job(); 
    from: Mixins for PHP

    Because the Person class will have access to $this from the Bartender class, it might be possible for Person to fill the Bartender's private data. If this "hydation" (to use Propel's language) could be applied in the constructor, then very little change would need to be made to the class. A similar "dehydrate" function could be called from the destructor, which could compare a hash of the inital data that it put in, and the final data that came back out, to see if anything that needs to be saved. Any translation code (whether derived from an XML file ala Meta, or through a PHP translate class of some sort) could be transparently applied using this method.

    The only problem is telling the class what data it should contain. What are the current ideas on this?

    Douglas
    Hello World

  6. #181
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arborint
    A lot of talk for only CHAR(1). Something as trivial as preg_match('/[YT1]/i', $obj->field) solves it. Any type stored in a database will have the same problems and require team communication (define() work well).
    That is not that simple. The problem is that no automatic program can guess whether the original developer meant that CHAR(1) be a boolean or an actual text field of only one position. Furthermore there is oftten the habit of using CHAR(1) for enumerated types that have more than two options. H

    Having a automated mapping tool querying database at runtime for the field types not only is not reliable because it can be ambiguous, but also is a waste of performance to do something at runtime just to query metadata that is not changing.

    I think the most viable solution is to depart from a reliable definition in a XML format or something easy to generate and parse by any progra, so the developer can validate at development time to make sure nothing was misunderstood.

    Quote Originally Posted by arborint
    But what other actual problems with types beyond the Y/N, T/F, 1/0 problem are there really. Dates? Foreign keys?
    Forget it. Once you start using anything else besides MySQL, you will see that it is pointless. Just try for instance Oracle, so you can see the kinds of headaches that you would face.

    Besides the fact that with Oracle the concept of multiple databases is different because it means different servers, and also the fact that it stores NULL in the place of empty text field values, which are problems that would not affect this, there is is the real problem that in Oracle there is only one type to store dates, times and time stamps.

    For a greater overview of the problems that you will face when trying to access different types of databases, take a look at the Metabase reference manual, specifically at the notes sections of the Available drivers topic and also at Known conformance failure issues.
    Manuel Lemos

    Metastorage - Data object relational mapping layer generator
    PHP Classes - Free ready to use OOP components in PHP

  7. #182
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arborint
    For example you could implement a system for installable types where you could pass it a translation object
    The problem with the example is that it is only one way translation. You want to be able to store data in the database too, right?

    The principle behind what I was talking about before would have the translation layer decorate the normal table access class:

    PHP Code:
    class MyTableTranslationLayer {

      function 
    getMyField() {
        return (
    'Y' == $this->my_field);
      }

      function 
    setMyField($value) {
        
    $this->my_field $value 'Y' 'N';
      }

      function 
    __call()
        
    // fall through code of some sort
      
    }


    I'm getting the feeling that PHP isn't flexible enough to make a really nice solution, though I'm sure we can get something better than a "shove everything in an XML file" solution too.

    Douglas
    Hello World

  8. #183
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Brenden Vickery
    One thing may be data types in the database. Is a Timestamp is mysql the same as a timestamp in oracle? Im not sure about all the idiosyncrasies of each database.
    Yes, they probably will be different, that's why you'd have to translate the SQL. But if something is a string, I'm sure it can stay a string regardless of which database it comes from. One might use CHR(250) and another may use CHAR:250, but I'm sure most of this could be fixed with creative use of regexes. For DB specific fields such as dates, reflection should be able to tell you if a field is stores a date or not. You should be able to tell the transport script that you are moving from XYZ DB to ABC DB, and as both fields will contain the same data (a date) it should be possible to translate back. Bigger problems would be when moving from, say, a DB with Boolean support to one without. At least in MySQL, I know it is possible to add a "notes" piece of data to a Database. Perhaps this data ("column MyDate is a Date.") could be stored there incase you wanted to move back to the original database. What other things are there which need translating?

    Anyone fancy writing a script to do this? It should be standalone and self contained, and Marcus suggested that it go in the first iteration anyway. First step would be to get some code to dump the DB to an SQL file. Probably easiest to start with nicking some code from phpMyAdmin, then refactor if it isn't beautiful enough [edit: meh, just took a look as the phpMyAdmin code - I take back the above beautification comment - it is beyond me to refactor that code!]

    Douglas
    Hello World

  9. #184
    SitePoint Guru
    Join Date
    Nov 2002
    Posts
    841
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I had the opportunity to re-read the first 300 pages of PoEAA today in the hospital waiting room. I also re-read this entire thread. I just wanted to summarize some thoughts on the POPO approach while they are in my head.

    POPO: Plain Old PHP Objects
    This is the analog of the hibernate approach where there are no base object inheritance or required persistence layer calls in the domain model.

    PROS:
    • Simple domain model.
    • Flexible domain model.
    • No PHP 4 or PHP 5 requirements on the domain model.


    CONS:

    • Determining which objects are dirty requires iterating over known objects and comparing them to a previous snapshot.
    • All persistent properties must be public or have public accessors in PHP 5.
    • The lazy initialization and the ghost techniques for implementing lazy loading are unavailable. This leaves value holder and virtual proxy. value holder seems a poor choice for PHP. That leaves the virtual proxy technique. Virtual proxy may have identity problems. How completely can one object be a proxy for another in PHP5 with __set, __get, and __call? Proxies might also be code generated for PHP4 compatibility.
    • All object properties must be loaded every time, since there are no lazy load options which can partially load an object. This might have performance implications for complex inheritance mappings where a particular class is split across different tables.


    I don't see any fundamental reason why a POPO approach couldn't be done in PHP. It may or may not be the best fit, but it could be done.

    It seems to me like the decision to use POPOs is binary. You do or you don't. It also seems to me like you can hardly say you are porting hibernate if you don't go the POPO route.

    Have I missed anything?

  10. #185
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mlemos,

    Do you have a UI for using your software? Also I've looked at the links for Metabase and I had a servere problem following the navigation. I just gave up on it I suppose, I would suggest that you compile the documentation into a more suitable format such as a PDF, a Compiled Help Module and if you have the time, as PHP Documentor format for online browsing

    If you want folks to use your software then please allow us to learn easily how to use the software, thank you.

  11. #186
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dr Livingston
    Do you have a UI for using your software?
    Which software? Metabase, Metastorage, what?

    If you mean Metastorage, it comes with a Web interface to compile Metastorage projects named Webstorage. It is not really a UI for editing your persistent object classes, but rather a way to provide a Web interface to process the persistent object class definitions without having to run Metastorage from the command line.

    If you mean an UI for doing other tasks, currently there is not anything but it is something that is suggested to other users that would like to contribute to the project with something that would be useful to many people and would not depend on the developments of Metastorage itself.

    Quote Originally Posted by Dr Livingston
    Also I've looked at the links for Metabase and I had a servere problem following the navigation. I just gave up on it I suppose, I would suggest that you compile the documentation into a more suitable format such as a PDF, a Compiled Help Module and if you have the time, as PHP Documentor format for online browsing
    I am not sure what problems did you have to follow the navigation. Metabase comes with over 300K of documentation including a tutorial both in English and Portuguese.

    The documentation is HTML. I don't know what would be so different with a PDF version that would make it so much better.

    As for online browsing versions, they are available in several places besides where I mentioned, like for instance here.
    Manuel Lemos

    Metastorage - Data object relational mapping layer generator
    PHP Classes - Free ready to use OOP components in PHP

  12. #187
    SitePoint Enthusiast hantu's Avatar
    Join Date
    Oct 2004
    Location
    Berlin
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Selkirk
    POPO: Plain Old PHP Objects
    Off Topic: hope this acronym doesn't become standard, because Popo is a german word for ***

  13. #188
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe POPHOs would be better then.
    Christopher

  14. #189
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by hantu
    Off Topic: hope this acronym doesn't become standard, because Popo is a german word for ***
    imo that's exactly the sort of problem you'll end up with copying things directly from Java to PHP, a load of Popo!

    Douglas
    Hello World

  15. #190
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear developers,

    We have open-sourced an object-relational mapping (ORM) and object persistence framework for PHP, called EZPDO. You can check it out at http://www.ezpdo.net if you are interested.

    Currently it only supports PHP5. We will consider the possibility of backward compatibility if there is a serious need from the community.

    Here is a list of features EZPDO has.
    * Minimum SQL knowledge required
    * Requires minimum ORM specification
    * No Phing! No need of explicit command line compile
    * Works with existing code and database
    * Has a small runtime core to guarantee performance
    * Handles 1:N, and M:N relationships automatically
    * Provides a simple runtime API
    * Supports object query (EZOQL)
    * Auto generates database tables
    * Test-driven with continuous integration

    With EZPDO, you can specify ORM in a way much like XDoclet - you insert mapping spec into the comments with a special custom tag. EZPDO auto-generates tables from your ORM spec. (XML specification is also planned.)

    The compiling of the ORM tags is triggered the first time you persist an object using the persistence manager or you have modified your class file since the last compile. So no excessive compiling to hurt performance. (Offline compile script is also available.)

    It also has a tiny object query language called EZOQL, which basically resembles the standard SQL select statement, but is much simpler.

    The biggest strength as we see in EZPDO as an ORM/persistence package is its capability of handling object relationships. It does not ask you to create auxiliary association classes or tables. It handles 1:N and M:N relationships automatically.

    EZPDO is still in its alpha stage and we'd like hear what you think. Thank you.

    Oak Nauhygon <ezpdo4php@gmail.com>
    URL: http://www.ezpdo.net

  16. #191
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    Bogota
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've only seen the tutorial. It looks quite nice!
    If I have wings, why am I walking?

  17. #192
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    Australia
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks very interesting, I tried to run the tests but ran into many problems. Try turning on E_NOTICE.

    Also, i couldn't get it to work with sqlite.

    Wei.

  18. #193
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by wei
    Looks very interesting, I tried to run the tests but ran into many problems. Try turning on E_NOTICE. Also, i couldn't get it to work with sqlite.
    Wei.
    Thanks for trying, wei. Without being able to look into the details of the problems you ran into, I can only guess. It might be that you had not set up your database. Our fault - we did not put that bit in the test page. We have just updated the test page (http://www.ezpdo.net/blog/?p=4). Please take a look. See if it helps. Let us know how it goes.

    We'd also like to encourage you and everyone else trying EZPDO to use our bug tracking system (http://www.ezpdo.net/bugs/) and make comments on specific docs at http://www.ezpdo.net (so that you can get our attention quickly).

    Thank you.

    -oak
    Last edited by nauhygon; Mar 16, 2005 at 03:53.

  19. #194
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Taking a brief look without delving too deep I think this could be interesting as well. The thing I like about it and what could make me more interested in fact, is this part below,

    No Phing!
    But what I have to ask is that what form of standards does the OQL follow? I must admit I did not seek more information on this point, but if it's there on your site, I'll find it

    I think if you follow standards (ala Java's Hibernate for example) this will help bring more people to use your scripts. What could put a lot of people off, is if they have to learn another language?

    Anyways, well done. Got my vote

  20. #195
    SitePoint Zealot sike's Avatar
    Join Date
    Oct 2002
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi,

    browsed the code and it looks quite nice. but trying to get it running was impossible (at least for me). i got several errors and exceptions. just try your scripts with full error reporting and "allow pass by reference : off" and you will see what i mean. if you could rework the examples so that i don't need to create a mysql user and stuff i will take a deeper look.

    cheers
    Sike

  21. #196
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dr Livingston
    But what I have to ask is that what form of standards does the OQL follow? I must admit I did not seek more information on this point, but if it's there on your site, I'll find it

    I think if you follow standards (ala Java's Hibernate for example) this will help bring more people to use your scripts. What could put a lot of people off, is if they have to learn another language?

    Anyways, well done. Got my vote
    The OQL in EZPDO is a part we have been constantly working on recently. Yes we plan to follow some standard and at the same time want to make it just as simple as possible so people can pick it up really quickly. We have been keeping a close eye on what Hibernate has in this regard. Please find more info on EZOQL at http://www.ezpdo.net/blog/?p=841.

    Thanks for your vote.

  22. #197
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sike
    if you could rework the examples so that i don't need to create a mysql user and stuff i will take a deeper look.
    Thanks for your time trying EZPDO. We will rework the example to make it easier. Will let you know once it's ready.

  23. #198
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sike
    i got several errors and exceptions. just try your scripts with full error reporting and "allow pass by reference : off" and you will see what i mean.
    This should have been taken care of now. With the testing framework we have, we were able to make the fixes quickly. Thank you and wei for pointing this out. Please download the latest at http://www.ezpdo.net/releases/ezpdo.latest.tar.gz.

    Quote Originally Posted by sike
    if you could rework the examples so that i don't need to create a mysql user and stuff i will take a deeper look.
    We have removed the class-level orm tags in the example classes. This would force EZPDO to look for the default DSN to store all classes. So if you have a database ready, there is only one line in the configuratoin file (config.xml under examples/books) you need to change. See this (http://www.ezpdo.net/blog/?p=5#database_setup) for a little more details.

    We have only tested EZPDO extensively with MySQL so far. [Warn: wei kindly pointed out there may be potential problems with SQLite. We are currently looking into the problem.]

    Hope this will get you started. Please let us know what you think and what you'd like us to improve. Thank you!
    Last edited by nauhygon; Mar 16, 2005 at 04:46.

  24. #199
    SitePoint Zealot sike's Avatar
    Join Date
    Oct 2002
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi,

    the parsing errors are gone but the examples still have their dsn settings (removed the for testing). still no luck. i get the following error :

    Code:
    Fatal error: Nesting level too deep - recursive dependency? in E:\Web\sandbox\ezpdo\ezpdo.2005-03-16\src\runtime\epObject.php on line 381
    Call Stack
    #	Function	Location
    1	{main}()	E:\Web\sandbox\ezpdo\ezpdo.2005-03-16\examples\books\timing.php:0
    2	epObjectWrapperBase->__set()	E:\Web\sandbox\ezpdo\ezpdo.2005-03-16\examples\books\timing.php:91
    3	epObjectWrapperBase->epSet()	E:\Web\sandbox\ezpdo\ezpdo.2005-03-16\src\runtime\epObject.php:563
    Variables in local scope (#3)
    Variable	Value
    $var_name_ = 	
    
    'books'
    
    $value = 	
    
    &array
    
    $var_name = 	
    
    'books'
    cheers
    Sike

  25. #200
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sike
    still no luck. i get the following error :
    sike, thanks for reporting the problem. have entered it into our bug tracking system (http://www.ezpdo.net/bugs/index.php?do=details&id=7) for further investigation. (just don't want to abuse this thread.). we have set the priority to be high. we may need a little help from you to get more info so we can figure out what the problem really is. thank you.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •