All Questions

Tagged with
Filter by
Sorted by
Tagged with
47 votes
4 answers
107k views

Check if laravel model got saved or query got executed

I've seen alot of people using this way to check if a laravel model got saved. So now I wonder if it is a safe way. And also can I check if the queries bellow got executed like this Check if model ...
user2722667's user avatar
  • 8,495
23 votes
8 answers
45k views

How would I use ON DUPLICATE KEY UPDATE in my CodeIgniter model?

I have a CodeIgniter/PHP Model and I want to insert some data into the database. However, I have this set in my 'raw' SQL query: ON DUPLICATE KEY UPDATE duplicate=duplicate+1 I am using CodeIgniter ...
Jack's user avatar
  • 9,693
17 votes
1 answer
42k views

Node.js MySQL model designing

I'm developing a node.js application using MySQL database but I'm stuck with making models on the node.js side of my application. I've used Mongoose before to produce schemas and use models to do ...
Tanmoy's user avatar
  • 171
16 votes
5 answers
26k views

How to use multiple databases dynamically for one model in CakePHP

Ok, my first question was modified so many times that I chose to delete it and reformulate my question. I've made a small test-case project with different model-names to find a proper solution for my ...
Ariaan's user avatar
  • 1,106
13 votes
2 answers
9k views

Django Model Auto Increment Primary Key Based on Foreign Key

I'm trying to figure out how to lay out two of my Django models so that when a new model is saved to the database, its primary key is incremented such that it is the next highest value for all records ...
Dirk's user avatar
  • 3,033
11 votes
3 answers
11k views

Magento model won't save values

I'm working on a backend module that saves to a custom table. My problem is that I've added fields to this table as I've been working on it, the newly added fields won't save with the model ->Save() ...
Christoffer Bubach's user avatar
11 votes
3 answers
12k views

Writing MySQL Node.js models using node-mysql

I'm trying to find some good practices for writing MySQL models using node-mysql. Here's what I have so far: var client = app.settings.client; // Client is set in Express settings var table = '...
Josh Smith's user avatar
  • 14.9k
9 votes
2 answers
10k views

sailsjs 1.0 model attribute type date columntype datetime error out in sailsjs

