-
Notifications
You must be signed in to change notification settings - Fork 10.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get field count of a table #1604
Comments
No, there isn't. (This kind of question is probably better suited for the forums.) |
Getting this from query ( DB::select('SHOW TABLES') ) foreach, solved by using substr_replace(). But I am requesting to add a laravel DB method to get table field count. |
I'm sure you could use the Doctrine schema manager to get this information. Explore that DB::getDoctrineSchemaManager method. |
Thanks. Sorry for the issue report, I am a beginner and noticed the API function now only. |
Updated my code using the API: $schema = DB::getDoctrineSchemaManager(); Fixed enum problem here, #1346 |
I am using this to get my table names DB::select('SHOW TABLES') and after that I would like to get field count for each tables.
The following query is working when I am not using table prefix in database configuration.
But after adding table prefix, the query duplicates the prefix. (dev_dev_branches instead of dev_branches).
$fields = DB::selectOne("SELECT COUNT(*) AS field_count FROM information_schema.
COLUMNS
C WHERE table_name = '".$table."' AND TABLE_SCHEMA = '".$database."'");$num_fields = $fields->field_count;
Is there any laravel 4 function to get field count ?
The text was updated successfully, but these errors were encountered: