SELECT文を発行する
@param  string $tbl テーブル名
@param  array $where 抽出条件
@param  array $options オプション(連想配列)
- *page* : `1` から始まるページ番号 (default: `1`)
- *limit* : 1ページあたりの件数 (default: `10`)
@return array 抽出されたレコード
185544
public function select($tbl, $where, $options = array()){
		return $this->crud->select($tbl, $where, $options);
	}
265786
public static function getFieldsWithAllData($tbl): array
    {
        if (isset(self::$_cached_tbl_fields[$tbl])) {
            return self::$_cached_tbl_fields[$tbl];
        }

        return self::$_cached_tbl_fields = self::q_assoc_id("SHOW FIELDS FROM `$tbl`");
    }
797896
public function select(array $where = [], array $nosql_options = [])
    {
        // Set statement
        $query = $this->getSelect($where);
        $statement = $this->getInstance()->prepare($query);

        // Bind where values
        foreach ($where as $key => $value) {
            $statement->bindValue(":where_$key", $value, $this->isPdoInt($value));
        }

        // Execute operation
        $statement->execute();

        // Return object
        return $statement->fetchAll(PDO::FETCH_OBJ);
    }
196375
public static function c($table, $where) {
        $row = DB::qbr($table, array("where" => $where, "cols" => "id"));
        if (!$row) return false;
        return $row["id"];
    }
826976
public function selectOne($where) {
        $clause = false;
        $values = false;
        $retval = self::extractWhere($where, $clause, $values);
        if ( is_string($retval) ) throw new \Exception($val);

        $sql = "SELECT KVS.id AS id, json_body, KVS.created_at, KVS.updated_at
            FROM $this->KVS_TABLE AS KVS
            WHERE $this->KVS_FK_NAME = :foreign_key AND $this->KVS_SK_NAME = :secondary_key AND ".$clause." LIMIT 1";
        $values[':foreign_key'] = $this->KVS_FK;
        $values[':secondary_key'] = $this->KVS_SK;
        $row = $this->PDOX->rowDie($sql, $values);
        if ( $row === false ) return false;

        $retval = json_decode($row['json_body'], true);
        if ( is_array($retval) ) {
            $retval['id'] = intval($row['id']);
            $retval['created_at'] = $row['created_at'];
            $retval['updated_at'] = $row['updated_at'];
        }
        return $retval;
    }
475429
public function where($where)
    {
        //Argument 1 must be a string or array
        Argument::i()->test(1, 'string', 'array');
        
        if (is_string($where)) {
            $where = array($where);
        }
        
        $this->where = array_merge($this->where, $where);
        
        return $this;
    }
801870
public static function first($table,$where=[],$option=[])
    {
        $sql=self::parseSql($table,$where,$option);
        return $sql->fetch();
    }
564158
public function update($tbl, $where, $data){
		$table_definition = $this->exdb->get_table_definition($tbl);
		$delete_flg_id = $table_definition->system_columns->delete_flg;

		foreach($table_definition->columns as $key=>$val){
			if( !array_key_exists( $key, $where ) && !array_key_exists( $key, $data ) ){continue;}
			if( $table_definition->columns->{$key}->type == 'password' ){
				// パスワードをハッシュ値化
				if( array_key_exists($key, $where) ){ $where[$key] = $this->exdb->encrypt_password($where[$key]); }
				if( strlen($data[$key]) ){
					if( array_key_exists($key, $data) ){ $data[$key] = $this->exdb->encrypt_password($data[$key]); }
				}else{
					unset($data[$key]);
				}
			}elseif( $table_definition->columns->{$key}->type == 'delete_flg' ){
				// delete_flgを 0 or 1 に整形
				if( array_key_exists($key, $where) ){ $where[$key] = ($where[$key] ? 1 : 0); }
				if( array_key_exists($key, $data) ){ $data[$key] = ($data[$key] ? 1 : 0); }
			}
		}
		if( is_string($delete_flg_id) && @is_null( $where[$delete_flg_id] ) ){
			$where[$delete_flg_id] = 0;
		}

		$errors = $this->exdb->validate( $tbl, $data );
		if( count($errors) ){
			return false;
		}

		$sql = array();
		$sql['update'] = 'UPDATE '.$this->exdb->get_physical_table_name($tbl).'';
		$sql['set'] = ' SET ';
		$sql['where'] = ' WHERE ';
		$sql['close'] = ';';

		$bind_data = array();

		$sql_set = array();
		$is_update_date = false;
		foreach( $data as $column_name => $data_row ){
			array_push($sql_set, $column_name.'=:__set__'.$column_name);
			$bind_data['__set__'.$column_name] = $data_row;
			if( $table_definition->system_columns->update_date === $column_name ){
				$is_update_date = true;
			}
		}

		$sql_where = array();
		foreach( $where as $column_name => $cond ){
			array_push($sql_where, $column_name.'=:__where__'.$column_name);
			$bind_data['__where__'.$column_name] = $cond;
		}

		if($table_definition->system_columns->update_date){
			// 最終更新日時を自動的にセットする
			$bind_data[':__set__'.$table_definition->system_columns->update_date] = date("Y-m-d H:i:s");
			if( !$is_update_date ){
				array_push($sql_set, $table_definition->system_columns->update_date.'=:__set__'.$table_definition->system_columns->update_date);
			}
		}


		$sql_template = $sql['update'].(count($sql_set) ? $sql['set'].implode($sql_set, ', ') : '').(count($sql_where) ? $sql['where'].implode($sql_where, ' AND ') : '').$sql['close'];
		// var_dump($sql_template);
		$sth = $this->exdb->pdo()->prepare( $sql_template );
		$result = $sth->execute( $bind_data );
		if( $result === false ){
			return false;
		}
		$result = $sth->rowCount();
		// var_dump($result);

		return $result;
	}
