1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

自作SQLcontrolクラスの使い方

Last updated at Posted at 2013-06-24

SQL作成のための自作SQLcontrolクラスの使い方

テーブルとフィールドの設定

<?php
//SQL文の作成
$sql = new SQLcontrol;
$sql->addField("id");   //フィールド指定
$sql->addTable("project");  //テーブル指定
?>

カスタマイズ

<?php
$sql->addWhere("com=?",$com->getId()); //where句(AND)
$sql->addWhereOR("com=?",$com->getId()); //where句(OR)
$sql->addOrder("total-totalB ASC"); //order by句
?>

ページャー使うときはlimitの前に全体数を取得しとくといいよ

<?php
//limitを追加する前に全体数の取得
$count = Model::db_query($sql->getSQL(),$sql->getData());

limit句

<?php
$sql->addLimit($pagestart.",".$_POST["itemnum"]); //limit句
?>

出力

<?php
//var_dump($sql->getSQL());
//var_dump($sql->getData());
//exit;
//SQL生成
$result = Model::db_query($sql->getSQL(),$sql->getData());
?>

コピペ用

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?