Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Problem with install script Magento Module
 
diegotxi
Jr. Member
 
Total Posts:  3
Joined:  2012-07-03
 

I can’t get Magento to create a table in the database through an install script. My code is ok I followed the Fundamentals of Magento tutorial and I can’t get the table writen on the database. It says SQLSTATE[HY000] [2002] Can’t connect to local MySQL server through socket ‘/Applications/MAMP/tmp/mysql/mysql.sock’ (38) sometimes when I go back from a page to Magento Home Page. but the shock file is there but not visible and I don’t know how to open it, just when I try to create a new file named mysql.socket it says ‘there is already a file with that name in that folder’ but I can’t see it even with ‘show hidden files’ option enabled in Finder. I am using a Mac Book Pro and MAMP server. My module is working becouse I have a controller showing a message but when I go to my controller page and hit go back. It shows me the error listed above. and There is no register of my module in core_resources table in the data base.
Here is my resources config in etc/config.xml
<models>
<modules>
<Training_Animal>
<version>0.1.0</version>
</Training_Animal>
</modules>
<training>
<class>Training_Animal_Model</class>
<resourceModel>training_animal_resource</resourceModel>
</training>
<training_animal_resource>
<class>Training_Animal_Model_Mysql4</class>
<entities>
<animal><table>training_animal_entity</table></animal>
</entities>
</training_animal_resource>
</models>
<resources>
<training_animal_setup>
<setup>
<module>Training_Animal</module>
<class>Mage_Core_Model_Resource_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</training_animal_setup>
<training_animal_write>
<connection>
<use>core_write</use>
</connection>
</training_animal_write>
<training_animal_read>
<connection>
<use>core_read</use>
</connection>
</training_animal_read>


</resources>

and here is my file Training/Animal/sql/training_animal_setup/mysql-install-0.1.0.php

<?php
$installer = $this;
/*@var $installer Mage_Core_Model_Resource_Setup*/
$installer->startSetup();

$installer->run("

CREATE TABLE `{$installer->getTable('training/animal')}`(
`entity_id` INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(255) NOT NULL DEFAULT '',
`type` VARCHAR(255) NOT NULL DEFAULT '',
`edible` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
`comment` TEXT NULL,
`updated_at` DATETIME,
`created_at` DATETIME
) Engine=InnoDB DEFAULT CHARSET=utf8;
");

$installer->endSetup();
?>

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top