462309
public function getResult($wheres = [], $selectField = '*', $options = NULL)
    {
        try {
            if (is_array($wheres) && count($wheres) > 0) {
                foreach ($wheres as $field => $value) {
                    if (is_array($value)) {
                        $this->db->where($field, $value, self::OPERATOR_IS_IN);
                    } else {
                        $this->db->where($field, $value, self::OPERATOR_EQUAL_TO);
                    }
                }
            } else {
                $this->db->where($this->primaryKey, $wheres, self::OPERATOR_EQUAL_TO);
            }
            if (isset($options['orderBy']) && is_array($options['orderBy'])) {
                foreach ($options['orderBy'] as $column => $direction) {
                    $this->db->orderBy($column, $direction);
                }
            }
            $result = $this->db->get($this->table, NULL, $selectField);
            $this->debug->debug(__FUNCTION__, 'Format is get all Result => ' . json_encode($result));

            return $result;
        }
        catch (\Exception $e) {
            $this->debug->error(__FUNCTION__, $e->getFile() . ' - Line: ' . $e->getLine() . ' - Message: ' . $e->getMessage());

            return NULL;
        }
    }
1366454
public function query(array $where, array $options = []) {
        $options += [
            'order' => $this->getDefaultOrder(),
            'limit' => $this->getDefaultLimit(),
            Db::OPTION_FETCH_MODE => $this->getFetchArgs()
        ];

        $stmt = $this->db->get($this->name, $where, $options);
        return $stmt;
    }
5529
public function buildSelectSql($options=array()) {
        if(isset($options['page'])) {
            // 根据页数计算limit
            list($page,$listRows)   =   $options['page'];
            $page    =  $page>0 ? $page : 1;
            $listRows=  $listRows>0 ? $listRows : (is_numeric($options['limit'])?$options['limit']:20);
            $offset  =  $listRows*($page-1);
            $options['limit'] =  $offset.','.$listRows;
        }
        $sql  =   $this->parseSql($this->selectSql,$options);
        return $sql;
    }
338856
protected function _where(Kwf_Db_Table_Select $select, $where)
    {
        $where = (array) $where;

        foreach ($where as $key => $val) {
            // is $key an int?
            if (is_int($key)) {
                // $val is the full condition
                $select->where($val);
            } else {
                // $key is the condition with placeholder,
                // and $val is quoted into the condition
                $select->where($key, $val);
            }
        }

        return $select;
    }
267231
function select($fields,$filter=NULL,array $options=NULL,$ttl=0) {
		list($sql,$args)=$this->stringify($fields,$filter,$options);
		$result=$this->db->exec($sql,$args,$ttl);
		$out=[];
		foreach ($result as &$row) {
			foreach ($row as $field=>&$val) {
				if (array_key_exists($field,$this->fields)) {
					if (!is_null($val) || !$this->fields[$field]['nullable'])
						$val=$this->db->value(
							$this->fields[$field]['pdo_type'],$val);
				}
				unset($val);
			}
			$out[]=$this->factory($row);
			unset($row);
		}
		return $out;
	}
1276756
protected function whereInSelect(array $where)
    {
        return $this->wrap($where['column']) . ' ' . ($where['not'] ? 'NOT IN ' : 'IN ') . '(' . $this->select($where['subquery']->getSQLStatement()) . ')';
    }
1147594
function orwhere($where)
    {
        $args = func_get_args();
        if (count($args) == 1)
        {
            $where = $args[0];
        }
        else
        {
            list($field, $expr, $value) = $args;
            $where = '`'.str_replace('`', '', $field).'`' . $this->db->quote($expr) . " '".$this->db->quote($value)."'";
        }

        if ($this->where == "")
        {
            $this->where = "where " . $where;
        }
        else
        {
            $this->where = $this->where . " or " . $where;
        }
    }
1274645
public function listDatabases($condition = [], $options = [])
    {
        $document = array_merge(['listDatabases' => 1], $options);
        if (!empty($condition)) {
            $document['filter'] = (object)$this->buildCondition($condition);
        }
        return $document;
    }
97896
public function findWhere(array $where, $columns = ['*'])
    {
        $this->applyCriteria();
        $this->applyScope();

        $this->applyConditions($where);

        $model = $this->model->get($columns);
        $this->resetModel();

        return $this->parserResult($model);
    }