SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: Zend Framework

Hybrid View

  1. #1
    Non-Member
    Join Date
    Oct 2008
    Posts
    372
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Zend Framework

    Hey,

    I'm experimenting with the ZF but I'm having issues. I thought that I had fixed it, but after a quick test, I can see that it doesn't work. What I'm trying to accomplish is to use the framework by just using:

    PHP Code:
    require_once 'Zend/Loader.php';
    Zend_Loader::registerAutoload(); 
    And then after initiating the Zend Loader continue developmenting, without worrying about the MVC structure.

    PHP Code:
    <?php

    error_reporting
    (E_ALL|E_STRICT);
    ini_set('display_errors''on');

    //include paths
    ini_set('include_path'ini_get('include_path') . PATH_SEPARATOR '../library');
    require_once 
    'Zend/Loader.php';
    Zend_Loader::registerAutoload();

    $connection = new Zend_Db_Adapter_Pdo_Mysql(array(
                  
    'host' => 'localhost2222',
                  
    'username' => 'root2',
                  
    'password' => '',
                  
    'dbname' => 'cms2'));

    if (
    $connection)
      echo 
    'Connected';
    else
      echo 
    'Failed';
    ?>
    I just tried to connect to a database on my localhost and it always displays Connected. The actual host, username, password, and dbname values are, localhost, root, no password, cms. I had changed the values to something random to test it.

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    The construct of a class never returns it's status, so it will neither return true nor false, which is what your checking for.

    You should validate your connection in another manner.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    Non-Member
    Join Date
    Oct 2008
    Posts
    372
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not really sure how to, I'm still new to ZF and I'm still learning what they have available. Could you help me out a bit more?

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $c = new Zend_Db_Adapter_Pdo_Mysql( ... );
    if ( 
    $c->isConnected() )
        print 
    'Connected!'
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    Non-Member
    Join Date
    Oct 2008
    Posts
    372
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That works logic. Thanks.

    Where are you viewing what objects you can call and/or are available to use? I'm looking online in the ZF documentation, and I don't see any objects being called using isConnected().

  6. #6
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    I'm looking in the API documentation which contains every single method and class. However, this documentation is a lot more technical. Top-right hand is a select containing a list of all the packages.

    http://framework.zend.com/apidoc/core/
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  7. #7
    Non-Member
    Join Date
    Oct 2008
    Posts
    372
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    WOW no kidding...

    Thank you

  8. #8
    Non-Member
    Join Date
    Oct 2008
    Posts
    372
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm actually getting a Connection failed when I try isConnected. But the values in the array are correct and the data base already exist. Is there something special I should be looking out for when using PDO?

    PHP Code:
    $connection = new Zend_Db_Adapter_Pdo_Mysql(array(
                  
    'host' => 'localhost',
                  
    'username' => 'root',
                  
    'password' => '',
                  
    'dbname' => 'cms'));

    if (
    $connection->isConnected())
      echo 
    'Connected';
    else
      echo 
    'Connection failed'


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
  •