You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MacOS 10.13重建PHP7添加ODBC扩展异常及odbc_connect未定义求助

Hey there, let's tackle your ODBC and PHP7 issues step by step—you've got two main problems here, so we'll break them down one by one:

1. Fixing the Call to undefined function odbc_connect() Error

This error means PHP isn't loading the ODBC extension. Let's start with the simplest checks first:

  • Verify if ODBC is enabled in PHP
    Create a quick phpinfo.php file in your web root with:

    <?php phpinfo(); ?>
    

    Access it in your browser and search for "ODBC". If you don't see any ODBC-related sections, the extension isn't loaded.

    If you installed PHP via Homebrew, you can install the ODBC extension using PECL:

    pecl install odbc
    

    When prompted for the ODBC library path, use /usr/local (for Homebrew's unixODBC) or /Library/ODBC (for ActualTech's driver files).

  • Update php.ini to load the extension
    Find your active php.ini file (check the "Loaded Configuration File" line in phpinfo), then add this line:

    extension=odbc.so
    

    For PHP 7.4+, you can omit the .so suffix: extension=odbc. Restart Apache to apply changes:

    sudo apachectl restart
    
  • Validate ActualTech ODBC Driver Setup
    Open ActualTech's ODBC Manager, confirm your FileMaker DSN is configured correctly, and run a test connection to ensure it works. Also, double-check that the driver architecture matches your PHP build (both should be 64-bit, which is default on High Sierra).

2. Resolving the "Makefile is not as expected" Error When Compiling PHP7

Manual PHP compilation issues often stem from leftover build files, missing dependencies, or incorrect configure flags. Try these steps:

  • Clean up old build artifacts
    Navigate to your PHP source directory and wipe previous builds:

    make clean
    make distclean
    

    This removes outdated Makefiles and intermediate files that might be causing conflicts.

  • Install required dependencies
    Compiling PHP's ODBC support needs unixODBC (even with ActualTech's driver). Install it via Homebrew:

    brew install unixodbc
    

    Also ensure you have other core PHP dependencies like libxml2, openssl, and apr installed—Homebrew usually handles these, but it's worth checking.

  • Configure PHP with correct ODBC flags
    Run the configure script with explicit ODBC path and Apache integration. For example:

    ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/sbin/apxs --with-odbc=unixODBC
    
    • --prefix sets where PHP will be installed
    • --with-apxs2 links to your Apache's apxs (default path on High Sierra is /usr/sbin/apxs)
    • If you want to use ActualTech's driver directly, replace unixODBC with /Library/ODBC
  • Recompile and install
    After a successful configure run, rebuild PHP:

    make
    sudo make install
    

    If you still get errors, check the configure output log for missing library warnings—adjust your flags or install the missing dependencies accordingly.

3. CodeIgniter-Specific Checks

Since you're using CodeIgniter, make sure your database config is set up for ODBC:

  • Open application/config/database.php and verify these settings:
    $db['default'] = array(
        'dsn'        => 'YOUR_FILEMAKER_DSN_NAME', // Match the DSN from ODBC Manager
        'username'   => 'your_filemaker_username',
        'password'   => 'your_filemaker_password',
        'dbdriver'   => 'odbc',
        'dbprefix'   => '',
        'pconnect'   => FALSE,
        'db_debug'   => TRUE, // Enable debug to catch connection issues
        'cache_on'   => FALSE,
        'cachedir'   => '',
        'char_set'   => 'utf8',
        'dbcollat'   => 'utf8_general_ci',
        'swap_pre'   => '',
        'encrypt'    => FALSE,
        'compress'   => FALSE,
        'stricton'   => FALSE,
        'failover'   => array(),
        'save_queries' => TRUE
    );
    
  • Ensure the CodeIgniter ODBC driver files (system/database/drivers/odbc/) are intact and unmodified.

内容的提问来源于stack exchange,提问作者Giuseppe Capoluongo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:10:40