示例#1
0
 public function testIgnorePriority()
 {
     $insert = new Insert('foo');
     $insert->ignore(true)->values(array('name' => 'hello'));
     list($sql) = $insert->toQuery();
     $this->assertEqualsSql('INSERT IGNORE INTO foo (name) VALUES (:name_0)', $sql);
 }
示例#2
0
文件: Log.php 项目: reekoheek/php-fw
	function log($priority, $message, $file = null, $line = null, $e = null) {
		$schema = "DEFAULT";
		$table = "logs";
		$trace = "";
		if (!empty($e)) {
			$trace = $e->getTraceAsString();
		}
		if (is_object($message)) {
			$message = JSON::encode($message);
		}
		$now = new Date();
		$log = array();
		$log["priority"] = $priority;
		$log["message"] = $message;
		$log["trace"] = $trace;
		$log["file"] = $file;
		$log["line"] = $line;
		$log["createdBy"] = "SYS";
		$log["createdTime"] = $now;
		$log["updatedBy"] = "SYS";
		$log["updatedTime"] = $now;

		$driver = $GLOBALS["CFG_DB"]->CON[$schema]->DRIVER;
		$insert = new Insert($table, $log, $schema);
		$link = DB::connect();
		$success = mysql_query($insert->sql(), $link);
		if (!$success) {
			$result = Bean::invoke(String::camelize('_'.$driver.'_driver'), "error", array($schema));
			throw new Exception("Cannot persist object. ".$result);
		}
	}
示例#3
0
    /**
     * @covers Zend\Db\Sql\Insert::getSqlString
     * @todo   Implement testGetSqlString().
     */
    public function testGetSqlString()
    {
        $this->insert->into('foo')
            ->values(array('bar' => 'baz'));

        $this->assertEquals('INSERT INTO "foo" ("bar") VALUES (\'baz\')', $this->insert->getSqlString());
    }
 public static function singleton_insert()
 {
     if (!isset(self::$instancia)) {
         $miclase = __CLASS__;
         self::$instancia = new $miclase();
     }
     return self::$instancia;
 }
示例#5
0
文件: coreds.php 项目: Eteng/lorb
 function insert()
 {
     pitch("Dodeye.core.db.Insert");
     $data = $this->request->getParam($this->type);
     $xml = simplexml_load_string($data);
     $array_val = ToArray($xml);
     $row_key = key($array_val);
     $row1_key = key($array_val[$row_key]);
     $Insert = new Insert();
     $Insert->into($this->table);
     //@NOTE: peple might send multiple insert
     if (is_numeric($row1_key)) {
         //there are may rows
         $tbl_cols = array_keys($array_val[$row_key][$row1_key]);
         $Insert->columns($tbl_cols);
         $sql = $this->dbcon->prepare($Insert->bindable_sql());
         // foreach ($tbl_cols as $key =>$val)
         // $sql->bindParam($key,$val);
     } else {
         //single entry
         $tbl_cols = array_keys($array_val[$row_key]);
         $Insert->columns($tbl_cols);
         $sql = $this->dbcon->prepare($Insert->bindable_sql());
         foreach ($tbl_cols as $key => $val) {
             $sql->bindParam($key + 1, $array_val[$row_key][$val]);
         }
         //$rs = $sql->execute();
         if ($rs) {
             print "true";
         } else {
             print "false";
         }
     }
     //$sql
     exit;
 }
示例#6
0
            $query_col .= " `" . $key . "` ,";
            $query_val .= " '\".\$_POST[\"" . $value . "\"].\"' ,";
        }
        $query_col = rtrim($query_col, ",");
        $query_val = rtrim($query_val, ",");
        return $query . "( " . $query_col . " ) values (" . $query_val . ");\"";
    }
    public function gen_insert_code($query)
    {
        $code = "<?php\n";
        $code .= "\t\$query\t=\t{$query};\n";
        $code .= "\t\$result\t=\t\$conn->query(\$query);\n";
        $code .= "\tif(\$result === true)\n";
        $code .= "\t{\n";
        $code .= "\t\techo 'Record saved';\n";
        $code .= "\t}\n";
        $code .= "\telse\n";
        $code .= "\t{\n";
        $code .= "\t\techo 'Record Not saved';\n";
        $code .= "\t}\n";
        return $code . "?>";
    }
}
$Insert = new Insert();
$table_name = 'users';
$col_val_arr = array("name" => "name", "age" => "age", "test" => "test");
$query = $Insert->gen_insert_query($table_name, $col_val_arr);
file_put_contents("test.php", $Insert->gen_insert_code($query));
?>

