Jul
29
2009
0

MySQL ERROR 1005 (HY000): Can’t create table ‘NameTable.frm’ (errno: 150)

This error 150 means “MySQL error code 150: Foreign key constraint is incorrectly formed”

So the common problem occurs if you try to create a new table with a foreign key without the table source FK (the source table doesn’t exist into DB ), the solution is create first the table source of the FK and then the another one.
or
Disable constraints check with:

SET FOREIGN_KEY_CHECKS = 0;

To enable check constraints

SET FOREIGN_KEY_CHECKS = 1;

Written by doutdex in: Base de Datos | Tags:
Jul
29
2009
0

Adodb PHP simple access to MySql – Oracle – Interbase

PHP’s database access functions are not standardised. This creates a need for a database
class library to hide the differences between the different databases (encapsulate the
differences) so we can easily switch databases.

Requires PHP4. Based on the best ideas of PEAR, phpdb and Microsoft’s ADO.

MySQL Usage:

include('adodb.inc.php');
ADOLoadCode('mysql');
$conn = &ADONewConnection();
$conn->PConnect('localhost','userid','password','database');
$rs = $conn->Execute('select * from table');
rs2html($rs); /* recordset to html table */

(more…)

Written by doutdex in: Uncategorized | Tags: ,
Jul
28
2009
0

UNIX Crontab

Introduction

cron is a utility that you can use to schedule and automate tasks. By defining items in the cron table, called crontab, you can schedule any script or program to run on almost any sort of schedule.

For example, run a program each day 5 minutes after midnight on mondays, wednesdays and fridays. Or schedule something to run every five minutes, or once a month.

Basics

Each user has their own crontab, the scheduled scripts run as that user take this in account with regards to permissions. To edit the crontab use the following command:

crontab -e

You can list what your currnet crontab is using the following command:

crontab -l

Crontab Format
The following is the format entries in a crontab must be. Note all lines starting with # are ignored, comments.

Written by doutdex in: Uncategorized |
Jul
12
2009
1

Timestamp en php y mysql

Es algo común tener que estar guardando fechas en la base de datos, sin embargo, es recomendable definir cual será la fuente para la base del tiempo, es decir, puede que pase que existen dos servidores el primero que mantiene a la aplicación y el segundo que tiene a la base de datos y podría pasar en el caso que no estén sincronizados por un servidor npt que el tiempo difiera y en el caso más pesimista hasta que en una haya cambiado la zona horaria y en el otro no.
Esto pasa al momento de obtener el tiempo para guardarlo en la base de datos, en el caso que obtengamos el tiempo usando una función en PHP estaremos obteniendo el tiempo del servidor que mantiene a la aplicación PHP, en el caso que dentro del QUERY la función NOW() esta corresponde a MYSQL y en este caso se retornala fecha y tiempo del servidor de la base de datos.

Lo correcto es definir al sistema u aplicación bajo uno de los dos para el efecto de llevar el tiempo y zona correcta.

CASO PHP:

Al crear dentro de una tabla MYSQL un campo del tipo DATETIME
Para poder insertar la fecha y tiempo en el formato (por defecto) correcto de MySQL usando PHP se hace con

Guardar en MySQL usando función de tiempo PHP
< ?

 date('Y-m-d H:i:s', time());

?>

Recuperar fecha MySQL en una variable PHP

Se debe usar la función srttotime

 $phpdate = strtotime( $fechaFromMySQL );

CASO BD:
En este caso dentro del insert en el lugar del valor del campo datetime se utiliza la funcion now()

ejm:

 INSERT INTO usuario VALUES ( 'juan','perez',now());

Referencias:

bigroom

Written by doutdex in: Uncategorized | Tags: , , ,

TheBuckmaker.com Wordpress Themes | Geld von Privat, Streaming Audio