Exemplo n.º 1
0
 /**
  * wrapper para el ejecutor de queries en base de datos
  * @param string $sqlcmd comando sql a ejectuar
  * @param bool $cache usar cache?
  * @param string $table tabla a usar (usada por limpiador de cache luego)
  */
 function execSql($sqlcmd, $cache = null, $table = null)
 {
     $this->data = $this->query($sqlcmd);
     if (!almdata::isError($sqlcmd) && $this->data && (preg_match('/^SELECT/', $sqlcmd) || preg_match('/^SHOW/', $sqlcmd))) {
         $this->num = almdata::rows($this->data);
     }
 }
Exemplo n.º 2
0
$sql_fix = '';
if (almdata::isError($this->data)) {
    #$existe = $this->catalogTableExists($this->name);
    $sqlcmd = "SELECT * FROM {$this->name} LIMIT 1";
    @$this->execSql($sqlcmd);
    if (almdata::isError($this->data)) {
        $sql_fix = genSQL($this->name);
        $this->execSql($sql_fix);
        echo "AUTO SQL {$sql_fix}<br/>\n";
    } else {
        $campos = preg_split('/,/', $this->table_fields);
        foreach ($campos as $campo) {
            #$existe = $this->catalogColumnExists($campo['name']);
            $sqlcmd = "SELECT {$campo} FROM {$this->name} LIMIT 1";
            @$this->execSql($sqlcmd);
            if (almdata::isError($this->data)) {
                list($tmp, $campo) = preg_split('/\\./', $campo);
                $size = isset($this->dd[$campo]['size']) && $this->dd[$campo]['size'] > 0 ? '(' . $this->dd[$campo]['size'] . ')' : '';
                if (!isset($this->key)) {
                    $this->key = false;
                }
                if (!isset($global_dd[$campo])) {
                    $global_dd[$campo] = null;
                }
                if (!isset($global_dd[$campo]['name'])) {
                    $global_dd[$campo]['name'] = null;
                }
                $sql_fix = "ALTER TABLE {$this->name} ADD COLUMN " . genColumnSQL($this->dd[$campo], $dbtype, $global_dd[$campo]['name'] === $this->key) . "; ";
                $this->execSql($sql_fix);
                echo "AUTO SQL {$sql_fix}<br/>\n";
            }
Exemplo n.º 3
0
<?php

#  function check_error($sqlcmd, $extra = '', $die = false) {
if (almdata::isError($sqlcmd)) {
    $error_msg = $this->errors[md5($sqlcmd)];
    if ($extra) {
        $error_msg .= " -- " . $extra;
    }
    $error_msg .= " -- " . $_SERVER['SCRIPT_NAME'];
    if (DEBUG === true) {
        print '<table bgcolor="red"><tr><td>';
        trigger_error(htmlentities($error_msg) . "<br/>\n");
        print '</td></tr></table>';
    }
    error_log(date("[D M d H:i:s Y]") . " Error: " . $error_msg . "\n");
    if ($die) {
        die;
    }
} elseif (ALM_SQL_DEBUG !== false && $extra) {
    $this->sql_log($extra);
}