示例#7
0
                $this->db->save($subitem);
                echo "inserted sub item {$i}<br>\n";
                if (!isset($_GET['skip']) || $parentName === 'foo1' && $i % 3 == 1 || $parentName === 'foo2' && $i % 3 == 0 || $parentName === 'foo3' && $i % 3 == 2) {
                    $this->insertSubSubItem($subitem->subItemId);
                }
            } catch (Tsukiyo_Exception $e) {
                echo $e->getMessage();
            }
        }
    }
    function insertItem()
    {
        for ($i = 1; $i <= 3; $i++) {
            $item = new Vo_Item();
            $item->name = "foo{$i}";
            try {
                $this->db->save($item);
                echo "inserted item {$i}<br>\n";
                if (!isset($_GET['skip2']) || $i != 2) {
                    $this->insertSubItem($item->itemId, $item->name);
                }
            } catch (Tsukiyo_Exception $e) {
                echo $e->getMessage();
            }
        }
    }
}
$db->begin();
$insert = new Insert($db);
$insert->insertItem();
$db->commit();
示例#8
0
<?php

if (isset($_POST['button_save_product'])) {
    if (isset($_POST['addProduct_marka'], $_POST['nomer'], $_POST['names'], $_POST['kol'], $_POST['price'])) {
        require '../model/class_connect_db.php';
        require '../model/class_insert.php';
        $insert = new Insert();
        $result1 = $insert->add_product($_POST['addProduct_marka'], $_POST['nomer'], $_POST['names'], $_POST['kol'], $_POST['price']);
        $result2 = $insert->add_img();
        if ($result1 == true) {
            if ($result2 == true) {
                header("Location: ../pages/add_product.php");
            } else {
                echo '$result2';
                return;
            }
        } else {
            echo '$result1';
            return;
        }
    }
} else {
    echo 'ERORR: not detected click on button';
}
示例#9
0
    $roominess = $_POST['roominess_mav'];
} else {
    $roominess = $_POST['roominess_mob'];
}
if (isset($_POST['short_description'])) {
    $short_description = trim($_POST['short_description']);
} else {
    $short_description = NULL;
}
isset($_POST['name']) ? $name = $_POST['name'] : ($name = '');
isset($_POST['price']) ? $cost = $_POST['price'] : ($cost = '');
isset($_POST['weight']) ? $weight = $_POST['weight'] : ($weight = '');
$number_inputs = $_POST['number_inputs'];
$specifications = isset($_POST['text2']) ? $_POST['text2'] : NULL;
$extra_options = isset($_POST['text1']) ? $_POST['text1'] : NULL;
$title = $_POST['title'];
$description = isset($_POST['description']) ? $_POST['description'] : NULL;
$keywords = $_POST['keywords'];
if (!empty($_POST['id_prod'])) {
    $id_prod = $_POST['id_prod'];
    $obj_product = new Update();
    $result = $obj_product->update_product($id_prod, $id_company, $type, $id_water_resistance, $number, $id_category, $id_frame, $name, $cost, $weight, $roominess, $number_inputs, $specifications, $short_description, $serialize_arr_img, $arr_attr, $title, $description, $keywords, $url_video, $color_tent, $extra_options, $related);
} else {
    $obj_product = new Insert();
    $result = $obj_product->add_product($id_company, $type, $id_water_resistance, $number, $id_category, $id_frame, $name, $cost, $weight, $roominess, $number_inputs, $specifications, $short_description, $serialize_arr_img, $arr_attr, $title, $description, $keywords, $url_video, $color_tent, $extra_options, $related);
}
if ($result == true) {
    header('Location:../pages/products.php?id=' . $id_company);
} else {
    echo $result;
}
<!DOCTYPE html>
<html lang="es">
<head>
    <title>Insert Entidad</title>
	<?php 
include 'inc/common_head.php';
?>
</head>
<?php 
include 'inc/function.php';
$function = new Insert();
if (isset($_POST['InsCategoria'])) {
    $ins = $function->insert_categoria($_POST['InsCategoria']);
}
?>

