Неустранимая ошибка при создании оболочки, которая должна подключаться к базе данных - PullRequest
1 голос
/ 23 апреля 2009
Fatal error: Call to undefined function mysql_connect() in
/opt/lampp/htdocs/cake/cake/libs/model/datasources/dbo/dbo_mysql.php on line 370

//shell
<?php

class ReportShell extends Shell
{
    var $uses = array('Customer');
    function main()
    {
            $customers = $this->Customer->find('all');
            var_dump($customers);
            $this->out('lol my first CakePHP shell is baked');
    }
}

?>

//model
<?php

class Customer extends AppModel
{
    var $name = "Customer";
    var $useTable = "customer";
    var $hasMany = array
    ('CustomerPrice',
     'Order' => array('foreignKey' => 'customer_id'));

    // Validation settings
    var $validate = array(
            'customer_id' => array(
                    'rule' => 'numeric',
                    'message' => 'A customer ID should be numeric !'
            ),
            'customer_number' => array(
                    'rule' => 'numeric',
                    'message' => 'A customer number should be numeric !'
            ),
            'customer_name' => array(
                    'rule' => 'notEmpty',
                    'message' => 'A customer number should be numeric !'
            )
    );


    /**
     * Function to retrieve Customer data
     *
     * @param string $response_type - CakePHP find() type
     * @param array $response_setting - CakePHP find() parameter array (set$
     * @param int $customer_id - Find customer by customer ID
     * @param int $customer_number - Find customer by customer number
     * @param string $customer_name - Find customer by customer name
     * @param int $customer_billing_month - Find customer by customer billi$
     * @param int $customer_start_date - Find customer by start date
     * @param int $customer_end_date - Find customer by end date
     * @param string $customer_email - Find customer by customer e-mail
     */
    function FjmCustomerGetCustomer($response_type, $response_setting = arr$

            /* Conditions: Find Customer by customer data */
            if($customer_id)
            {       $response = $this->Customer->findByCustomerId($response$
            if($customer_number)
            {       $response = $this->Customer->findByCustomerNumber($resp$
            if($customer_name)
            {       $response = $this->Customer->findByCustomerName($respon$
            if($customer_billing_month)
            {       $response = $this->Customer->findByCustomerBillingMonth$
            if($customer_start_date)
            {       $response = $this->Customer->findByCustomerStartDate($r$
            if($customer_end_date)
            {       $response = $this->Customer->findByCustomerEndDate($res$
            if($customer_email)
            {       $response = $this->Customer->findByCustomerEmail($respo$

            if(!$customer_id || !$customer_number || !$customer_name || !$c$
            {       $response = $this->Customer->find('all', $response_sett$

            return $response;
    }

    /* FjmCustomerGetCustomerByProduct
     * FjmCustomerGetCustomerByOrder
     * FjmCustomerGetCustomerByBill
     * FjmCustomerGetCustomerByHandle
     */
}

?>

//database config php
    var $default = array(
            'driver' => 'mysql',
            'persistent' => false,
            'host' => 'localhost',
            'login' => 'root',
            'password' => 'pwd',
            'database' => 'fjm_pps',
            'prefix' => 'fjm_',
    );

Ответы [ 3 ]

5 голосов
/ 23 апреля 2009

«Неустранимая ошибка: вызов неопределенной функции mysql_connect ()» означает, что в вашу установку PHP не включены библиотеки MySQL.

Проверьте ваш php.ini и убедитесь, что расширение mysql активировано. «Extension = mysql.so» (или «extension = php_mysql.dll») необходимо раскомментировать.

Google для получения помощи по включению библиотек MySQL, включенных в вашу установку PHP.

4 голосов
/ 23 апреля 2009

Также обратите внимание, что в некоторых установках (на ум приходит Debian), если не во всех, cli-php и apache-php имеют отдельные php.ini: s. Таким образом, включение mysql в одном не обязательно помогает в другом. Используйте phpinfo (), чтобы узнать, где он ищет php.ini.

1 голос
/ 23 апреля 2009

Ответ таков: расширение для mysql в php cli не было активировано или установлено

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...