In sailsjs 1.0@beta I have a model linked to a view in mysql table with mysql-sails@beta adapter. The model is configured the following way: attributes: { id: {type:'number', required: true}, ...
Alex D's user avatar
  • 713
9 votes
1 answer
4k views

Yii2: Prevent empty string in attribute of ActiverRecord

What's the best way to prevent that an empty string gets inserted into a field of an MySQL's InnoDB table? Allowed values are strings with more than zero characters or NULL. I'm asking that because ...
robsch's user avatar
  • 9,518
9 votes
1 answer
1k views

Relationship References disbled table while generating model through intellij hibernate persistence tool

I have a table created on mysql with following sql CREATE TABLE `ssk_cms_category_transaction_type_relation` ( `categoryId` int(11) NOT NULL, `typeId` int(11) NOT NULL, `createdTime` timestamp ...
Syed Anas's user avatar
  • 1,466
9 votes
1 answer
7k views

Troubleshooting "Error: Unable to serialize database:" when performing dumpdata

For some reason today I cannot dump my database using python manage.py dumpdata or from a link that can download the mysql file. I tried to use python manage.py dumpdata --traceback and here is the ...
Shehzad009's user avatar
  • 1,587
8 votes
2 answers
11k views

set auto increment initial value for id in django model

i have a model with just one field. name. class City(models.Model): <br> name = models.CharField(max_length=30) Django sets id by itself so I end up with id and a description field in SQL. ...
A.J.'s user avatar
  • 8,777
7 votes
2 answers
4k views

Laravel Global Settings Model

I'm working on building a small CRUD app in Laravel 5. I have a few app wide settings such as "SiteTitle" and "BaseURL" I'd like to give my admins the ability to change from the UI. My whole app uses ...
Moose's user avatar
  • 1,241
7 votes
2 answers
18k views

Sequelize select only chosen attributes

I am using MySQL database, when I am doing: models.modelA.findAll({ attributes: [ ['modelA.id','id'] ], raw: true, include: ...
Marcin's user avatar
  • 427
7 votes
3 answers
4k views

CakePHP added column doesn't appear in query

I have added a new_column to a MyISAM table on a MySQLproduction server. I have deleted the appropriate model cache file from the /app/tmp/models folder. Upon reloading the page and inspection, the ...
Vanja D.'s user avatar
  • 844
7 votes
3 answers
3k views

How can I know if a table column is a foreign key in Laravel through Model?

So as the title says, how can I know if a field of a Model is a foreign key in Laravel ? Supose I have a FK column called show_type_id and a model named Event and I want to know if there is a function ...
didix16's user avatar
  • 113
7 votes
1 answer
6k views

NodeJS sequelize auto generate models and run migrations SQL syntax error

I am building a new NodeJS application with MySQL. I need to use the existing database schema. I have a mysql dump file that is loaded into the database (in a docker container). I am trying to ...
ktamaral's user avatar
  • 2,371
6 votes
2 answers
42k views

How to create custom MySQL queries in CakePHP?

I am trying to create my own MySQL queries in Cakephp. This is my LocationsController.php: <?php App::uses('Location', 'Model'); class LocationsController extends AppController { public $...
Johnathan Au's user avatar
  • 5,314
6 votes
3 answers
8k views

Two primary keys specified in MySQL database

I am trying to create a test database that is a replica of a preexisting database. I am using Django models (theoretically the models used with the original database) in order to do this. I recently ...
mshell_lauren's user avatar
6 votes
1 answer
2k views

How to set an alias on a Model::query() in Phalcon Framework

How to set an SQL alias for a Phalcon Model. A method alias() does not exist. A sample of what i need: $modelA = ModelA::query() ->alias('q') ->columns(['q.*','concat(q.id,...
Mihai Petcu's user avatar
6 votes
3 answers
5k views

Best database design for a "sensor system"

I'm doing a schoolwork and.. I have to do a vehicle tracker system. I thought of these three designs. What do you think? My database schemas Opinions?
Nick's user avatar
  • 61
5 votes
1 answer
8k views

How to pass dynamic table name in gorm model

I am using Gorm ORM for my current application. I have one model correspondents to many tables with identical table structures(i.e. column name and type). So my requirement how can I change the table ...
Coder's user avatar
  • 73
5 votes
1 answer
3k views

How do I specify type of index in django? (btree vs hash vs etc)

Like the title says, how do I specify the type of index I want on a field in a model in django? class Person: ... age = models.IntegerField(db_index=True) What now? How do I ensure that it ...
AlanSTACK's user avatar
  • 5,760
5 votes
3 answers
2k views

How to add associations to Models generated from Sequelize-Auto

For an existing MySQL database, I used Sequelize-auto package to generate the models. But the associations don't come with model classes. I have an MySQL database and I'm using it for NodeJS web ...
Yasiru Nilan's user avatar
5 votes
2 answers
2k views

Django cooking recipes site model structure

I'm working on Django website that should give a possibility to select cooking recipes containing the ingredients provided by user. So in brief, the idea of the site is "things you could make from the ...
Volodymyr Smirnov's user avatar
5 votes
1 answer
1k views

Change database connection according to domain

We have multiple domain running on the same application. Currently , our database environment setting is having config database replicated to every database server. The slave server owns config ...
xyonme's user avatar
  • 395
5 votes
1 answer
627 views

Ember Models and SQL - Joining tables on server or via Ember relationships?

With Ember, you can find a number of tutorials on building blogs and to do lists, but there doesn't seem to be much on anything that requires more complex models. I'm looking for a little more ...
EmptyArsenal's user avatar
  • 7,424
4 votes
6 answers
8k views

How to update model from database in Visual Web Developer 2010 Express?

I have an existing model for a MySQL database. I've added a new table in my database and now I want to update the model. But when I right-click in the Model browser and select Update Model from ...
Bobrovsky's user avatar
  • 14.1k
4 votes
2 answers
5k views

Unable to move (click and drag) entities in MySQL Workbench EER Diagram

I am modelling a database using MySQL Workbench - EER model. Now, I would like to move around certain entities so I can wrap them in separate layer for better visual look. My problem is that I am not ...
Vladimir's user avatar
  • 1,674
4 votes
3 answers
17k views

MySQL - SELECT data and create a "virtual" table

Let's say my database table looks like this: page_table | id | page_id | meta_id | value ---------------------------------------- | 1 | 2 | 1 | Testing value | 2 | 2 | 2 | ...
Jens Törnell's user avatar
4 votes
1 answer
277 views

Merge two queries and order them on base of created_at in Laravel

I've created Models for two tables. Now I want to perform a query and merge the results based on created_at. My queries are: $first = RequestF::where('userId','=',$userId)->get(); $...
Reza_Rg's user avatar
  • 3,364
4 votes
3 answers
4k views

How to check if any of the fields of a model are null or empty?

I have a model, $userModel. I want to check if any of the fields for this model are empty or null. At the moment I am doing it with a big if statement. if(!empty($userModel->name) && !...
J_Strauton's user avatar
  • 2,368
4 votes
1 answer
3k views

zend select query inside joinleft

How to write SELECT query inside JOIN LEFT in a Zend model? for eg how to convert the following mysql query to zend model query LEFT JOIN (SELECT count(*) as game_count,topic_id,time as ...
Harish Ambady's user avatar
4 votes
3 answers
432 views

Database structure - is mySQL the right choice?

We are currently planning the database structure of a quite complex e-commerce web app that has flexibility as its main cornerstone. Our app features a large amount of data (products) and we have run ...
Industrial's user avatar
  • 42.2k
4 votes
1 answer
138 views

Defining relationships across Multiple Models - Django

I have the following relationship between three Django models: class TestCase(models.Model): ''' Define the testcase model. A testcase is a python Class which contains a set of ...
cybertextron's user avatar
  • 10.8k
4 votes
2 answers
2k views

Development of railway enquiry system, how to model Trains, Stations and Stops?

For example, if I have two trains, X and Y and they travel: TRAIN.........STATIONS Train-X : Goes Via Station-A; Station-B; Station-C; Station-D Train-Y : Goes Via Station-B; Station-X; Station-D;...
san's user avatar
  • 280
4 votes
2 answers
2k views

Laravel 5 firstOrCreate keep create even set unique to the field

Below is my app\Cart.php use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; class Cart extends Model { use SoftDeletes; protected $table = 'cart'; ...
Kenny Ong's user avatar
  • 401
4 votes
1 answer
152 views

Record some data to database in Codeigniter

I got a problem I have a questionnaires website using students as respondents to fill in the matter of the website. The Problem is, when sending data contained on the results of questionnaires to the ...
Ron Ashrovy's user avatar
3 votes
4 answers
6k views

Automate database table creation from within CakePHP framework

I'm trying to write a webapp with CakePHP, and like most webapps I would like to create an installer that detects whether the database has been initialized and, if not, executes the installation ...
Magsol's user avatar
  • 4,670
3 votes
3 answers
10k views

Laravel model relationships Class not found

In Laravel I just started with models and I have this database structure: users id | username | password | group | //(group is the id of the group) groups id | groupname | group_pages group_id | ...
Loko's user avatar
  • 6,619
3 votes
1 answer
4k views

Path Enumeration mySQL Querying to create a bread crumb

I would like to create a bread crumb from a path enumerated column. Here is an example of the dataset that I have. https://spreadsheets.google.com/ccc?key=...
Layke's user avatar
  • 52.2k
3 votes
3 answers
240 views

Laravel manually update timestamps returns null

I have an offer with some children. I want to update expire_time field of each children when their parent expire_time field changed. but it returns null. expire_time type is timestamps. and here ...
Samira kalantari's user avatar
3 votes
1 answer
880 views

Nested one to many relationships in Eloquent

Let's say I have three models with this relationsship USER hasMany (app/organisation) ORGANISATION hasMany (app/order) ORDER For one level I could just go user->organisations()->get() And get all ...
Christoffer's user avatar
  • 7,647
3 votes
1 answer
7k views

Model a ISA relation in MySQL with Foreign Keys

How to model an ISA class? A 'Persoon' ISA 'Student' or a 'Docent', how do you model this in MySQL? I tried to make a Persoon class, with 2 field and then you can put the ID of the student / docent in ...
atMaarten's user avatar
3 votes
1 answer
668 views

Django charfield model with db query

I am trying to generate a select menu on hello.html with a list from a db query. My models.py: class hello(models.Model): q = """ SELECT * FROM ZONAS WHERE cod_zona = 1 """ db....
ClaudioA's user avatar
  • 327
3 votes
1 answer
265 views

Select exact matching columns from table in Zend...?

I am facing a strange issue in my Zend Application: My model is like this: public function checkEmailAndProfileName($emailId, $proName) { $select = $this->select() ->...
user avatar
3 votes
3 answers
5k views

Django: How to model a MySQL VARBINARY HEX Field?

I am trying to model a VARBINARY MySQL field in Django v1.1.1. The binary field stores a hexadecimal representation of data (i.e. one would use INSERT INTO test(bin_val) VALUES X'4D7953514C') Reading ...
the_void's user avatar
  • 5,528
3 votes
1 answer
1k views

How do I update a foreign key (belongsTo) in Sequelize

I have the following model: 'use strict'; const {Model} = require('sequelize'); module.exports = (sequelize, DataTypes) => { class Key extends Model { static associate(models) { Key....
Traveling Tech Guy's user avatar
3 votes
2 answers
411 views

Accessing associated models of HABTM relationships via bindModel() w/o recursion

The Problem In A Nutshell I want to retrieve data from Model A that HABTM Model B via a find() operation in Model B's controller without relying on extensive recursion. $this->ModelB->...
Jonline's user avatar
  • 1,697
3 votes
2 answers
295 views

Proper way to model user groups

So I have this application that I'm drawing up and I start to think about my users. Well, My initial thought was to create a table for each group type. I've been thinking this over though and I'm not ...
ohiock's user avatar
  • 646

1
2 3 4 5
11