<body>
    <a href="index.php">Home</a><br>
    <a href="graficos.php">Graficos</a><br>
    <a href="insert-entidad.php">Entidades</a>
    <div class="row formulario-ingreso">
        <form role="form" method="POST">
          <div class="form-group">
            <label for="nombreEntidad">Ingrese una nueva Categoria</label>
            <input type="text" class="form-control" id="ejemplo_email_1"
                   placeholder="Nombre de la Categoria" name="InsCategoria" required>
          </div>
          <button type="submit" class="btn btn-default">Insertar</button>
        </form>
        </div>
<!--    Importamos las scripts al final de la pagina-->
示例#11
0
 /**
  * @param Insert $i
  * @param Validation $v
  * @return bool
  */
 function register(Insert $i, Validation $v)
 {
     $i->setTable('')->setKey('')->setValue('')->insert();
     return true;
 }
示例#12
0
 /**
  * INSERT
  * @param $task
  * @param $arguments
  * @param $conditions
  * @return bool
  */
 public function insert($task, $arguments, $conditions)
 {
     $insert = new Insert();
     return $insert->run($task, $arguments, $conditions);
 }
示例#13
0
文件: Adapter.php 项目: shen2/mdo
 /**
  * 
  * @return Insert
  */
 public function insert($keyword = null)
 {
     $insert = new Insert($this);
     if ($keyword !== null) {
         $insert->setKeyword($keyword);
     }
     return $insert;
 }
示例#14
0
                $update->updateData($sql);
            }
            echo json_encode(true);
            return;
        }
    } elseif (is_string($_POST['arr_data'])) {
        $data = $_POST['arr_data'];
        $table = $_POST['table'];
        $field = $_POST['field'];
        if ($table == 'roominess_mav' || $table == 'roominess_mob') {
            $int = (int) preg_replace("/[^0-9]/", '', $data);
            $sql = "INSERT INTO " . $table . "(" . $field . ",int_val) VALUE ('{$data}','{$int}')";
        } else {
            $sql = "INSERT INTO " . $table . "(" . $field . ") VALUE ('{$data}')";
        }
        $insert = new Insert();
        $result = $insert->addInFilter($sql);
        echo json_encode($result);
        return;
    }
}
/*if(isset($_POST['water_resistance']) && !empty($_POST['water_resistance'])) {
    $water_resistance = $_POST['water_resistance'];
    $sql = "INSERT INTO water_resistance(name) VALUE ('$water_resistance')";
    $insert = new Insert();
    $insert->addInFilter($sql);
}

if(isset($_POST['frame']) && !empty($_POST['frame'])) {
    $frame = $_POST['frame'];
    $sql = "INSERT INTO frame_tents(name_frame) VALUE ('$frame')";
示例#15
0
 /**
  * Create a new insert query builder
  * 
  *     $h->table('users')->insert(['name' => 'Lucas', 'age' => 21])
  *
  * @param array                                     $values
  * @return Insert
  */
 public function insert(array $values = array())
 {
     $query = new Insert($this);
     return $query->values($values);
 }
示例#16
0
<?php

require '../model/class_connect_db.php';
require '../model/class_insert.php';
if (isset($_POST['opt_name'], $_POST['opt_value'])) {
    $name = $_POST['opt_name'];
    //echo $name;
    //return;
    $value = $_POST['opt_value'];
    //echo $value;
    //return;
    $insert = new Insert();
    $result = $insert->add_opt($name, $value);
    if ($result == true) {
        header("Location: ../pages/opt.php");
    } else {
        var_dump($result);
    }
}
<!DOCTYPE html>
<html lang="es">
<head>
    <title>Insert Entidad</title>
	<?php 
include 'inc/common_head.php';
?>
</head>

<?php 
include 'inc/function.php';
$function = new Reads();
$fun = $function->read_all_categories();
if (isset($_POST['nombreEntidad']) and isset($_POST['Categoria'])) {
    $function2 = new Insert();
    $ins = $function2->insert_entidad($_POST['nombreEntidad'], $_POST['Categoria']);
}
?>


<body>
    <a href="index.php">Home</a><br>
    <a href="graficos.php">Graficos</a><br>
    <a href="insert-categoria.php">Categoria</a>
    <div class="row formulario-ingreso">
        <form role="form" method="POST">
          <div class="form-group">
            <label for="nombreEntidad">Ingrese nueva Empresa</label>
            <input type="text" class="form-control" id="ejemplo_email_1" name="nombreEntidad" 
                   placeholder="Nombre o rol de empresa" required>
          </div>
示例#18
0
<?php

require '../model/class_connect_db.php';
require '../model/class_insert.php';
$obj = new Insert();
$obj->addImg();
示例#19
0
<?php

