Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1063869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:50:56+00:00 2026-05-16T18:50:56+00:00

I am trying to add some administration scripts to a Zend Framework project, that

  • 0

I am trying to add some administration scripts to a Zend Framework project, that will end up being run nightly via cron.

However I’ve hit my first problem with the script when trying to use Zend_Db. I am currently doing a very simple SQL call to get some results and just display them using var_dump() however I get the following error message:

SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

The script so far looks like this:

<?php
chdir(dirname(__FILE__));

error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', 1);
date_default_timezone_set('Europe/London');

//directory setup and class loading
set_include_path('.' . PATH_SEPARATOR . '../library/' . PATH_SEPARATOR . '../application/models/'
                    . PATH_SEPARATOR . '../library/MyApp/'
                    . PATH_SEPARATOR . get_include_path());

include "Zend/Loader/Autoloader.php";

$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->setFallbackAutoloader(true);

//start sessions
Zend_Session::start(); 

//read configuration data
$config = new Zend_Config_Xml('../application/config/config.xml', 'app');

//we create an ability to capture errors and write them to an error log if there are problems.
$log = new Zend_Log();
$writer = new Zend_Log_Writer_Stream($config->log->logfile);
$log->addWriter($writer);
$filter = new Zend_Log_Filter_Priority((int)$config->log->level);
$log->addFilter($filter);

//we now need to get the list of graduates that need to have their CV's removed from the search engine
$date = new Zend_Date();
$date->sub(3, Zend_Date::MONTH);

echo $date->get(Zend_Date::ISO_8601);

$sql = "SELECT userid, guid FROM users WHERE lastlogin = ? AND active = 1";

$db = Zend_Db::factory($config->database);
try{

    $results = $db->fetchAll($sql, $date->get(Zend_Date::ISO_8601));

    var_dump($results);

}catch(Zend_Db_Exception $dbe){

    $log->debug($dbe->getMessage()."\n".$dbe->getTraceAsString());

}


//close database.
if($db->isConnected()){
    $db->closeConnection();
}

What am I missing? I know that the database connection settings in the Zend_Config object works and the web application is running fine with no issues.

I am running this using Zend Framework v1.7.6 at present.

Also are there any generic tips for using the Zend Framework in a cli script?

Many thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:50:57+00:00Added an answer on May 16, 2026 at 6:50 pm

    PHP will try to connect to mysql via tcp/ip, unless the mysql server is on the same machine as the script and “localhost” is used as the db host. Then it will use a filesystem socket.

    It could be that mysql cannot create /tmp/mysql.sock due to permissions, or that it’s not configured to do so. The Mysql manual should have more on that.

    A quick way to get around this for now should be to change the db host in your Zend_Db settings to an actual ip mysql listens on, not “localhost” or “127.0.0.1”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying add some implicit rules in CMake that will generate direct dependencies (like
I'm trying to write a console application that will run and remove/add items to
I am trying to add some error detection to a script that is used
I have some Zend Framework apps running and it's time to add user access
I'm trying to add some features into my editor that allow to the user
I'm trying add some code at run time to the head element. When I
Im trying to add some short file names to a Wise installer to fix
I was trying to add some non-production test code by creating a 3rd partial
I am trying to add some WebAPI support to my asp.net 4 RC site,
I am trying to add some logic in this. But I am not sure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.