require_once 'class_insert/insert.class.php';
//accedemos al método singleton que es quién crea la instancia
//de nuestra clase y así podemos acceder sin necesidad de
//crear nuevas instancias, lo que ahorra consumo de recursos
$nuevoSingleton = Insert::singleton_insert();
$nombre = $_SESSION['nick'];
$contraseña = $_SESSION['password'];
$nuevoSingleton->insert_users($nombre, $contraseña);
$_SESSION['new'] = 0;
header("Location:home.php");
示例#20
0
 public function testGenerateSqlForValues()
 {
     $this->out->into('Test')->values(['super' => 'data', 'next' => 'fieldData']);
     $expected = 'INSERT INTO `[prefix]_Test` ' . '(`super`,`next`) VALUES ("data","fieldData")';
     $this->assertEquals($expected, $this->out->generateSql());
 }
<meta charset="UTF-8">
<?php 
include 'inc/function.php';
if (isset($_POST['point'])) {
    $function = new Insert();
    $ins = $function->insert_nota($_POST['id_empresa'], $_POST['point']);
    echo "\n\t\t<form name=\"form\" action=\"grafico-actual.php\" method=\"POST\" accept-charset=\"utf-8\">\n\t\t\t<input type=\"hidden\" name=\"point\" value=\" " . $_POST['point'] . "\">\n\t\t\t<input type=\"hidden\" name=\"empresa\" value=\"" . $_POST['empresa'] . "\">\n\t\t\t<input type=\"hidden\" name=\"id_empresa\" value=\"" . $_POST['id_empresa'] . "\">\n\t\t</form>\n\n\t\t<script>\n           document.form.submit();\n\t\t</script>\n  ";
} elseif (isset($_POST['empresa']) and isset($_POST['id_empresa']) and !isset($_POST['point'])) {
    echo "<script type='text/javascript'>\n\t    alert('DEBE SELECCIONAR UNA NOTA PARA PODER CONTINUAR');\n\t    window.location='index.php';\n\t    </script>";
}
?>

示例#22
0
文件: index.php 项目: joksnet/php-old
<?php

require_once 'includes/common.php';
$id_posts = isset($_GET['id_posts']) ? $_GET['id_posts'] : (isset($_POST['id_posts']) ? $_POST['id_posts'] : 0);
$id_users = isset($_GET['id_users']) ? $_GET['id_users'] : (isset($_POST['id_users']) ? $_POST['id_users'] : 0);
list($users_data, $users_submenu) = get_users();
list($data, $posts, $pagination, $comments) = get_posts($id_posts, $id_users, $start);
if ($id_posts > 0) {
    if (isset($_POST['author'])) {
        $ins = new Insert('comments', $db);
        $ins->col['id_posts'] = $id_posts;
        $ins->col['author'] = $_POST['author'];
        $ins->col['author_email'] = $_POST['author_email'];
        $ins->col['author_url'] = $_POST['author_url'];
        $ins->col['author_ip'] = getenv('HTTP_X_FORWARDED_FOR') ? getenv('HTTP_X_FORWARDED_FOR') : $_SERVER['REMOTE_ADDR'];
        $ins->col['agent'] = $_SERVER['HTTP_USER_AGENT'];
        $ins->col['date'] = 'NOW()';
        $ins->col['content'] = strip_tags(specialchars($_POST['comment']), '<h1><b><i><a><ul><li><pre><hr><blockquote><img><p>');
        $ins->update();
        redirect('?id_posts=' . $id_posts);
    }
    $id_users = $data['id_users'];
    $comments_reply = '
<h1>Leave a Comment</h1>
<form name="frm" id="frm" action="" method="post">
    <label for="author">Author</label><input type="text" name="author" id="author" /><br />
    <label for="author_email">Email</label><input type="text" name="author_email" id="author_email" /><br />
    <label for="author_url">URL</label><input type="text" name="author_url" id="author_url" /><br />
    <label for="comment">Comment</label><textarea name="comment" id="comment"></textarea><br />
</form>
<p align="center"><a href="javascript:send();">Send</a></p>
示例#23
0
 /** @test */
 public function it_can_be_instantiated_with_table_and_no_assignments()
 {
     $insert = new Insert('news', []);
     $this->assertEquals('INSERT INTO news () VALUES ()', $insert->getStatement());
     $this->assertEquals([], $insert->getParams());
 }